我正在创建一个桌面是MDI父表单的VOS。但是,只要我显示任何子窗口,它们就会出现,加载所有资源然后再次隐藏。而且他们不会显示出来。
显示应用的代码:
Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click, Label1.Click, TestToolStripMenuItem.Click
showapp(Maininternet)
End Sub
''' <summary>
''' Add's an app to the Galaxy OS MDI child tree and shows it.
''' </summary>
''' <param name="app">Name of the app.</param>
''' <remarks></remarks>
Sub showapp(app As Form)
AddNewForm(app)
app.Show()
End Sub
在其中一个模块中:
''' <summary>
''' Adds a form to the MDI application
''' And links it with a TaskBarItem
''' </summary>
''' <param name="frm">The form to use</param>
''' <remarks></remarks>
Private Sub AddNewForm(ByVal frm As Form)
frm.MdiParent = GalaxyOS.Core.GUI.Desktop
Dim img As Image = CType(New ImageConverter().ConvertFrom(frm.Icon), Image)
Dim tbItem As New TaskBarItem(frm.Text, img, frm)
tbItem.ImageScaling = ToolStripItemImageScaling.SizeToFit
TaskBar.Items.Add(tbItem)
frm.Show()
End Sub
由于它是一个操作系统,有一个menustrip就像一个任务栏,而TaskBarItem是一个MenuStrip项,显示一个应用程序的图标,它的名称,以及关闭和恢复它的选项。代码:
Namespace Core.GUI.Desktop.Taskbar
''' <summary>
''' The TaskBarItem class is a item on the TaskBar that can close/restore a application
''' It represents the form's icon and text on the visual side
''' </summary>
''' <remarks></remarks>
Public Class TaskBarItem
Inherits ToolStripMenuItem
Private WithEvents CloseItem As New ToolStripMenuItem("Close")
Private WithEvents RestoreItem As New ToolStripMenuItem("Restore")
Friend WithEvents Control1 As System.Windows.Forms.Control
Private _form As Form
''' <summary>
''' Creates a new instance of the TaskBarItem class
''' </summary>
''' <param name="text">The text used on the item</param>
''' <param name="img">The image used on the item</param>
''' <param name="frm">The form that is linked to it</param>
''' <remarks></remarks>
Public Sub New(ByVal text As String, ByVal img As Image, ByVal frm As Form)
MyBase.New(text, img)
CloseItem.BackColor = color.black
CloseItem.ForeColor = color.deepskyblue
RestoreItem.BackColor = color.black
RestoreItem.ForeColor = color.deepskyblue
BackColor = color.black
ForeColor = color.deepskyblue
_form = frm
AddHandler CloseItem.Click, AddressOf Close_Click
AddHandler RestoreItem.Click, AddressOf Restore_Click
AddHandler frm.FormClosing, AddressOf Form_Closed
Me.DropDownItems.Add(CloseItem)
Me.DropDownItems.Add(RestoreItem)
frm.Show()
End Sub
'' A event to remove the item when the form has been closed by the close button
'' or a internal Form.Close call
Private Sub Close_Click(ByVal sender As Object, ByVal e As EventArgs)
Me.Parent.Items.Remove(Me)
If (Not IsNothing(_form)) Then
_form.Close()
End If
End Sub
'' A event to restore the form's previous state
Private Sub Restore_Click(ByVal sender As Object, ByVal e As EventArgs)
If (_form.WindowState = FormWindowState.Minimized) Then
_form.WindowState = FormWindowState.Normal
_form.Visible = True
End If
End Sub
'' A event to close the form using the TaskBarItem
Private Sub Form_Closed(sender As Object, e As FormClosingEventArgs)
For Each tsmi As ToolStripMenuItem In GalaxyOs.Core.GUI.Desktop.Desktop.TaskBar.Items
If (tsmi.Text = _form.Text) Then
Me.Parent.Items.Remove(tsmi)
Exit For
End If
Next
End Sub
End Class
End Namespace
我是一个完整的菜鸟,我真的被困在这......
任何帮助都非常感激, 哈姆扎阿里
答案 0 :(得分:0)
我想出了问题!问题是,我在MDI父表单上有一个flowlayoutpanel,它位于前台,让MDI子项显示在后台。有没有什么方法可以使FlowLayoutPanel不受MDI孩子的影响?
谢谢, 哈姆扎阿里