请问如何让 Form 显示在指定的 Screen 上面? 我现在的开发电脑有两个显示器,两个显示器的分辨率是一样的,一个主显示器,一个附加显示器。Q:请问,我想让我程序 Run 起来之后,Form 显示在指定的显示器屏幕上,而这个屏幕也是 Visual Studio 所在屏幕,请问有什么好的方法?谢谢。显示器分配率指定屏幕 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 设置Form的Location,比如:public Form1(){ this.StartPosition = FormStartPosition.Manual; this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width + 100, 0);} this.Left = ((Screen.AllScreens[1].Bounds.Width - this.Width) / 2);this.Top = ((Screen.AllScreens[1].Bounds.Height - this.Height) / 2);获取显示屏数量,计算location。 我的意思是:我需要显示在和 Visual Studio 同一个 Screen 当中!这里的代码是指定放到哪个显示器去,但是问题是我怎么确定这个显示器就是我 Visual Studio 所在的显示器? 随意指定哪个 Screen 我知道怎么做,即便遍历 Screens 都行,但是哪个显示器是我应该要的(Visual Studio 所在的)我无法确定。 你可以问“请问如何确定Visual Studio所在的显示器?”private void button1_Clicked(object sender, EventArgs e){ var visualStudio = Process.GetProcessesByName("devenv").FirstOrDefault(); Rectangle rect = new Rectangle(); if (visualStudio != null && GetWindowRect(visualStudio.MainWindowHandle, ref rect)) { MessageBox.Show("visual studio @" + rect); }}[DllImport("User32")]static extern bool GetWindowRect(IntPtr hWnd, ref Rectangle rect);当然可能有多个Visual Studio在运行,也可能一个VS跨越好几个显示器。 C#处理特殊字符 c#如何使用钩子禁用系统win键,和任务管理器、alt+f4热键? 非泛型集合ArrayList和泛型集合List,运行时间问题 在vs2005下,如何将已经做好的ocx打包成cab,在网页中实现自动下载安装? 二次开发中控M880局域网采集图片 WinForm小问题 字符串在一定范围内格式化 我用smtpmail类写了一个发邮件的程序,可是怎么收不到邮件阿? 水晶报表问题,高手请进来帮忙看看,谢谢先 webBrowser里面怎么调用没有ID,Name的按钮点击事件 winfrom嵌入ppt 急!大约每50ms发一次串口数据得到的串口数据丢很多
public Form1()
{
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width + 100, 0);
}
this.Top = ((Screen.AllScreens[1].Bounds.Height - this.Height) / 2);获取显示屏数量,计算location。
我的意思是:我需要显示在和 Visual Studio 同一个 Screen 当中!
这里的代码是指定放到哪个显示器去,但是问题是我怎么确定这个显示器就是我 Visual Studio 所在的显示器?
随意指定哪个 Screen 我知道怎么做,即便遍历 Screens 都行,但是哪个显示器是我应该要的(Visual Studio 所在的)我无法确定。
{
var visualStudio = Process.GetProcessesByName("devenv").FirstOrDefault();
Rectangle rect = new Rectangle();
if (visualStudio != null && GetWindowRect(visualStudio.MainWindowHandle, ref rect))
{
MessageBox.Show("visual studio @" + rect);
}
}
[DllImport("User32")]
static extern bool GetWindowRect(IntPtr hWnd, ref Rectangle rect);当然可能有多个Visual Studio在运行,也可能一个VS跨越好几个显示器。