Option Explicit
Private Declare Function EnableWindow Lib "User32" _
(ByVal hWnd As Long, ByVal fEnable As Long) As Long
Private Declare Function GetWindow Lib "User32" _
(ByVal hWnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetCursorPos Lib "User32" _
(lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "User32" _
(ByVal lpPointX As Long, ByVal lpPointY As Long) _
As Long
Private Declare Function GetAsyncKeyState Lib "User32" _
(ByVal vKey As Long) As Integer
Private Declare Function GetFocus Lib "User32" () As _
Long
Private Declare Function SetFocusAPI Lib "User32" _
Alias "SetFocus" (ByVal hWnd 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 Const GWL_WNDPROC = -4
Private Const GW_OWNER = 4
Private Const VK_LBUTTON = &H1
Private Const LBUTTON_DOWN = &H8000
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Sub WaitForMe()
Dim hParent As Long
Dim hProperty As Long
Dim tPoint As POINTAPI
Dim lOldProc As Long
'Subclass the About Box
lOldProc = SetWindowLong(Me.hWnd, GWL_WNDPROC, _
AddressOf AboutProc)
'Pass the old window procedure into the mod file
Call PassOldProc(lOldProc)
'Get the Property Browser handle
hProperty = GetFocus
'Get the VB IDE handle
hParent = GetWindow(Me.hWnd, GW_OWNER)
'Bring up the About Box
Me.Visible = True
'Disable the VB IDE and re-enable the About Box
Call EnableWindow(hParent, 0)
Call EnableWindow(Me.hWnd, 1)
Do
'Exit if a close message was received
If CloseWindow() = True Then Exit Do
'Find the cursor position
Call GetCursorPos(tPoint)
'Inside the button's perimeter?
If cmdClose.hWnd = WindowFromPoint(tPoint.X, _
tPoint.Y) Then
'If the button is down, then exit
If GetAsyncKeyState(VK_LBUTTON) = _
LBUTTON_DOWN Then Exit Do
End If
DoEvents
Loop
'Restore the old window procedure
Call SetWindowLong(Me.hWnd, GWL_WNDPROC, lOldProc)
'Re-enable the VB IDE
Call EnableWindow(hParent, 1)
'Set the focus back on the Property Browser
Call SetFocusAPI(hProperty)
'Unload the About Box
Unload Me
End Sub
|