泰国安娜贝拉官网:vb 窗体一直置前

来源:百度文库 编辑:高考问答 时间:2024/04/29 14:54:07
我想要做一个窗体,像迅雷,网际快车,那样的悬浮窗。 一直置前。

要※一直※置前!
光这个
SetWindowPos Form3.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
不是一直置前
怎样才能一直置前?

Option Explicit

''使指定窗口总在最前
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

Const HWND_TOPMOST = -1
Const SWP_NOMOVE = &H2
Const SWP_NOSIZE = &H1
Const SWP_NOZORDER = &H8

Sub SetFormTopmost(TheForm As Form)

SetWindowPos TheForm.hwnd, HWND_TOPMOST, 0, 0, 0, 0, _
SWP_NOZORDER + SWP_NOMOVE + SWP_NOSIZE

End Sub

Sub Form_Load()

SetFormTopmost Me ''只需要改动这里,ME换成你想放在最前的窗体名

End Sub

Private Sub Form_Paint()
Dim front
front = SetWindowPos(Form3.hwnd, -1, 0, 0, 0, 0, &H2 Or &H3)

End Sub