GetClientRect() strange behavior

Started by
2 comments, last by vladic2000x 14 years, 10 months ago
Hello! Please can somebody help me with the bug? Here's the win32 window initialization code: ----------- RECT rect; SetRect( &rect, 0, 0, 1024,768); AdjustWindowRect(&rect,WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX, false); HWND hWnd = CreateWindow(szWindowClass, szTitle,WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX, 0,0,rect.right-rect.left,rect.bottom-rect.top, NULL, NULL, hInstance, NULL); RECT clientRect; GetClientRect(hWnd, &clientRect); ---------- 1. When my monitor resolution is higher than 1024x768 the clienRect is (0,0,1024,768) 2. When I set the monitor resolution to 1024x768 the clienRect becomes (0,0,1024,755) 3. When I set the monitor resolution to 800x600 the clienRect becomes (0,0,806,587) Why is this happening? Isn't this function supposed to return the (0,0,1024,768) clientRect for any monitor resolution?
Advertisement
While playing with the code I noticed that the window's size is never greater than the resolution of the desktop. For instance if I set the window size to be 1600x1200 and use the 800x600 desktop resolution, the window which is displayed has a size of about 800x600. Maybe this ca be changed in window creation settings or style?
Quote:Original post by vladic2000x
Isn't this function supposed to return the (0,0,1024,768) clientRect for any monitor resolution?

Not always, I'm afraid. It depends on how you use it, have you tried creating a full-screen window without borders?

I'm not sure if you want to create a full-screen window with/without borders, or if you want to get the screen resolution, or if you're just curious [smile]

Some alternatives:

A. If you create a full-screen window without borders, then GetClientRect should equal the window bounding box. For that I use WS_POPUP (only).

B. If you want the bounding box anyway, you can call GetWindowRect instead.
Oh, sorry I forgot to mention, that the application is in windowed mode. For fulscreen mode, there are no problems.

Also I have found some threads on gamedev saying that it is impossible to create a window in size greater than the desktop resolution, however I have played a game, that when switched from fullscreen to windowed had a window much bigger in size than the desktop resolution.

This topic is closed to new replies.

Advertisement