
Signature
Carlos J. Quintero (Visual Developer - .NET MVP)
FAQs, Knowledge Base, Files, Docs, Articles, Utilities, etc. for .NET
addins:
http://groups.yahoo.com/group/vsnetaddin/ (free join)
> I am missing something here..., do you mean that you are using C# which does
> not support missing parameters?
Yeah, C# must pass all parameters unless you pass in System.Type.Missing as
Dustin
suggested which I didn't know about. Eventually I figured out by trial and
error
what to use for default parameters so it ended up working before Dustins
post,
but it took a while to figure out which values to use.
> Again, I am also missing something here: if you cast to CommandBarPopup,
> this class exposes a CommandBar property directly, no need for Reflection or
[quoted text clipped - 5 lines]
>
> objMyCommandBarControl =
objCodeWindowCommandBar.Controls.Add(MsoControlType.msoControlPopup,System.T
> ype.Missing,System.Type.Missing,System.Type.Missing,System.Type.Missing);
>
> objMyCommandBarPopup = (CommandBarPopup) objMyCommandBarControl;
Ok, I'm a moron <g>... looking at the code again I didn't cast to
CommandBarPopup <g>.
I ended up with a CommandBarControl which of course doesn't have the
property and
off it I could get the CommandBar property via Reflection.
> > I suppose I should also not use AddNamedCommand, but Commands.Add() but
> > that's yet another excercise that I don't feel like wasting my time on
> > today...
>
> No, you should stick to Commands.AddNamedCommand. I was not aware of
> Commands.Add() until you mentioned it and now I see it is a hidden method.
Right. I ended up writing some generic Command Add routine that handles all
of this
in a single method to make it easy to port this stuff later to Whidbey
(since apparently
the whole CommandBar model has changed). The code checks to see if hte
command exists
before creating a new one which guarantees that you never end up getting
errros and
that things won't break if VS crashes and the cleanup code doesn't fire.
Using a non
named command bar and named commands works well now and it finally feels
like I'm doing
this the right way <g>...
+++ rick ---

Signature
Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
http://www.west-wind.com/wwThreads/
----------------------------------
Making waves on the Web
> > I remember looking at this a while back but I couldn't make this work
> mainly
[quoted text clipped - 6 lines]
> I am missing something here..., do you mean that you are using C# which does
> not support missing parameters?
Yeah, C# must pass all parameters unless you pass in System.Type.Missing as
Dustin
suggested which I didn't know about. Eventually I figured out by trial and
error
what to use for default parameters so it ended up working, but it took a
while.
> Again, I am also missing something here: if you cast to CommandBarPopup,
> this class exposes a CommandBar property directly, no need for Reflection or
[quoted text clipped - 5 lines]
>
> objMyCommandBarControl =
objCodeWindowCommandBar.Controls.Add(MsoControlType.msoControlPopup,System.T
> ype.Missing,System.Type.Missing,System.Type.Missing,System.Type.Missing);
>
> objMyCommandBarPopup = (CommandBarPopup) objMyCommandBarControl;
Ok, I'm a moron <g>... looking at the code again I didn't cast to
CommandBarPopup <g>.
I ended up with a CommandBarControl which of course doesn't have the
property and
off it I could get the CommandBar property via Reflection.
> > I suppose I should also not use AddNamedCommand, but Commands.Add() but
> > that's yet another excercise that I don't feel like wasting my time on
> > today...
>
> No, you should stick to Commands.AddNamedCommand. I was not aware of
> Commands.Add() until you mentioned it and now I see it is a hidden method.
Right. I ended up writing some generic Command Add routine that handles all
of this
in a single method to make it easy to port this stuff later to Whidbey
(since apparently
the whole CommandBar model has changed). The code checks to see if hte
command exists
before creating a new one which guarantees that you never end up getting
errros and
that things won't break if VS crashes and the cleanup code doesn't fire.
Using a non
named command bar and named commands works well now and it finally feels
like I'm doing
this the right way <g>...
+++ rick ---
Carlos J. Quintero [MVP] - 19 Aug 2004 09:47 GMT
I have just updated the article to include System.Type.Missing values just
in case someone else ports it to C#. It can take some minutes to appear on
the MSDN site.

Signature
Carlos J. Quintero (Visual Developer - .NET MVP)
FAQs, Knowledge Base, Files, Docs, Articles, Utilities, etc. for .NET
addins:
http://groups.yahoo.com/group/vsnetaddin/ (free join)
> Yeah, C# must pass all parameters unless you pass in System.Type.Missing
as Dustin
> suggested which I didn't know about. Eventually I figured out by trial and
error
> what to use for default parameters so it ended up working before Dustins
post,
> but it took a while to figure out which values to use.