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.
GetSystemMetricsSM_CXSCREEN/SM_CYSCREEN(GetDeviceCapscan also be used)GetSystemMetricsSM_CX/YVIRTUALSCREENSystemParametersInfoSPI_GETWORKAREAGetMonitorInfoEdit:
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
MonitorFromWindowto find the monitor your window is on and then callGetMonitorInfoIf you want to go the low-level route or change the resolution you need to use
EnumDisplayDevices,EnumDisplaySettingsandChangeDisplaySettings(This is the only way to get the refresh rate AFAIK, butGetDeviceCapswill tell you the color depth)