64,642
社区成员
发帖
与我相关
我的任务
分享
#include <windows.h>
#include <stdio.h>
const size_t namesize = 100;
const TCHAR classname[namesize] = L"wenxing";
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
switch(message)
{
case WM_CHAR:
wchar_t szChar[20];
//sprintf(szChar,"char is code %d",wparam);
MessageBox(hwnd,szChar,L"char",0);
break;
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPreInstance,LPSTR lpCmdLine,int nShowCmd)
{
WNDCLASS wnd;
wnd.style = CS_HREDRAW | CS_VREDRAW;
wnd.lpfnWndProc = WndProc;
wnd.cbClsExtra = 0;
wnd.cbWndExtra = 0;
wnd.hInstance = hInstance;
wnd.hIcon = LoadIcon(NULL,IDI_ERROR);
wnd.hCursor = LoadCursor(NULL,IDC_ARROW);
wnd.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wnd.lpszMenuName = NULL;
wnd.lpszClassName = classname;
ATOM atom = RegisterClass(&wnd);
if(!atom)
MessageBox(NULL,L"1233",L"lqm",MB_OKCANCEL);
HWND hand = NULL;
hand = CreateWindow(classname,L"Hello",WS_OVERLAPPEDWINDOW,0,0,800,600,NULL,NULL,hInstance,NULL);
ShowWindow(hand,SW_SHOWNORMAL);
if(!hand)
{
if(IDYES == MessageBox(NULL,L"创建失败!",L"lqm",MB_YESNO))
exit(0);
}
UpdateWindow(hand);
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
switch(message)
{
case WM_CHAR:
wchar_t szChar[20];
//sprintf(szChar,"char is code %d",wparam);
MessageBox(hwnd,szChar,L"char",0);
break;
}
return ::DefWindowProc(hwnd,message,wparam,lparam);
}