- 积分
- 73549
- 明经币
- 个
- 注册时间
- 2001-6-7
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2003-2-27 20:01:00
|
显示全部楼层
实际上Always On Top是借助Windows API的SetWindowPos实现的
1、首先应该把以下声明放再窗体的声明部分:
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_NOACTIVATE = &H10
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const SWP_SHOWWINDOW = &H40
Private Declare Function SetWindowPos Lib _
"user32" Alias "SetWindowPos" (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
2.使窗口Always On Top时,可以用下面的语句:
SetWindowPos hWnd, HWND_TOPMOST, 0, 0, 0, 0, _
SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE _
Or SWP_NOSIZE
3.使窗口取消Always On Top功能,用下面的语句:
SetWindowPos hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, _
SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE _
Or SWP_NOSIZE |
|