Sign in to follow this  
Turold

Win XP correct destop area size

Recommended Posts

I need to know what is the maximum size of a not maximized window in a current desktop setup (res and task bar size). Max size which allows restoring window, without maximizing it. I have caption and border size. I need to account for taskbar, also if it's wider that usual. How can I get this info? Win32, WinXP. [Edited by - Turold on August 16, 2008 1:11:16 PM]

Share this post


Link to post
Share on other sites
SystemParametersInfo:

RECT rcWork;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWork, 0);
// rcWork now contains the rect representing the working area (Fullscreen window area)




EDIT: I'm not entirely sure if you want to also use AdjustWindowRectEx too, which will let you determine the size of a window frame.

Share this post


Link to post
Share on other sites
Decisions, decisions...


1. For a specific monitor in a multi-monitor system:
a) MonitorFromRect() to get the handle of a monitor you're interested in.
b) EnumDisplayMonitors() to get handles for all monitors.
c) GetMonitorInfo() to get ino about that monitor.
d) The rcWork member of the MONITORINFO takes the taskbar into account.

Bear in mind that:
- Each monitor might be at different resolution to the others.
- If you're using the GPU there can be a significant performance penalty if your window straddles two monitors (Windows needs to copy pixels using the CPU in this case).
- Monitors don't necessarily need to be in order, monitor 1 might be to the right of monitor 2.


2. GetSystemMetrics() with SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN, SM_XVIRTUALSCREEN, SM_YVIRTUALSCREEN.


3. SystemParametersInfo() with SPI_GETWORKAREA.


4. GetSystemMetrics() with SM_CXMAXIMIZED, SM_CYMAXIMIZED.

Share this post


Link to post
Share on other sites
Now you are stretching it! :) It's funny, how seemingly simple things in theory, can get complicated in practice. My framework is for a casual game, so I'm 99.999% positive that my players will not have two monitors.

I will add your Ultimate Solution to my "To Do" list. Thx!

Share this post


Link to post
Share on other sites
Quote:
Original post by Turold
Now you are stretching it! :) It's funny, how seemingly simple things in theory, can get complicated in practice. My framework is for a casual game, so I'm 99.999% positive that my players will not have two monitors.

I will add your Ultimate Solution to my "To Do" list. Thx!
I'm curious why you need to know the desktop area if your window isn't maximized? If you just use a maximized window, Windows will handle all this for you. Also, I wouldn't assume that not a lot of people have multiple monitors. It's likely that people won't, but you may be surprised how many people actually have multiple monitors.

Share this post


Link to post
Share on other sites

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