Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 155 Vote(s) - 3.68 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to detect the current screen resolution?

#1
How do I from Winapi (in C or C++) detect the current screen resolution?

Some background:

I want to start a new OpenGL fullscreen window, but want it open with the same horizontal and vertical size which the desktop already is set to. (Now when everyone uses LCD screens, I figured this is the best way to get the native resolution of the screen.)

I don't desperately need to also know the desktop color depth, although that would be a nice bonus.
Reply

#2
I think [SystemParametersInfo](

[To see links please register here]

) might be useful.

Edit: Look at [GetMonitorInfo](

[To see links please register here]

) too.
Reply

#3
It's [GetSystemMetrics][1] with these parameters:<br>
SM_CXSCREEN < width<br>
SM_CYSCREEN < height

As it says (SM_CXSCREEN):

> The width of the screen of the primary
> display monitor, in pixels. This is
> the same value obtained by calling
> GetDeviceCaps as follows:
> GetDeviceCaps( hdcPrimaryMonitor,
> HORZRES).


[1]:

[To see links please register here]

Reply

#4
- Size of the primary monitor: [GetSystemMetrics][1] SM_CXSCREEN / SM_CYSCREEN (GetDeviceCaps can also be used)
- Size of all monitors (combined): GetSystemMetrics SM_CX/YVIRTUALSCREEN
- Size of work area (screen excluding taskbar and other docked bars) on primary monitor: [SystemParametersInfo][2] SPI_GETWORKAREA
- Size of a specific monitor (work area and "screen"): [GetMonitorInfo][3]

Edit:
It is important to remember that a monitor does not always "begin" at 0x0 so just knowing the size is not enough to position your window. You can use MonitorFromWindow to find the monitor your window is on and then call GetMonitorInfo

If you want to go the low-level route or change the resolution you need to use EnumDisplayDevices, EnumDisplaySettings and ChangeDisplaySettings (This is the only way to get the refresh rate AFAIK, but GetDeviceCaps will tell you the color depth)



[1]:

[To see links please register here]

[2]:

[To see links please register here]

[3]:

[To see links please register here]

Reply

#5
Deleted about a week ago, then edited 3-4-13.

Here's a good one for situations where the user has decided to
run their desktop in a lower resolution (bad idea) or corner
cases where a person decided to get a monitor that their
graphics controller couldn't take full advantage of:

// get actual size of desktop
RECT actualDesktop;
GetWindowRect(GetDesktopWindow(), &actualDesktop);


Reply

#6
MFC Example Multiple monitor support with GetSystemMetrics EnumDisplayMonitors and GetMonitorInfo

Follow this link: [Monitor enumeration with source code][1]


[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through