mouse focusing in close button in preview window

T

tom taol

i have a button in the sheet.
when i press the button, preview run.
i want to focusing with mouse pointer to close button in preview window.

Private Declare Function SetTimer _
Lib "user32" ( _
ByVal hwnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) _
As Long

Private Declare Function KillTimer _
Lib "user32" ( _
ByVal hwnd As Long, _
ByVal nIDEvent As Long) _
As Long
Private Declare Function GetActiveWindow _
Lib "user32" () _
As Long

Private Declare Function FindWindowEx _
Lib "user32" _
Alias "FindWindowExA" ( _
ByVal hWnd1 As Long, _
ByVal hWnd2 As Long, _
ByVal lpsz1 As String, _
ByVal lpsz2 As String) _
As Long
Private Declare Function SetCursorPos Lib "user32" _
(ByVal x As Long, ByVal y As Long)
As Long
Private Declare Function ClientToScreen Lib "user32" _
(ByVal hwnd As Long, lpPoint As
POINTAPI) As Long
Type POINTAPI
x As Long
y As Long
End Type
Type Rect
x1 As Long
y1 As Long
x2 As Long
y2 As Long
End Type
Private Const GW_CHILD = 5

Private rt As Rect
Private pt As POINTAPI
Private Declare Function GetWindow Lib "user32" ( _
ByVal hwnd As Long, ByVal uCmd As Long) As Long

Public Function TimMsg3( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal nEvent As Long, _
ByVal nSecs As Long) As Long

KillTimer 0, nEvent
hdlwndAct = GetActiveWindow()
prev = GetWindow(hdlwndAct, GW_CHILD)
hBtn = FindWindowEx(prev, 0&, "Button", "´Ý±â(&C)")
GetClientRect hBtn, rt
pt.x = rt.x1
pt.y = rt.y1
ClientToScreen hBtn, pt
SetCursorPos pt.x + 20, pt.y + 10
End Function

Sub prvAndFocusColseBtn()
SetTimer 0, 0, 100, AddressOf TimMsg3
ActiveSheet.PrintPreview
End Sub




*** Sent via Developersdex http://www.developersdex.com ***
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top