模块:Public 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 Public Const HWND_TOPMOST = -1Public Function OnTop(ByVal hWnd As Long, ByVal frmlef As Long, ByVal frmtop As Long, ByVal frmwid As Long, ByVal frmhei As Long) SetWindowPos hWnd, HWND_TOPMOST, frmlef / Screen.TwipsPerPixelX, frmtop \ Screen.TwipsPerPixelY, frmwid \ Screen.TwipsPerPixelX, frmhei \ Screen.TwipsPerPixelY, 0 End Function窗体: private sub form_load() call ontop(me.hwnd,me.left,me.top,me.width,me.height) end sub
Public Const HWND_TOPMOST = -1Public Function OnTop(ByVal hWnd As Long, ByVal frmlef As Long, ByVal frmtop As Long, ByVal frmwid As Long, ByVal frmhei As Long)
SetWindowPos hWnd, HWND_TOPMOST, frmlef / Screen.TwipsPerPixelX, frmtop \ Screen.TwipsPerPixelY, frmwid \ Screen.TwipsPerPixelX, frmhei \ Screen.TwipsPerPixelY, 0
End Function窗体:
private sub form_load()
call ontop(me.hwnd,me.left,me.top,me.width,me.height)
end sub
在XP下运行会溢出