赞 | 42 |
VIP | 91 |
好人卡 | 5 |
积分 | 110 |
经验 | 80759 |
最后登录 | 2024-11-16 |
在线时间 | 4430 小时 |
Lv4.逐梦者
- 梦石
- 1
- 星屑
- 10049
- 在线时间
- 4430 小时
- 注册时间
- 2005-10-22
- 帖子
- 6953
|
以下引用sizz123于2008-5-11 19:05:00的发言:
怎么把窗体挂在最前面?
用神奇的API
去处正常关闭和窗口前置代码如下
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
Const HWND_TOPMOST = -1
Const SWP_SHOWWINDOW = &H40
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, _
ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, _
ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Const MF_REMOVE = &H1000&
Private Const SC_COLSE = &HF060
Private Const SC_MAXIMIZE = &HF030
Private Const SC_MINIMIZE = &HF020
以及要进行的窗口的代码
Private Sub Form_Load()
Dim retValue As Long
retValue = SetWindowPos(Me.hWnd, HWND_TOPMOST, Me.CurrentX, Me.CurrentY, 300, 300, SWP_SHOWWINDOW)
RemoveMenu GetSystemMenu(Me.hWnd, 0), SC_COLSE, MF_REMOVE
RemoveMenu GetSystemMenu(Me.hWnd, 0), SC_MAXIMIZE, MF_REMOVE
RemoveMenu GetSystemMenu(Me.hWnd, 0), SC_MINIMIZE, MF_REMOVE
End Sub
'将窗体设置为处于所有窗口的顶层,注意在 VB 中运行时,可能不行,但编译成EXE后就可以了
|
|