简体   繁体   English

C / C ++ / C#在监视器上设置窗口位置

[英]C/C++/C# Set Window Position on a monitor

I want to move a Window (HWND) in a second monitor. 我想在第二个监视器中移动一个窗口(HWND)。 The thing is that I tried many things like double the resolution or putting negative values and it never was able to put the window on my second monitor. 事实是,我尝试了很多事情,例如将分辨率提高一倍或设置负值,却始终无法将窗口放在第二个监视器上。

Any clue of how to do that in C/C++/c# 关于如何在C / C ++ / c#中执行此操作的任何线索

Screen and the Form.StartPosition should get you there. 屏幕和Form.StartPosition应该会带您到那里。

See the first answer to this post (for C#/WinForms solution): How do I ensure a form displays on the "additional" monitor in a dual monitor scenario? 请参阅此帖子的第一个答案(针对C#/ WinForms解决方案): 在双监视器方案中,如何确保表单显示在“附加”监视器上?

The desktop layout is user-configurable, a second monitor can be to the left, to the right, above, below, or positioned weirdly compared to the primary. 桌面布局是用户可配置的,第二台显示器可以位于左,右,上,下或与主显示器相比怪异的位置。

The GetMonitorInfo function will help you find out where the second monitor is, in virtual screen coordinates. GetMonitorInfo函数将帮助您找到第二个监视器在虚拟屏幕坐标中的位置。 As @holtavolt mentioned , the .NET Screen class is a convenient wrapper. 正如@holtavolt所提到的 ,.NET Screen类是一个方便的包装器。

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

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