求救完整的vb代码,怎样运行也写清楚,谢了!我是菜了

来源:百度知道 编辑:UC知道 时间:2024/06/23 00:07:16

Private Sub Form_Load()
On Error Resume Next
Call PutWindowOnTop(Me)

End Sub
模块中
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

Public Function PutWindowOnTop(pFrm As Form)
Dim lngWindowPosition As Long

lngWindowPosition = SetWindowPos(pFrm.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)

End Function