求vb6中让窗体一直保持在最前的代码
答案:3 悬赏:10 手机版
解决时间 2021-11-08 13:12
- 提问者网友:爱了却不能说
- 2021-11-07 19:45
求vb6中让窗体一直保持在最前的代码
最佳答案
- 五星知识达人网友:舊物识亽
- 2021-11-07 20:48
Option Explicit
Private Const SWP_NOMOVE = 2
Private Const SWP_NOSIZE = 1
Private Const Flags = SWP_NOMOVE Or SWP_NOSIZE
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
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
Public Function SetTopMostWindow(tHWND As Long, Topmost As Boolean) As Long
If Topmost = True Then ''Make the window topmost
SetTopMostWindow = SetWindowPos(tHWND, HWND_TOPMOST, 0, 0, 0, 0, Flags)
Else
SetTopMostWindow = SetWindowPos(tHWND, HWND_NOTOPMOST, 0, 0, 0, 0, Flags)
SetTopMostWindow = False
End If
End Function
Private Sub Form_Load()
SetTopMostWindow Me.hwnd, True
End Sub
Private Const SWP_NOMOVE = 2
Private Const SWP_NOSIZE = 1
Private Const Flags = SWP_NOMOVE Or SWP_NOSIZE
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
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
Public Function SetTopMostWindow(tHWND As Long, Topmost As Boolean) As Long
If Topmost = True Then ''Make the window topmost
SetTopMostWindow = SetWindowPos(tHWND, HWND_TOPMOST, 0, 0, 0, 0, Flags)
Else
SetTopMostWindow = SetWindowPos(tHWND, HWND_NOTOPMOST, 0, 0, 0, 0, Flags)
SetTopMostWindow = False
End If
End Function
Private Sub Form_Load()
SetTopMostWindow Me.hwnd, True
End Sub
全部回答
- 1楼网友:污到你湿
- 2021-11-07 22:20
SetWindowPos
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯