/* WINMAIN *******************************************************************************/
int WINAPI WinMain(HINSTANCE hinstance,
HINSTANCE hprevinstance,
LPSTR lpcmdline,
int ncmdshow)
{
WNDCLASS winclass;
HWND hwnd;
MSG msg;
HDC hdc;
PAINTSTRUCT ps;
/* CS_DBLCLKS Specifies that the window should be notified of double clicks with
* WM_xBUTTONDBLCLK messages
* CS_OWNDC标志,属于此窗口类的窗口实例都有自己的DC(称为私有DC),私有DC仅属于该窗口实例,
* 所以程序只需要调用一次GetDC或BeginPaint获取DC,系统就为窗口初始化一个DC,并且保存程序
* 对其进行的改变。ReleaseDC和EndPaint函数不再需要了,因为其他程序无法访问和改变私有DC.
*/
winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc = WindowProc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hinstance;
winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName = NULL;
winclass.lpszClassName = WINDOW_CLASS_NAME;
// register the window class
if (!RegisterClass(&winclass))
return 0;
// Create the window, note the use of WS_POPUP
hwnd = CreateWindow(
WINDOW_CLASS_NAME, // class
TEXT("WIN32 Game Console"), // title
WS_OVERLAPPEDWINDOW, // style
0, 0, // initial x, y
WINDOW_WIDTH, // initial width
WINDOW_HEIGHT, // initial height
NULL, // handle to parent
NULL, // handle to menu
hinstance, // instance
NULL); // creation parms
if (! hwnd)
return 0;
ShowWindow(hwnd, ncmdshow);
UpdateWindow(hwnd);
// hide mouse
//ShowCursor(FALSE);
// save the window handle and instance in a global
main_window_handle = hwnd;
main_instance = hinstance;
// perform all game console specific initialization
//Game_Init();
// enter main event loop
while (1)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
// test if this is a quit msg
if (msg.message == WM_QUIT)
break;
// translate any accelerator keys
TranslateMessage(&msg);
// send the message to the window proc
DispatchMessage(&msg);
}
// main game processing goes here
//Game_Main();
}
// shutdown game and release all resources
//Game_Shutdown();
// show mouse
//ShowCursor(TRUE);
// return to windows like this
return (msg.wParam);
}