-
Window resizeing wrong
Ok, the problem is say I create a window at 800x600, but the window ends up a different size (Window cannot be sized by a user). Using WM_SIZE to get the updated sizes for the window class I find that the width and height of the window have shrunk! Usually by 10-20 on both, in the above example something like 792x573 or something like that. Now the problem, the application supports fulscren mode using the default window size of 800x600 but since the values have changed the call to DisplayMode fails since there is no 792x573. The values for the window size stay 800x600 untill WM_SIZE when they get corrupted, after debugging im lost, since the only WM_SIZE called is from the CreateWindowEx call.
-
WM_SIZE provides the client dimension (like GetClientRect does); CreateWindowEx supplies window dimensions ie. client + borders, menu dimensions etc (the height and width would be same as generated by GetWindowRect). If the only window style is WS_POPUP then window and client dimesions will be the same, since there's no border etc. AdjustWindowRectEx (and AdjustWindowRect) allows you to calculate window size based on desired client size. Or you can query border etc dimensions from GetSystemMetrics and do the conversions based on client or window size for yourself.
-
Thanks Ken, maybe you can help me with the next problem, when using WS_OVERLAPPED window everything renders fine (GL) but if specifying WS_POPUP nothing renders. Ive been debugging and find right after RegisterClassEx an error code of 2 is returned (system cannot find the specified file) , I dont know why it says that since right now im only loading the default mouse cursor and it does. Next it gives me an error of 127 (the specified procedure can not be found) if I check an error during WM_CREATE before and after doing anything in the message processing. After returning from window creation (call from CreateWindowEx returns) I get the error 1400 (Invalid window handle) but the hWnd, hInstance are both valid (only with WS_POPUP otherwise still 127). Heres a link to the code if you dont mind looking through it. GLWindow
Edit:
I striped out the GL stuff and created an app using the base class CBWindow and still get the 2 and 127 errors. Heres the striped version Stripped Version
-
After doing a lot of searching I found that GetLastError will return 2 if called after a successful call to RegisterClassEx and I should only check it if the value returned by registering is 0. So im asuming the same is with 127 being returned after CreateWindowEx is called. Ive uploaded a newer version of the code but still cant see why nothing is rendered if I simply the style to WS_POPUP (tried changing some demos to use WS_POPUP in window mode and they work).
GLWindow
-
Your GLWindow::ResizeWindow member function is only called in response to a WM_SIZE event, an event which a window with only WS_POPUP as a window style never receives. This means that the viewport and perspective are never set - a call to GLWindow::ResizeWindow in your GLWindow::Create function, after the call to Initialize with suitable width and height (GetClientRect), will remedy this.
-
Ken you are a God!!!! Tired eyes never find the problem.