VB中,窗体置顶问题,VB中,窗体如何一直都在其他窗体上面

来源:百度知道 编辑:UC知道 时间:2024/05/10 21:32:12

Private Declare Function SetWindowPos Lib "USER32.DLL" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As Long) As Boolean

Const SWP_NOMOVE = &H2 '不更动目前视窗位置
Const SWP_NOSIZE = &H1 '不更动目前视窗大小
Const HWND_TOPMOST = -1 '设定为最上层
Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Dim bTopMost As Boolean

Private Sub Form_Load()
If bTopMost = False Then
SetWindowPos Me.hWnd, HWND_TOPMOST, Me.Left, Me.Top, Me.Width, Me.Height, FLAGS
bTopMost = True
End If