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
|
int WINAPI WinMain(
HINSTANCE inst,
HINSTANCE prev_inst,
LPSTR lp_cmd_line,
int n_cmd_show
)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof( WNDCLASSEX );
wcex.style = CS_VREDRAW | CS_HREDRAW;
wcex.lpfnWndProc = win_proc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 8;
wcex.hInstance = inst;
wcex.hIcon = 0;
wcex.hCursor = ::LoadCursor( NULL, IDC_ARROW );
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszMenuName = 0;
wcex.lpszClassName = "wcex";
wcex.hIconSm = 0;
if (!::RegisterClassEx( &wcex ))
return 1;
HWND hwnd = 0;
hwnd = ::CreateWindowEx(
0, "wcex", "test",
WS_OVERLAPPEDWINDOW,
0, 0, 300, 200,
0, 0, inst, 0
);
if (hwnd == 0)
return 1;
AppClass *app = 0;
app = new AppClass(5);
if (app)
::SetWindowLongPtr( hwnd, GWLP_USERDATA, (LONG_PTR)app);
else
return 0;
::ShowWindow( hwnd, SW_SHOW );
::UpdateWindow( hwnd );
MSG msg;
while (true)
{
if (::PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
{
if (msg.message == WM_QUIT)
break;
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
else
{
}
}
return static_cast<int>(msg.wParam);
}
|