I am building a Visual Studio extension and I am stumped on how I would show a dialog when visual studio is started.
The main use for it is going to be when Visual studio starts my extension will check for updates if an update is found a dialog appears.
Information on extensions is very scarce so I have no idea how to do this. I am using C#.
Edit: I have tried adding the code in the package file that has all of the command code/callbacks into it's initialize event and it shows the dialog before visual studio appears to have even loaded and does not continue to load until I close it. I feel like I am getting closer though.
Is their an extension start up command I can create in VSCT file, kind of like they have for menu items?
The values for individual controls and the dialog box appear in the lower right of the Visual Studio status bar when you select them.
To create a modal dialog box, call either of the two public constructors declared in CDialog. Next, call the dialog object's DoModal member function to display the dialog box and manage interaction with it until the user chooses OK or Cancel. This management by DoModal is what makes the dialog box modal.
You can access Options from the Tools menu.
Use the Manage Extensions dialog box to install and manage Visual Studio extensions. To open the Manage Extensions dialog, choose Extensions > Manage Extensions. Or, type Extensions in the search box and choose Manage Extensions.
I was able to figure out my problem. It took alot of trial and error due to the lack of info. I had originally tried the OnStartupcomplete() event but it was not working for me, hence I came here. The reason why it was not working was because the DTE object wasn't initialized at that point. So I was able to create the object and add the handler.
[ProvideAutoLoad(Microsoft.VisualStudio.Shell.Interop.UIContextGuids.NoSolution)]
[ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExists_string)]
protected override void Initialize()
{
//DTE gets called
var dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE));
_EventsObj = dte.Events.DTEEvents;
_EventsObj.OnStartupComplete += OnStartupComplete;
}
public void OnStartupComplete()
{
//This is the code to launch the dialog.
EvaluationDialog EvalForm = new EvaluationDialog();
EvalForm.ShowDialog();
}
I'm assuming you are using a Visual Studio Add-in project. If you want just a message box, in the Connect.cs file, add a reference to System.Windows.Forms
and a using
statement:
using System.Windows.Forms;
In the OnConnection
method:
public void OnConnection(object application,
ext_ConnectMode connectMode,
object addInInst, ref Array custom)
{
MessageBox.Show("message box");
// or you could use your on dialog class
var myDialog=new MyDialog();
myDialog.Show();
// ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With