Okay, so here is my first attempt at a main window.
The only issue with this, is that the X button at the top right doesn't work! Why?Code:BOOL CreateMainWindow(char* title, int width, int height) { DWORD dwExStyle; DWORD dwStyle; RECT WindowRect; WindowRect.left =(long)0; WindowRect.right=(long)width; WindowRect.top=(long)0; WindowRect.bottom=(long)height; hInstance = GetModuleHandle(NULL); dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style dwStyle=WS_OVERLAPPEDWINDOW; // Windows Style AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requested Size if (!(hWnd=CreateWindowEx( dwExStyle, // Extended Style For The Window WC_DIALOG, // Class Name title, // Window Title dwStyle | // Defined Window Style WS_CLIPSIBLINGS | // Required Window Style WS_CLIPCHILDREN, // Required Window Style 0, 0, // Window Position WindowRect.right-WindowRect.left, // Calculate Window Width WindowRect.bottom-WindowRect.top, // Calculate Window Height NULL, // No Parent Window NULL, // No Menu hInstance, // Instance NULL))) // Dont Pass Anything To WM_CREATE { MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } ShowWindow(hWnd,SW_SHOW); // Show The Window SetForegroundWindow(hWnd); // Slightly Higher Priority SetFocus(hWnd); // Sets Keyboard Focus To The Window return TRUE; }
Also, Can someone explain more to me about the device context? Do I need one for this main window? Or do I only need a device context when I'm drawing things, like in our OpenGL frame I want to create.


