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
|
#include <iostream>
#include <windows.h>
using namespace std;
LRESULT CALLBACK WindowProc (HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain (HINSTANCE h_ins, HINSTANCE h_prev, LPSTR lp_cmd, int shw_cmd) {
WNDCLASSEX wnd;
static LPCTSTR wnd_name = L"Win App";
HWND h_wnd;
MSG msg;
wnd.cbSize = sizeof (WNDCLASSEX);
wnd.style = CS_HREDRAW | CS_VREDRAW;
wnd.lpfnWndProc = WindowProc;
wnd.cbClsExtra = 0;
wnd.cbWndExtra = 0;
wnd.hInstance = h_ins;
wnd.hIcon = LoadIcon (0, IDI_APPLICATION);
wnd.hCursor = LoadCursor (0, IDC_ARROW);
wnd.hbrBackground = static_cast <HBRUSH> (GetStockObject(GRAY_BRUSH));
wnd.lpszMenuName = 0;
wnd.lpszClassName = wnd_name;
wnd.hIconSm = 0;
if (!RegisterClassEx (&wnd))
return 0;
h_wnd = CreateWindow (
wnd_name,
L"Windows example",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
0,
0,
h_ins,
0
);
ShowWindow (h_wnd, shw_cmd);
UpdateWindow (h_wnd);
while (GetMessage (&msg, 0, 0, 0)) {
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return static_cast <int> (msg.wParam);
}
|