标签:none ati use over 窗体 info 技术 patch one
源码
1 #include<Windows.h> 2 3 LRESULT CALLBACK WindProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); 4 5 int WinMain(HINSTANCE hInst, HINSTANCE tmp, LPSTR szCmd, int nShow) 6 { 7 WNDCLASS WndClass; 8 TCHAR* ClassName = TEXT("MyClass"); 9 HWND hwnd; 10 MSG msg; 11 12 WndClass.cbClsExtra = 0; 13 WndClass.cbWndExtra = 0; 14 WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 15 WndClass.hCursor = LoadCursor(NULL, IDC_ARROW); 16 WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); 17 WndClass.hInstance = hInst; 18 WndClass.lpfnWndProc = WindProc; 19 WndClass.lpszClassName = ClassName; 20 WndClass.lpszMenuName = NULL; 21 WndClass.style = CS_VREDRAW | CS_HREDRAW; 22 23 if (!RegisterClass(&WndClass)) 24 { 25 MessageBox(NULL, TEXT("Gegister Class Fail!!"), TEXT("error"), MB_OK); 26 return 0; 27 } 28 29 hwnd = CreateWindow(ClassName, TEXT("Hello"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 500, 300, NULL, NULL, hInst, NULL); 30 if (hwnd == NULL) 31 { 32 MessageBox(NULL, TEXT("Create Window Fail!!"), TEXT("error"), MB_OK); 33 return 0; 34 } 35 ShowWindow(hwnd, nShow); 36 UpdateWindow(hwnd); 37 38 while (GetMessage(&msg,NULL,0,0)) 39 { 40 TranslateMessage(&msg); 41 DispatchMessage(&msg); 42 } 43 44 return 0; 45 } 46 47 LRESULT CALLBACK WindProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 48 { 49 switch (message) 50 { 51 case WM_DESTROY: 52 PostQuitMessage(0);//发送WM_QUIT消息 53 return 0; 54 default: 55 break; 56 } 57 58 return DefWindowProc(hwnd, message, wParam, lParam); 59 }
WIndows窗体程序的一生 ,大部分时间都在消息循环中度过。
标签:none ati use over 窗体 info 技术 patch one
原文地址:https://www.cnblogs.com/kelamoyujuzhen/p/9300449.html