www.pudn.com > bmbrsrc > WindowStuff.c


//Window handler 
long WINAPI WindowMessageHandler (HWND hWnd, UINT wMessage, WPARAM wParam, LPARAM lParam) 
{ 
  //Close window 
  if (wMessage == WM_CLOSE) Done = -1; 
  #include "bombermessages.c" 
  //Other messages 
  return DefWindowProc (hWnd, wMessage, wParam, lParam); 
} 
 
 
//Registers a new window class and creates an empty window. 
void InitWindow () 
{ 
  //For initializing the window 
  WNDCLASS      wndclass; 
  RECT          ClientArea; 
 
  //Register window class, as standard as can be 
  wndclass.style = 0; 
  wndclass.lpfnWndProc = (WNDPROC)WindowMessageHandler; 
  wndclass.cbClsExtra = 0; 
  wndclass.cbWndExtra = 0; 
  wndclass.hInstance = InstanceHandle; 
  wndclass.hIcon = LoadIcon(InstanceHandle, MAKEINTRESOURCE (IDI_MAINICON)); 
  wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); 
  wndclass.hbrBackground = GetStockObject (LTGRAY_BRUSH); 
  wndclass.lpszMenuName = NULL; 
  wndclass.lpszClassName = (LPSTR)"GAME"; 
  RegisterClass (&wndclass); 
 
  //Resize window so it can accomodate a 256x256 bitmap 
  ClientArea.left = 0; 
  ClientArea.top = 0; 
  ClientArea.right = 272; 
  ClientArea.bottom = 272; 
  AdjustWindowRect (&ClientArea, WS_CAPTION | WS_SYSMENU, FALSE); 
  ClientArea.bottom -= ClientArea.top; 
  ClientArea.right -= ClientArea.left; 
 
  //Create empty window 
  WindowHandle =  
  CreateWindow ((LPSTR)"GAME",                //Class name 
                (LPSTR)"Bomberman",           //Window name 
                WS_CAPTION | WS_SYSMENU,      //Window type 
                CW_USEDEFAULT, 0,             //Don't specify location 
                ClientArea.right,             //Specify size 
                ClientArea.bottom, 
                NULL,                         //No parent window 
                NULL,                         //No menu 
                InstanceHandle,               //It belongs to this program 
                NULL);                        //No other data 
 
  //Display the window 
  ShowWindow (WindowHandle, SW_SHOWNORMAL); 
}