Reputation: 87
So I'm trying to launch a fullscreen window in a secondary display. I have the computer set to extend displays. I've tried every solution on Stack Overflow that I've found and all of them launch the window in the laptop screen but it has the width and height of the monitor so it partially extends into the monitor. So the problem (I think) is that it is not getting the (x,y) coordinate of the upper left corner of the second monitor correctly. Here is the code:
DEVMODE laptop;
EnumDisplaySettings(NULL, 0, &laptop);
int endOfLaptopW=laptop.dmPelsWidth;
const POINT pt={endOfLaptopW+1, 360};//create point on second monitor
HMONITOR hmon=MonitorFromPoint(pt, NULL);
MONITORINFO mi = { sizeof(mi) };
if (!GetMonitorInfo(hmon, &mi)) return NULL;
CreateWindow(TEXT("static"), TEXT("FULLSCREEN"), WS_POPUP|WS_VISIBLE, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right - mi.rcMonitor.left, mi.rcMonitor.bottom - mi.rcMonitor.top, bkgrdPrintWin, NULL, g_hinst, 0);
Upvotes: 3
Views: 3613
Reputation: 37122
EnumDisplaySettings
is not the function you want here. That enumerates graphics modes, and graphics mode 0 is probably 320x200 or something else small. It almost certainly won't be the current resolution of your display.
Try using the EnumDisplayMonitors
function instead.
Upvotes: 2