Form2.Show vbNormalFocus
这句话就可以了。form2前端显示,且 form2为焦点。不关闭form2则不能点击form1。
如果只是想让form2 前端显示,但可以点击form1。就用:
form2.show vbnormal
sub button_click
form2.show vbmodal
end sub
'窗体1代码:
Private Sub Command1_Click()
Form2.Show
End Sub
'窗体2代码:
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Form_Load()
SetForegroundWindow Me.hwnd
End Sub