![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I've created a custom task pane on a User Control using VSTO and VS.Net 2008. In the UserControl I want to detect when focus switches back and forth between the worksheet and the User Control. I've looked at the GotFocus, Enter and other events for the User Control, but they don't capture this change of focus. If it was a dll form, I know I'd use the Activate event, but that doesn't exist for the User Control. You may want to go with this to the VSTO forum, as there's more support |
#3
| |||
| |||
|
|
Hi Doug, I've created a custom task pane on a User Control using VSTO and VS.Net 2008. In the UserControl I want to detect when focus switches back and forth between the worksheet and the User Control. I've looked at the GotFocus, Enter and other events for the User Control, but they don't capture this change of focus. If it was a dll form, I know I'd use the Activate event, but that doesn't exist for the User Control. You may want to go with this to the VSTO forum, as there's more support there. http://social.msdn.microsoft.com/Forums/en-US/vsto/threads/#page:1 The problem seems to lie with how the user control is wrapped into the CTP. The CTP is a type of Office CommandBar. VSTO wraps the user control into a managed code ActiveX control that, in turn, is enabled for COM. So not all the properties and events are exposed in the same way. If I click from the document into a textbox control on the UC the Enter event is triggered the first time. If I then TAB out of the textbox and there is no other target in the UC, the leave event will trigger (and the focus is in the document). If I click into the document, no event in the UC is triggered, but I do get the event for selection change. So I guess the best you could do is create events for the controls in the UC and also trap the event that triggers when the user clicks on the document. In the "enter" events of the UC set a class-level variable that records that the UC has gotten the focus. Check this in the document's selection change event; if it's true you know the UC has been entered, then left. Cindy Meister INTER-Solutions, Switzerland http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005) http://www.word.mvps.org This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :-) |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |