兄弟,下面的代码对你会有帮助. 在mdi窗体上放一个图片框,图片框上放三个命令按钮. 假设每个按钮打开相应的子窗体,若想每次只打开一个,则代码为(代码放在主窗体中):Private Sub Command1_Click()If Not Me.ActiveForm Is Nothing Then Unload Me.ActiveForm End If
Form1.ShowEnd SubPrivate Sub Command2_Click() If Not Me.ActiveForm Is Nothing Then Unload Me.ActiveForm End If
Form2.ShowEnd SubPrivate Sub Command3_Click() If Not Me.ActiveForm Is Nothing Then Unload Me.ActiveForm End If
Form3.ShowEnd Sub
在公用模块中设一变量boolean来记录窗口的显示情况 在每一个子窗口加载的时候,标记一下。 例: public gFormShow as booleanprivate sub Form_load() gformshow=false end subprivate sub form_unload() gformshow =true end sub 当在MDI窗口当点击显示子窗口的菜单时加上判断,例: if gformshow=false then msgbox"已有子窗口" else form2.show end if
在mdi窗体上放一个图片框,图片框上放三个命令按钮.
假设每个按钮打开相应的子窗体,若想每次只打开一个,则代码为(代码放在主窗体中):Private Sub Command1_Click()If Not Me.ActiveForm Is Nothing Then
Unload Me.ActiveForm
End If
Form1.ShowEnd SubPrivate Sub Command2_Click()
If Not Me.ActiveForm Is Nothing Then
Unload Me.ActiveForm
End If
Form2.ShowEnd SubPrivate Sub Command3_Click()
If Not Me.ActiveForm Is Nothing Then
Unload Me.ActiveForm
End If
Form3.ShowEnd Sub
在每一个子窗口加载的时候,标记一下。
例:
public gFormShow as booleanprivate sub Form_load()
gformshow=false
end subprivate sub form_unload()
gformshow =true
end sub
当在MDI窗口当点击显示子窗口的菜单时加上判断,例:
if gformshow=false then
msgbox"已有子窗口"
else
form2.show
end if