#include "stdafx.h" #include "win32.h" #include "windows.h" #include #define MAX_LOADSTRING 100 HWND g_hWnd = NULL; HINSTANCE g_hInst; LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); void CreateWnd(void) { WNDCLASS wc = {0}; wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = g_hInst; wc.hIcon = NULL; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_WINDOW); wc.lpszMenuName = NULL; wc.lpszClassName = TEXT("SimpleWindow"); RegisterClass(&wc); g_hWnd = CreateWindowEx(0, TEXT("SimpleWindow"), TEXT("SimpleWindow"), WS_VISIBLE, 0, 0, 200, 200, NULL, NULL, g_hInst, 0); } DWORD ThreadBaseFunc(LPVOID lpParam) { CreateWnd(); MSG msg; while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; } int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { g_hInst = hInstance; HANDLE hThrd =(HANDLE)_beginthreadex( NULL,0,(unsigned int (__stdcall*)(void*))ThreadBaseFunc,NULL,0,NULL); CloseHandle(hThrd); MSG msg; while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; } LRESULT CALLBACK WndProc(HWND hWnd,UINT wMsg,WPARAM wParam,LPARAM lParam) { return DefWindowProc(hWnd,wMsg,wParam,lParam); }
转载于:https://www.cnblogs.com/chunyou128/p/4278164.html