#include <Windows.h> //自定义的窗口过程 LRESULT CALLBACK MyWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { switch (Msg) { case WM_DESTROY: // WM_DESTORY 代表“窗口关闭” 消息 PostQuitMessage(0); return 0; default: return DefWindowProc(hWnd, Msg, wParam, lParam); } return 0; } int WINAPI WinMain( _In_ HINSTANCE hInstance, // 窗口句柄 _In_opt_ HINSTANCE hPrevInstance, // 上一个窗口类的句柄 _In_ LPSTR lpCmdLine, // 命令行参数 _In_ int nShowCmd // 窗口的显示状态 ) { WNDCLASSW wnd = { CS_HREDRAW, DefWindowProc, 0,0, hInstance, LoadIcon(NULL, IDI_APPLICATION), LoadCursor(NULL, IDC_ARROW), (HBRUSH)(GetStockObject(WHITE_BRUSH)), NULL,L"MyWindow" }; RegisterClass(&wnd); HWND hWnd = CreateWindow(L"MyWindow", L"newWindow", WS_OVERLAPPEDWINDOW, 100, 100, 300, 300, NULL, NULL, hInstance, NULL); ShowWindow(hWnd, nShowCmd); UpdateWindow(hWnd); MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); //翻译消息 DispatchMessage(&msg); //分发消息到窗口过程 } return 0; }
标签:return,创建,c++,hInstance,hWnd,msg,窗口,NULL From: https://www.cnblogs.com/laremehpe/p/17689423.html