Nicolas Bourgogne
Guest
|
Good afternoon,
As a follow up to this discussion: http://www.add-in-express.com/forum/read.php?FID=5&TID=12006
I would like to detect when the key down event is triggered from the Navigation pane or search pane.
I cannot find anywhere a property that would indicate that the "active" selection is really the search box rather than the document itself. The reason being that I only want to handle the key stroke if the user is currently working in the document, not typing in the search box.
Thank you,
Nicolas |
|
Heinz-Josef Bomanns
Posts: 206
Joined: 2008-02-28
|
Hi Nicolas,
you may try to use adxWordEvents to update a gobal flag like 'Public IsInWindow As Boolean' in 'WindowActivate' (=True) and 'WindowDeactivate' (=False) and check that flag in your code:
If IsInWindow Then
'DoSomeThing
Else
'Ignore
End If__________________
Greetings, HJB
|
|
Nicolas Bourgogne
Guest
|
Thanks Heinz,
Unfortunately, this doesn't work. The navigation pane is part of the window, so the WindowDeactivate event is not triggered by toggling its display status or typing in it. At least not on Office 2010 64-bit.
Nicolas |
|
Andrei Smolin
Add-in Express team
Posts: 19138
Joined: 2006-05-11
|
Nicolas,
First, you need to use Spy++ to retrieve the class names and captions of the windows in the window chain in which the task pane window resides. Obviously, the details of the window chain may differ for different Word versions. The edit control adds one more window to the chain: when you click what the Search "control" (it is just drawn on the pane), Word creates a RichEdit which handles the user input; when you move the focus off the pane, the RichEdit control is killed.
In the OnKeyDown event, you retrieve the hwnd of the focused window by calling the GetFocus Win API function. Then you use the GetClassName and GetWindowText (plus GetWindowTextLength) Win API functions to retrieve the class name and caption of this window. Finally, you use GetParent to retrieve the parent window of the current window. In this way you can walk up the window chain to find the window the class name and/or title of which you know from studying the Spy++ output. You find the declarations of the above mentioned WinAPI functions at pinvoke.net.
Andrei Smolin
Add-in Express Team Leader |
|
Nicolas Bourgogne
Guest
|
Thanks Andrei!
I was hoping to do it via the application interface itself, but this works perfectly.
Nicolas |
|