Event for toolbars visibility - c#

Installed products
Visual Studio 2017 15.6.1
Description
Visual Studio extension that contains a toolbar with drop down combo still receives advised selection(IVsSelectionEvents) events after toolbar is hidden.
Steps to recreate
Use Drop Down Combo from https://github.com/Microsoft/VSSDK-Extensibility-Samples/tree/master/Combo_Box sample
Use IVsMonitorSelection.AdviseSelectionEvents()
Hide the toolbar.
Current behavior
I could not find any event to be notified when toolbar is hidden/shown so could not stop receiving IVsSelectionEvents interfaces OnSelectionChanged event.
Expected behavior
Notified when toolbar is hidden or shown so Advise/UnadviseSelectionEvents() could be called.
So, i need an event that is triggered when toolbar is shown and hidden.

Related

C#/.NET - View a list of system events ie. Windows that have been displayed, buttons that have been clicked etc

I'm completely new to C# and the .NET framework so forgive me if this is a silly question.
Is there any way of viewing a list of all of the events that have happened on a Windows system as a result of keystrokes and mouse movements etc.? So for example when I click on the Start menu, the Start menu is displayed or when I click the "Apply" button within a settings sub-menu, the settings are applied.
Is there any part of the .NET framework that will allow me to view all of these events/actions and record them via a C# program? Any help would me greatly appreciated! Thanks in advance.
UI Automation API is what you need. For listening automation events there are few kinds of handlers: AutomationEventHandler, StructureChangedEventHandler and 2 others.
There is another way for native windows: global mouse and keyboard hooks. See SetWindowsHookEx function.
C# in visual studio designer gives you the ability to respond to all kinds of events, like mouse moves and clicks. If you click on the object you want events from, then go to the events pane, you will see a list of all the events for that object. double click in the textbox next to it and it will auto-generate an event handler in your code. When the event is triggered, it will go to this method and do any code you provide there; IE log the action however you choose.

In Visual Studio 2012 why is a message box in the project shown as the project loads?

In Visual Studio 2012, I added a message box to the load event of a WinForms user control that will pop up if the user control was not initialized correctly (when the load event is fired). All the check does is see if a couple of member variables in the user control are null or not.
The user control is in a different project from the main application because it will be used by more than one application.
The intended sequence of events is this:
In the main application, there is a right click menu with an option to show a window. That window contains the user control being referred to. When the user selects that menu item it creates an instance of the window, initializes the window through an initialization method, which in turn sets the variables in the user control to initialize it. Then the form.Activate method is called, then ShowDialog() and Focus() for the window containing the user control.
Here's the issue:
When I load the solution in Visual Studio 2012, while the solution is being loaded and before any code is shown, the message box is sometimes shown as a modal dialog of Visual Studio itself. The solution does not continue to load until I dismiss the message box.
Also, the message box is sometimes shown when I debug the application, popping up immediately after the login window of the application is shown. I can't seem to find any pattern to why the message box is shown in these two instances.
This is very mystifying as the code is not even executing, yet the message box is being shown. And during application start up the message box is shown even though the right click menu has not been selected.
To be honest I'm not even sure what information to give about this to get an answer. Any information pointing me in the right direction would be appreciated.
So that others like myself can see the answer to this question, Prix and Jonathon Reinhart have provided excellent answers in the comments to my question. But for completeness I'll just sum up.
The load event is fired as soon as the form or user control is ready. The user control is loaded on application start up so that it will be available to use in any form, which is what Prix is talking about. MSDN says this about the load event "Occurs before a form is displayed for the first time." Apparently this can mean even while starting your application, and not necessarily right before being shown.
In other words the load event is not the correct place to put an initialization check.
As for the message box being shown when the solution is loaded in Visual Studio, Jonathon Reinhart provided the key here. Apparently, the visual studio designer interface uses the load event to show the user control in the designer, so the code is executed as the designer loads your user control as well.
Mystification de-mystified. Thank you Prix and Jonathon. Such a simple answer, but I sure was stumped.

C# WinForms - Drag Drop TreeView in VS 2013 Update 3 not work

I Have Winforms and crate drag drop for my tree view using Drag Drop Sample in code project.
this worked before I upgrade my project to VS 2013 update 3 but when project upgrade to VS 2013 I can not start drag in tree view.
I so confused for this complicated problem
Please help me.
Please check this steps:
You must first set AllowDrop=true;
Set Event ItemDrag
Set Event DragDrop
Set Event DragEnter
Set Event DragOver
If your tree drag drop worked before and now not work I think it must be for your data structure that checked in DragDrop Event or some other event of drag drop

How to programmatically remove a menu context item in Outlook 2013

I have an Outlook add in that was written with Outlook 2010 in mind but I am updating to handle Outlook 2013 correctly. As part of the add in I have included a number of context menu buttons using the IRibbon method.
At this point these new menu items work correctly, however I wish to remove one of the default Outlook contxt menu buttons with right clicking on a mail item or document in a specific folder.
I have tried declaring a GetVisible event for the button in the Ribbon XML but this does not get fired like the GetVisibile calls I have for my new custom added buttons.
If anyone has any hints, tips or experience with disabling one of the default Outlook 2013 context menu options they would be much appreciated.
Having looked into this further, the "Delete" option I was looking to remove was a new addition on 2013, having originally thought the add in I was working with had removed it in 2010.
It shares the same behaviour as the "Delete" button in the main top ribbon and appears to be a menu item that cannot be removed on an item type basis, but you can suppress the behaviour of the button within the add in.

Windows Application .. Not working

after I did this application using visual C# ... Simply nothing on the form is working its like disconnected any ideas why ?
Check if the event handlers for the Button.Click events are set. Visual Studio tends to drop the event handlers some times.
Open up your form in design mode and check if the click event is set for your buttons by inspecting them in the property grid. If they aren't then you can reselect the method using the drop-down menu.

Categories