简体   繁体   English

在VB.NET中单击最小化按钮时的最小化表单

[英]Minimize form when minimize button is clicked in VB.NET

I have a form which is maximized with this property: 我有一个最大化此属性的表单:

Me.WindowState = FormWindowState.Maximized

and with FormBorderStyle = None . 并使用FormBorderStyle = None This means that when this form is opened, it can not be minimized, which is the behavior I want. 这意味着打开此表单时,无法将其最小化,这是我想要的行为。

From this main form, there is a button which open another small form called 'Console' where I can see some messages thrown by the main form. 在此主表单中,有一个按钮可以打开另一个称为“控制台”的小表单,在其中我可以看到主表单引发的一些消息。 This 'Console' form is with FormBorderStyle = FixedSingle , and this means that can be minimized. 此“控制台”形式具有FormBorderStyle = FixedSingle ,这意味着可以将其最小化。

The problem with this, is that when I minimize the 'Console' form, I can not opened again because the main form occupy the whole screen. 问题在于,当我最小化“控制台”表单时,由于主表单占据了整个屏幕,因此无法再次打开。

What I am trying to do is to minimize the 'Console' and be able to see it to maximize it again when I wish. 我想做的是将“控制台”最小化,并在需要时能够再次看到它最大化。

I tried to use events of the 'Console' form like SizeChanged or KeyUp and control when the minimize button is pressed. 我试图使用“控制台”形式的事件,如SizeChangedKeyUp并在按下最小化按钮时进行控制。

All things I tried have gone wrong, and always when I press the minimize button, the form minimizes normally. 我尝试的所有方法都出了问题,并且总是在我按下最小化按钮时,表格通常会最小化。

It is possible when I minimize the form by clicking on the minimize button, to see the minimize window down to maximize it when I want? 我可以通过单击最小化按钮来最小化表单,以查看最小化窗口向下以在需要时最大化它吗?

I accept any suggestions! 我接受任何建议!

Finaly I've used this option: when I click to minimize, I just relocate the form and resize it. 最后,我使用了此选项:单击以最小化时,我只是重新定位表单并调整其大小。 Maybe is a simple and manual option and for sure it will be better ways to do it, but this gives me what I need for now. 也许这是一个简单且手动的选项,并且可以肯定这将是更好的方法,但这为我提供了我现在需要的东西。

@HansPassant thanks for your help! @HansPassant感谢您的帮助! I am going to look for information about docking layout manager as you suggested. 我将按照您的建议查找有关对接布局管理器的信息。

Here is the code: 这是代码:

Private Sub frmConsole_Move(sender As Object, e As EventArgs) Handles MyBase.Move
    If Me.WindowState = FormWindowState.Minimized Then
        Me.Size = New System.Drawing.Size(247, 0)
        Me.WindowState = FormWindowState.Normal
        Me.Location = New Point(padre.GMapControl.Location.X, padre.GMapControl.Location.Y + 1000)
        Me.TopMost = True
    ElseIf Me.WindowState = FormWindowState.Maximized Then
        Me.Size = New System.Drawing.Size(447, 900)
        Me.WindowState = FormWindowState.Normal
        Me.Location = New Point(padre.Location.X + padre.GMapControl.Width * 0.9, padre.Location.Y)
    End If
End Sub

I've used some buttons location of the main form to locate the 'Console' form, but it can be any value. 我已经使用主窗体的一些按钮位置来定位“控制台”窗体,但是它可以是任何值。

Thanks! 谢谢!

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

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