2 screen questions

When I set up a fullscreen window, how do I know whats the aspect ration of the monitor, and what are the resolutions that it supports?

2nd:
In windowed mode I need to know what is the size of the window headline in pixels …I have problems when counting the cursor distance from the centre of the screen.
Thanks!
(Im using Win XP btw)

For Windows you need to use some Windows API calls for these. Look up EnumDisplaySettings for supported resolutions; for the current screen size you have a choice: SystemParametersInfo (SPI_GETWORKAREA, … is useful for windowed modes as it excludes the taskbar from it’s returned value, so you get the actual client area of the screen; for fullscreen (or if you need the full screen resolution including the taskbar) GetDC (NULL), then some GetDeviceCaps calls is one option (not forgetting a ReleaseDC when done).

By “window headline” I assume that you mean the title bar. It’s generally a bad idea to hard-code this value as it can change between different versions of Windows or based on user preferences (and overriding user preferences is an even worse idea), so you use GetWindowRect to get the full rectangle coords for the window including title bar and borders, then GetClientRect for the coords excluding them, and from there it’s just some simple subtraction to get the sizes. You probably also want to respond to WM_SIZE messages and recalculate these if needed, and likely also WM_MOVE if you’re using ClipCursor to constrain the mouse within a specified rectangle.

Look up all of these on your local friendly MSDN: Microsoft Learn: Build skills that open doors in your career

[QUOTE=mhagain;1238732]For Windows you need to use some Windows API calls for these. Look up EnumDisplaySettings for supported resolutions; for the current screen size you have a choice: SystemParametersInfo (SPI_GETWORKAREA, … is useful for windowed modes as it excludes the taskbar from it’s returned value, so you get the actual client area of the screen; for fullscreen (or if you need the full screen resolution including the taskbar) GetDC (NULL), then some GetDeviceCaps calls is one option (not forgetting a ReleaseDC when done).

By “window headline” I assume that you mean the title bar. It’s generally a bad idea to hard-code this value as it can change between different versions of Windows or based on user preferences (and overriding user preferences is an even worse idea), so you use GetWindowRect to get the full rectangle coords for the window including title bar and borders, then GetClientRect for the coords excluding them, and from there it’s just some simple subtraction to get the sizes. You probably also want to respond to WM_SIZE messages and recalculate these if needed, and likely also WM_MOVE if you’re using ClipCursor to constrain the mouse within a specified rectangle.

Look up all of these on your local friendly MSDN: Microsoft Learn: Build skills that open doors in your career

Thanks! EnumDisplaySettings works perfectly.

but getClientRect doesnt.
Im trying
LPRECT c_rect;
GetClientRect( hWnd, c_rect);
and it crashes. hWnd is “set up” already.

[QUOTE=Aliii;1238738]but getClientRect doesnt.
Im trying
LPRECT c_rect;
GetClientRect( hWnd, c_rect);
and it crashes. hWnd is “set up” already.[/QUOTE]
Obviously, because you pass an invalid pointer to it. The LPRECT type is a pointer type that points to a RECT structure. You have to allocate the structure and pass a pointer to it to GetClientRect.
Here’s what you have to do:

RECT c_rect;
GetClientRect( hWnd, &c_rect );

Thanks! works