int WINAPI WinMain (HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) {WNDCLASSEX winclass; // this will hold the class we createHWND hwnd; // generic window handleMSG msg; // generic messageHDC hdc; // graphics device context
// first fill in the window class stucturewinclass.cbSize = sizeof (WNDCLASSEX); 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; winclass . Hiconsm = loadicon (NULL, IDI_Application);
// save hinstance in globalhinstance_app = hinstance;
// register the window classif (! RegisterClassex (& WinClass) Return (0);
// Create The Windowif (! (hWnd = CREATEWINDOWEX (NULL, // Extended Style Window_class_name, // Class "DirectDraw 16-bit Full-Screen Demo", // Title WS_POPUP | WS_VISible, 0,0, // Initial X, Y Screen_Width, Screen_Height, // Initial Width Null, // Handle To Parent Null, // Instance of this Application NULL) // Extra CREATION PARMSRETURN (0);
// Save main window handlemain_window_handle = hwnd;
// Initialize Game Heregame_init ();
// enter main event loopwhile (TRUE) {// Test if there is a message in queue, if SO Get IT IF (PeekMessage (& MSG, NULL, 0, 0, PM_REMOVE)) {if (msg.Message == WM_QUIT) Break; TranslateMessage (& MSG); DispatchMessage (& MSG);} // end if // main game_main ();} // end while // CloseDown Game Heregame_Shutdown ();
// Return to Windows Like thisreturn (msg.wparam);
} // End WinMain