- UID
- 45489
注册时间2008-2-14
阅读权限50
最后登录1970-1-1
感悟天道
TA的每日心情 | 开心 2025-1-14 20:20 |
---|
签到天数: 1246 天 [LV.10]以坛为家III
|
下面一段代码是用复选框使窗口置顶的。有些问题想问问大家。
Const HWND_TOPMOST = -1
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
Private Sub Check1_Click()
Dim lngWindowFront As Long
If Check1.Value = 1 Then '窗口置前
lngWindowFront = SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, 3)
If lngWindowFront = 0 Then
MsgBox "设置失败!", vbInformation, "友情提示"
Else
MsgBox "设置成功!", vbInformation, "友情提示"
End If
Else
lngWindowFront = SetWindowPos(Me.hwnd, -2, 0, 0, 0, 0, 3)
If lngWindowFront = 0 Then
MsgBox "设置失败!", vbInformation, "友情提示"
Else
MsgBox "设置成功!", vbInformation, "友情提示"
End If
End If
End Sub
为什么要在这里声明常量HWND_TOPMOST = -1呢?
它不是hWndInsertAfter中的值吗?
lngWindowFront = SetWindowPos(Me.hwnd, -2, 0, 0, 0, 0, 3)
而这个-2又代表了什么? |
|