How to get the monitor screen resolution from a hWnd?
I am using a hWnd because the window could be located on any one of multiple monitors.
i.e. the hWnd top/left coordinate is on a Monitor that has a Screen Resolution of 800 x 600.
I program in a language called PL/B and it allows calling Windows API.
What Window APIs can be used?
h> Display* disp = XOpenDisplay(NULL); Screen* scrn = DefaultScreenOfDisplay(disp); int height = scrn->height; int width = scrn->width; with the linker option -lX11 .
Adjust size and color To scale up everything on your screen, select the Start button, then select Settings > System > Display, and change the Scale drop-down menu under Scale & Layout to a larger percentage.
Here's a C++ code example that works for me:
HMONITOR monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); MONITORINFO info; info.cbSize = sizeof(MONITORINFO); GetMonitorInfo(monitor, &info); int monitor_width = info.rcMonitor.right - info.rcMonitor.left; int monitor_height = info.rcMonitor.bottom - info.rcMonitor.top;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With