WindowsApplication with MDI [英] WindowsApplication with MDI
问题描述
大家好,
我正在使用MDI应用程序和创建菜单。我遇到了下面解释的问题。
1)我们有一个子窗口(比如发送表单),其属性WindowState为Maximized。
2)另一个子窗口(比如添加表格),其属性WindowState为Normal。
现在问题当我第一次打开发送表格时,它显示为最大化状态,但接下来当我打开添加表单时,添加表单和发送表单都处于最大化状态。
类似,
当我第一次打开添加表格然后我打开发送表格然后我得到焦点( 使用objAddForm.Activate())返回添加表单现在两个子表单都处于NORMAL状态。
这是父表格代码:
公开 类 Form1
私人 Sub ExitToolStripMenuIt em_Click(发件人作为 对象,e 作为 EventArgs)句柄 ExitToolStripMenuItem.Click
Me .Close()
结束 Sub
Dim frmFile 作为添加
私有 Sub AddToolStripMenuItem_Click(发件人作为 对象,e As EventArgs)句柄 AddToolStripMenuItem.Click
如果 frmFile 没什么 然后
frmFile = 新添加()
frmFile.MdiParent = 我
frmFile.Show()
< span class =code-keyword> Else
frmFile.MdiParent = 我
frmFile.Activate()
结束 如果
结束 Sub
Dim frmSend As 发送
私有 Sub SendToolStripMenuItem_Click(发件人< span class =code-keyword>作为 对象,e As EventArgs)句柄 SendToolStripMenuItem.Click
如果 frmSend Nothing 然后
frmSend = 新发送()
frmSend.MdiParent = 我
frmSend.Show()
其他
frmSend.MdiParent = 我
frmSend.Activate()
结束 如果
结束 Sub
Dim frmSettings As 设置
私有 Sub SettingsToolStripMenuItem_Click(发件人作为 Object ,e As EventArgs) Handles SettingsToolStripMenuItem.Click
frmSettings = 新设置()
frmSettings.MdiParent = 我
frmSettings.Show()
结束 Sub
< span class =code-keyword>结束 类
这是添加表格代码
公开 类添加
结束 班级
这是发送表格代码
公开 类发送
< span class =code-keyword>结束 类
我刚出演该应用程序只是为了知道MDI是如何实现的,所以你找不到很多代码。
请帮助我。
请为我推荐一个解决方案。
对不起,如果有人觉得我的英语不好。
在此先感谢,
Rohith。
有几个原因不使用MDI。请阅读谢尔盖的答案:
如何将mdi孩子带到其他形式的控件前面? [ ^ ]
在MDI儿童表格中在面板中最小化:c# [ ^ ]
mdi child隐藏在父母的控件之后 [ ^ ]
如何从MDIparent表单中的另一个MDIchild表单打开MDIchid表单 [ ^ ]
< blockquote>您描述的是预期的行为。如果一个子窗口最大化,则它们将变为最大化。如果一个正常,它们都会变得正常。
MDI代表多个DOCUMENT界面,而不是多个窗口。你正在使用MDI来达到它不适合的目的。
它被设计用作文本编辑器,你有多个打开窗户,所有人都做同样的事情,编辑文件。你的应用程序没有这样做,是吗?
hi all,
I''m working with MDI Application and Creating Menus in it. I have come across an issue explained below.
1) we have a child window (say Send Form) having property WindowState as Maximized.
2) another child window (say Add Form) having property WindowState as Normal.
Now the issue is when I first open Send Form it appears maximized state but next when I open Add form both Add Form and Send Form are in MAXIMIZED state.
similarly,
when I First open Add Form then I open Send Form and then I get Focus (by using objAddForm.Activate()) back to Add Form now both Child Forms are in NORMAL state.
This is Parent form code:
Public Class Form1
Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
Dim frmFile As Add
Private Sub AddToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AddToolStripMenuItem.Click
If frmFile Is Nothing Then
frmFile = New Add()
frmFile.MdiParent = Me
frmFile.Show()
Else
frmFile.MdiParent = Me
frmFile.Activate()
End If
End Sub
Dim frmSend As Send
Private Sub SendToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SendToolStripMenuItem.Click
If frmSend Is Nothing Then
frmSend = New Send()
frmSend.MdiParent = Me
frmSend.Show()
Else
frmSend.MdiParent = Me
frmSend.Activate()
End If
End Sub
Dim frmSettings As Settings
Private Sub SettingsToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SettingsToolStripMenuItem.Click
frmSettings = New Settings()
frmSettings.MdiParent = Me
frmSettings.Show()
End Sub
End Class
This is Add Form Code
Public Class Add
End Class
This is Send Form Code
Public Class Send
End Class
I have just started the application just to know how MDI is implemented so you can''t find much code in it.
Pls help me.
Please suggest me a solution for it.
Sorry, if any one feels my English is bad.
Thanks in Advance,
Rohith.
There are several reasons to not use MDI. Please, read Sergey''s answers:
how to bring mdi child to front of other form''s controls?[^]
In MDI Child form minimize with in panel : c#[^]
mdi child is hiding behind parent''s controls[^]
How to open a MDIchid form from another MDIchild form within a MDIparent form[^]
What you describe is the expected behavior. If one child window is maximized, they ALL become maximized. If one is normal, they all become normal.
MDI stands for Multiple DOCUMENT interface, not Multiple Window. You''re using MDI for a purpose it was not designed for.
It''s designed to be used as something of a text editor, where you have multiple windows open, all doing the exact same thing, editing documents. Your app isn''t doing that, is it??
这篇关于WindowsApplication with MDI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!