Sign in to follow this  

GetClientRect() strange behavior

This topic is 3111 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 3111 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this