1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
#include <windows.h>
#include <tchar.h>
int CALLBACK WinMain(
_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nCmdShow
);
LRESULT CALLBACK WndProc(
_In_ HWND hWnd,
_In_ UINT message,
_In_ WPARAM wParam,
_In_ LPARAM lParam
);
LRESULT CALLBACK WndProc(
_In_ HWND hWnd,
_In_ UINT message,
_In_ WPARAM wParam,
_In_ LPARAM lParam
) {
return 0;
}
static TCHAR szTitle[] = _T("Hello Windows Desktop");
static TCHAR szWindowClass[] = _T("Hello");
void setUpWindowClass(WNDCLASSEX* const wcex, const HINSTANCE hInstance);
int CALLBACK WinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nCmdShow){
WNDCLASSEX wcex;
setUpWindowClass(&wcex, hInstance);
if (!RegisterClassEx(&wcex)){
MessageBox(NULL,
_T("Call to RegisterClassEx failed!"),
NULL,
NULL);
return 1;
}
HWND hWnd = CreateWindow(
szWindowClass,
szTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
500, 100,
NULL,
NULL,
hInstance,
NULL
);
if (!hWnd){
MessageBox(NULL,
_T("Call to CreateWindow failed!"),
NULL,
NULL);
return 1;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return 0;
}
void setUpWindowClass(WNDCLASSEX * const wcex, const HINSTANCE hInstance) {
wcex->cbSize = sizeof(WNDCLASSEX);
wcex->style = CS_HREDRAW | CS_VREDRAW;
wcex->lpfnWndProc = WndProc;
wcex->cbClsExtra = 0;
wcex->cbWndExtra = 0;
wcex->hInstance = hInstance;
wcex->hIcon = LoadIcon(hInstance, IDI_APPLICATION);
wcex->hCursor = LoadCursor(NULL, IDC_ARROW);
wcex->hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex->lpszMenuName = NULL;
wcex->lpszClassName = szWindowClass;
wcex->hIconSm = LoadIcon(wcex->hInstance, IDI_APPLICATION);
}
| |