|
'===========================================================
'用途:动态改变窗体的弹出模式
'作者: andymark
'日期:2008-3-4
' Q Q: 42503577 Email: ewang11@163.com
'
'==========================================================
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
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 Const SWP_NOSIZE = &H1
Private Const SWP_NOZORDER = &H4
Private Const SWP_NOMOVE = &H2
Private Const SWP_DRAWFRAME = &H20
Private Const GWL_STYLE = (-16)
Private Const WS_POPUP = &H80000000 '弹出模式
Private Const HWND_TOPMOST = -1 '最顶层窗口
Public Function SetPoPupFrm(Frm As Form, SetPOPUP As Boolean)
Dim dwStyle As Long
dwStyle = GetWindowLong(Frm.hwnd, GWL_STYLE)
If SetPOPUP Then
dwStyle = dwStyle Or WS_POPUP
dwStyle = SetWindowLong(Frm.hwnd, GWL_STYLE, dwStyle)
SetWindowPos Frm.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME
Else
dwStyle = SetWindowLong(Frm.hwnd, GWL_STYLE, dwStyle)
SetWindowPos Frm.hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME
End If
End Function
'Private Sub Form_Load()
'设置窗体弹出模式
' SetPoPupFrm Me, True
'非出模式
' SetPoPupFrm Me, False
'End Sub |
|