简体   繁体   English

Win32 C ++在第二个监视器中创建窗口

[英]Win32 C++ creating window in second monitor

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. 我已经尝试了我发现的Stack Overflow上的所有解决方案,并且所有这些解决方案都在笔记本电脑屏幕中启动了窗口,但它具有显示器的宽度和高度,因此它部分延伸到显示器中。 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. 所以问题(我认为)是它没有正确获得第二个监视器左上角的(x,y)坐标。 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);    

EnumDisplaySettings is not the function you want here. EnumDisplaySettings不是您想要的功能。 That enumerates graphics modes, and graphics mode 0 is probably 320x200 or something else small. 这列举了图形模式,图形模式0可能是320x200或其他小的。 It almost certainly won't be the current resolution of your display. 它几乎肯定不会是您显示器的当前分辨率。

Try using the EnumDisplayMonitors function instead. 请尝试使用EnumDisplayMonitors函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM