'Form2.MinButton 设为fasle '下面是Form1上的代码 Private Sub Form_Load() Timer1.Interval = 50 Form2.Show Form2.MinButton = fasle End SubPrivate Sub Timer1_Timer() Form2.ZOrder End Sub
Form2.MinButton = fasle注释掉
'在FORM1上建一个COMMAND1 Private Sub Command1_Click() Form2.Show End SubPrivate Declare Function PtInRect Lib "user32" (lpRect As RECT, ByVal ptx As Long, ByVal pty As Long) As Long 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) As Long Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal X As Long, _ ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As LongConst HWND_TOPMOST = -1
Private Type POINTAPI X As Long Y As Long End Type Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Is_Move_B As Boolean Private Is_Movestar_B As Boolean Private MyRect As RECT Private MyPoint As POINTAPI '第二个窗体上 Private Sub Form_Paint() '使窗体始终置于最前面 If PtInRect(MyRect, MyPoint.X, MyPoint.Y) = 0 Then SetWindowPos Me.hwnd, HWND_TOPMOST, Me.Left / Screen.TwipsPerPixelX, _ Me.Top \ Screen.TwipsPerPixelY, Me.Width \ Screen.TwipsPerPixelX, _ Form2.Height \ Screen.TwipsPerPixelY, 0 End If End Sub
Private Sub Form_Load() Timer1.Interval = 50 End SubPrivate Sub Timer1_Timer() Form2.Show 0, Me End Sub
'下面是Form1上的代码
Private Sub Form_Load()
Timer1.Interval = 50
Form2.Show
Form2.MinButton = fasle
End SubPrivate Sub Timer1_Timer()
Form2.ZOrder
End Sub
'在FORM1上建一个COMMAND1
Private Sub Command1_Click()
Form2.Show
End SubPrivate Declare Function PtInRect Lib "user32" (lpRect As RECT, ByVal ptx As Long, ByVal pty As Long) As Long
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) As Long
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal X As Long, _
ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As LongConst HWND_TOPMOST = -1
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Is_Move_B As Boolean
Private Is_Movestar_B As Boolean
Private MyRect As RECT
Private MyPoint As POINTAPI
'第二个窗体上
Private Sub Form_Paint()
'使窗体始终置于最前面
If PtInRect(MyRect, MyPoint.X, MyPoint.Y) = 0 Then
SetWindowPos Me.hwnd, HWND_TOPMOST, Me.Left / Screen.TwipsPerPixelX, _
Me.Top \ Screen.TwipsPerPixelY, Me.Width \ Screen.TwipsPerPixelX, _
Form2.Height \ Screen.TwipsPerPixelY, 0
End If
End Sub
Timer1.Interval = 50
End SubPrivate Sub Timer1_Timer()
Form2.Show 0, Me
End Sub