VB中窗体最顶和最底

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 FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function GetWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal wCmd As Long) As Long

Private Sub Command1_Click()
If Command1.Caption = "置顶" Then
SetWindowPos Me.hwnd, -1&, 0&, 0&, 0&, 0&, 3&
Command1.Caption = "置底"
Else
SetParent Me.hwnd, GetWindow(FindWindow("Progman", "Program Manager"), 5)
Command1.Caption = "置顶"
End If
End Sub

Private Sub Form_Load()
Command1.Caption = "置顶"
End Sub
原文地址:https://www.cnblogs.com/appleseed/p/1314383.html