VB怎么让Form2始终在Form1前面?
点击Form1出现Form2,再点击Form1可以对Form1进行操作,但Form2始终在最前面。请问用VB怎么实现上述效果?...
点击Form1出现Form2,再点击Form1可以对Form1进行操作,但Form2始终在最前面。请问用VB怎么实现上述效果?
展开
2个回答
展开全部
Form1中的代码(添加个按钮)
Private Sub Command1_Click()
Form2.Show
End Sub
***************************************************************
Form2中的代码
Private Declare Function SetWindowPos& Lib "user32" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, _
ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private Sub Form_Load()
Me.Show
Call SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)
'……其它代码
End Sub
Private Sub Command1_Click()
Form2.Show
End Sub
***************************************************************
Form2中的代码
Private Declare Function SetWindowPos& Lib "user32" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, _
ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private Sub Form_Load()
Me.Show
Call SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)
'……其它代码
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询