- 注册时间
- 2011-3-6
- 最后登录
- 1970-1-1
该用户从未签到
|
下面一段代码是用复选框使窗口置顶的。有些问题想问问大家。
引用
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
引用
Const HWND_TOPMOST = -1
为什么要在这里声明常量HWND_TOPMOST = -1呢?
它不是hWndInsertAfter中的值吗?
引用
lngWindowFront = SetWindowPos(Me.hwnd, -2, 0, 0, 0, 0, 3)
而这个-2又代表了什么?
引用
引用第1楼geriald于2008-04-14 17:01发表的 :
HWND_TOPMOST = -1
设置当前窗体处于最上层,HWND_TOPMOST窗体只能设置一个
-2也是设置窗体
我是说这个-1跟-2是固定的,但为什么呢?
在书上没见到给这些参数赋值呀,这值不是随便赋的吧。
|
|