Я делаю VOS, где рабочий стол является родительской формой MDI. Но, как только я показываю все дочерние окна, они появляются, загружают все свои ресурсы, а затем снова скрываются. И они не показывают резервную копию.Детские формы ребенка никогда не появляются
Код, который показывает приложение:
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
Я полный нуб, и я действительно застрял на этом ...
Любая помощь оценили значительно, Хамза Али
Неясно, что вы делаете: 'frm.MdiParent = Me' не может скомпилировать, если эта линия находится в модуле, так как мне не будет относиться к форме. Я не стал бы показывать форму перед установкой свойства MdiParent. – LarsTech
oops, я хотел поставить Рабочий стол там ... Я сейчас его изменю. –
Ну, это так ясно, как грязь. Что такое «GalaxyOS.Core.GUI.Desktop»? Это не похоже на ссылку на экземпляр родительской формы MDI. – LarsTech