Advertisement
Guest User

CreateWindow Type Error

a guest
Jan 7th, 2014
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.86 KB | None | 0 0
  1. #include <Windows.h>
  2.  
  3. //Forwards Declarations
  4. bool InitMainWindows(HINSTANCE, int);
  5. LRESULT CALLBACK MsgProc(HWND, UINT, WPARAM, LPARAM);
  6.  
  7. //Constants
  8. const int WIDTH = 800;
  9. const int HEIGHT = 600;
  10.  
  11. HWND hwnd = NULL;//Handle to window
  12.  
  13. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){
  14.     return(1);
  15. }
  16.  
  17. bool InitMainWindow(HINSTANCE hInstance, int nCmdShow){
  18.  
  19.     //Inital structure setup
  20.     WNDCLASSEX wcex;
  21.     wcex.cbSize = sizeof(wcex);
  22.     wcex.style = CS_HREDRAW | CS_VREDRAW;//Set to redraw on resize
  23.  
  24.     //0 extra bytes if data
  25.     wcex.cbClsExtra = 0;
  26.     wcex.cbWndExtra = 0;
  27.  
  28.     wcex.lpfnWndProc = MsgProc;
  29.  
  30.     wcex.hInstance = hInstance;//Set handle for window
  31.  
  32.     wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);//Set App icon to defualt
  33.     wcex.hCursor = LoadCursor(NULL, IDC_ARROW);//Set defualt cursor
  34.     wcex.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);//Set app background intialy
  35.     wcex.lpszClassName = "HelloDirectXClass";
  36.     wcex.lpszMenuName = NULL;
  37.     wcex.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
  38.  
  39.  
  40.     if (!RegisterClassEx(&wcex)){//If window structure fails to load program will exit
  41.         return false;
  42.     }
  43.  
  44.     //Create the window
  45.     hwnd = CreateWindow(
  46.         "HelloDirectXClass",//Class name, defined above
  47.         "Hello DirectX",//Top bar title
  48.         WS_OVERLAPPED | WS_SYSMENU, WS_CAPTION,//Window style, using default
  49.         GetSystemMetrics(SM_CXSCREEN) / 2 - WIDTH / 2,//Position relitive to top left corner, X CXSCREEN notice the CX<--for X or width
  50.         GetSystemMetrics(SM_CYSCREEN) / 2 - HEIGHT / 2,//Position relitive to top left corner, Y CYSCREEN notice the CY<--for Y or height
  51.         WIDTH,
  52.         HEIGHT,
  53.         (HWND)NULL,//Setting window parent
  54.         (HMENU)NULL,
  55.         hInstance,//Window instance defined above
  56.         (LPVOID)NULL);
  57.  
  58.     if (!hwnd){//Check if window exists
  59.         return false;//If not exit program
  60.     }
  61.  
  62.     ShowWindow(hwnd, nCmdShow);
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement