win32- 窗口模板
主要用于日常的win32窗口的测试
#include <Windows.h> #include <stdio.h> #include <iostream> using namespace std; LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { if (message == WM_DESTROY) { PostQuitMessage(0); } return DefWindowProc(hwnd, message, wParam, lParam); }; HINSTANCE hinst; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevinstance, PSTR szCmdLine, int iCmdShow) { HWND hwnd; hinst = GetModuleHandle(NULL); // create a window class: WNDCLASS wc = {}; wc.lpfnWndProc = WndProc; wc.hInstance = hinst; wc.lpszClassName = L"win32"; // register class with operating system: RegisterClass(&wc); // create and show window: hwnd = CreateWindow(L"win32", L"My program", WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL, 0, 0, 1000, 800, NULL, NULL, hinst, NULL); if (hwnd == NULL) { return 0; } ShowWindow(hwnd, SW_SHOW); MSG msg = {}; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } }