请帮助我..我有一个项目使用mdi应用程序。我的问题是,如何检查已经运行的mdi孩子..?请帮帮我..
答案 0 :(得分:2)
我使用以下技术,但每个Form类型需要一个特定的Sub(我使用的是VB.NET)。但是我确信可以有一种简化方法来处理所有子表单的方法
Dim blExists As Boolean = False
For Each f As Form In Me.MdiChildren
If TypeOf (f) Is FormName Then
f.Focus()
blExists = True
Exit For
End If
Next
If Not blExists Then
fAnalysis = New FormName
fAnalysis.MdiParent = Me
fAnalysis.Show()
End If
以下子项适用于所有表单。
Private Sub ShowNewForm(ByVal frmName As Form)
Dim blExists As Boolean = False
Dim f as Form
For Each f In Me.MdiChildren
If f.Name Is frmName.Name Then
f.Focus()
blExists = True
Exit For
End If
Next
If Not blExists Then
f = DirectCast(New Form, frmName.Type)
fAnalysis.MdiParent = Me
f.Show()
End If
End Sub
答案 1 :(得分:0)
创建MDI窗口时,您使用了WM_MDICREATE吗?那个消息返回一个窗口句柄,你应该把那个句柄保存到某个地方,以便你可以在以后找到窗口时查询它,或者检查它是否存在。
MDICREATESTRUCT mci;
// fill out mci...
HWND hwndChild = (HWND) SendMessage(hwndMDI, WM_MDICREATE, 0, (LPARAM)(ULONG_PTR)&mci);
// save hwndChild so that I can use it later.