最小化/最大化两个屏幕
我有一个在两个显示器上运行的应用程序(例如主屏幕和辅助屏幕)。辅助屏幕没有设置控制框属性。这完全取决于主屏幕的功能。我无法弄清楚的是,如果我将主屏幕最小化到系统任务栏,我也需要最小化辅助屏幕。此外,一旦我最大化主要部分,次要部分也应该最大化。
更新 我厌倦了做这样的事情,但搞砸了。应用程序一启动它就会创建 2 个表单,这是我不想要的。
private void MainForm_Resize(object sender, EventArgs e)
{
SecondaryLayoutForm secondaryLayoutForm = new SecondaryLayoutForm();
if (this.WindowState == FormWindowState.Minimized)
{
secondaryLayoutForm.Hide();
}
else
{
secondaryLayoutForm.Show();
}
}
谢谢
I have an application which runs on 2 monitors (say Primary screen and Secondary screen). The secondary screen does not have the control box property set to it. It depends completely on the functionality of the primary screen. What I am not able to figure out is, if I minimize the primary screen to the system taskbar, I need to minimize the secondary screen too. Also as soon as I maximize the primary, the secondary should also be maximized.
UPDATE
I tired to do something like this, but messed it up. It creates 2 forms as soon as the application starts which I do not want.
private void MainForm_Resize(object sender, EventArgs e)
{
SecondaryLayoutForm secondaryLayoutForm = new SecondaryLayoutForm();
if (this.WindowState == FormWindowState.Minimized)
{
secondaryLayoutForm.Hide();
}
else
{
secondaryLayoutForm.Show();
}
}
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的 MainForm 类上尝试一下:
这使得 MainForm 负责创建您的 secondaryLayoutForm 并控制其窗口状态 - 如果您不希望这样做,请考虑创建一个 UIManager 类或其他东西来将其分开。
更新
我用 2 个表单编写的示例应用程序。这就是 Form1 中的内容,Form2 上只有一个文本框,因此它与 Form1 明显不同。
更新:如何从不同的类执行此操作的示例
但是,无论您是从其中一个表单还是单独的类执行此操作,都需要引用这两种表单,以便它可以同步窗口状态。
Try this, on your MainForm class:
This makes the MainForm responsible for creating your SecondaryLayoutForm and controlling its window state - if you don't want that, then consider creating a UIManager class or something to separate this out.
Update
A sample app I wrote with 2 forms. This is what's in Form1, Form2 just has a text box on it so it's visibly different to Form1.
Update: Example of how to do this from a different class
However, whether you do this from one of the forms or a separate class, something will need a reference to both forms so it can synchronize the window states.