Visual studio Combo box selected detection  
Author Message
jwize





PostPosted: Visual Studio Extensibility, Visual studio Combo box selected detection Top

I need to detect when a user has entered a combo box, for example, when the user enters the Types dropdown from the class's code view. You can select the Types dropdown menu using the mouse.You can also press CTRL + F2 to navigate to the Types dropdown.

I want to do this so I can remind the user that there is an available short-cut for that particular action. This, I hope, will improve the efficiency of the programmer using the IDE. I will send a modal dialog that can only be closed by the user using the correct shortcut command--that way the user will slowly remember all the possible shortcuts. I have implemented most visual studio .net commands in this way by trapping the command events that are raised when a Visual Studio command has been executed. These command reminders have been implemented successfully. Since there is no command raised by simply clicking a drop down, I need a way to detect when a new dropdown control has gained focus.

Any help would be greatly appreciated.

Thank you!


Visual Studio7  
 
 
Carlos J. Quintero





PostPosted: Visual Studio Extensibility, Visual studio Combo box selected detection Top

Hi,

I don’t think that the extensibility model will provide a way to detect that. Maybe the VS SDK has something related to document windows but AFAIK that functionality is language-specific. Another approach is to use the Win32 API to track mouse activity.

But in any case, maybe you should reconsider what you are trying to do, since it seems a bit overkill to me. One thing is to kindly educate programmers about productivity shortcuts (which should be voluntary) and another thing is to show a modal (!!) dialog (not just a tooltip or balloon) that can be closed only with the suggested shortcut if they dare to use the mouse... You may end infuriating the programmers instead of increasing their productivity. It is always a good idea to give the control of how to work to the user, not all users have the same preferences...

I hope that you are doing this only for your internal organization and not for a commercial product....it will hurt sales severely.



 
 
jwize





PostPosted: Visual Studio Extensibility, Visual studio Combo box selected detection Top

I do my work and then I am prompted with a dialog when I use common operations that have available shortcut. It is a headache to learn all of the shortcuts but in the long term it will definitely improve programming efficiency.

The modal also has the default button(Enter Key to close it) highlighted. Once the I press that button I will stop recieving prompts for that shortcut. All the actions that I don't want to be prompted for anymore are saved to an xml file , so that when the addin loads those particular command/actions will be no longer send notifications.The other way to close the dialog is to use the shortcut. I use the shortcut when I feel I'm not familiar with it yet. Ideally, I the shortcut would not send the modal prompt. I couldn't find anyway to trap shortcut invoked command/actions.


 
 
Paul Harrington MSFT





PostPosted: Visual Studio Extensibility, Visual studio Combo box selected detection Top

There might be a way to do it via a priority command target (which requires a package, not an add-in), but I doubt it'll work for all cases.

In any case, if you show a modal dialog when a combo drops down, then the combo will go away again (combos self-dismiss when focus changes)



 
 
Carlos J. Quintero





PostPosted: Visual Studio Extensibility, Visual studio Combo box selected detection Top

OK, since it seems that you know what you are doing, I think that the only way will be using the Win32 API. Basically you can try something like this:

- Get the handle of the main IDE window: DTE.MainWindow.hWnd, which is non-zero always.

- Get the handle of the active document window. The active window can be got with DTE.ActiveWindow, the active document window with DTE.ActiveDocument.ActiveWindow and/or DTE.WindowEvents / DTE.DocumentEvents. But since Window.HWnd will return 0 (because MS does not want you to do the kind of things that you are trying to do), so you should use the FindWindow Win32 API function to get this window handle by caption/class, etc. knowing the handle of the parent main window.

- Get the handle of the combobox window with the same approach and then use some Win32 API trick to trap its events (subclassing, etc.)

Notice that all of this is risky, unrecommended, unsupported, etc,etc...



 
 
jwize





PostPosted: Visual Studio Extensibility, Visual studio Combo box selected detection Top

Thanks for that. I figured I would have to do it using the Win32 Api. I needed the extra guidance about the dte hwnd, so thanks for that. I am also familiar with FindWindow as well. When I try it out I will keep you updated to see if it all works out.