FORM 窗口总在最前(显示隐藏视窗)

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 ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long 

 

'1.声明方法

 

Const SWP_HIDEWINDOW = &H80 '隐藏视窗
Const SWP_SHOWWINDOW = &H40 '显示视窗

 

'2.在Form_load中加入代码

Private Sub Form_Load()

     Dim Thwnd As Long
     Form1.BackColor = RGB(206, 223, 247)
    Thwnd = FindWindow("Shell_traywnd", "")
    Call SetWindowPos(Thwnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW)
    SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 3
    Me.WindowState = 2

End Sub <!-- 导入 在此 参考资料--><!-- end 参考资料-->

 

 

你可能感兴趣的:(form)