On 11/7/05 13:39, in article
1131399586.714090.217230@f14g2000cwb.googlegroups.com, "dengerous@mail.ru"
> first, I set command control to be disabled , then at some point I want
> to enable it.
[quoted text clipped - 7 lines]
>
> But, unfortunately, the item stays disabled all the time. Any ideas?
I am not sure about managed code, but in C++ it is important not only to set
correct flags, but also to return S_OK and not OLE_E_UNKNOWNGROUP.
Thanks
Mikhail Arkhipov (Microsoft)
-- This post is provided 'AS IS' with no warranties and confers no rights
> first, I set command control to be disabled ,
How?
> then at some point I want to enable it.
> so here's what I tried in QueryStatus method:
[quoted text clipped - 6 lines]
>
> But, unfortunately, the item stays disabled all the time. Any ideas?
Basically you should avoid that EnabledFlag, or at least update it
somewhere. I mean, you will want your command enabled or disabled depending
on some condition (for example, if a code window is active, but not if a
designer window is active). VS.NET will call your QueryStatus method
whenever it needs, so your code should look like this:
if ( MyFunctionToCheckCodeWindow(applicationObject.ActiveWindow) )
statusOption = vsCommandStatusEnabled + vsCommandStatusSupported
else
statusOption = vsCommandStatusSupported
end if
You see, no need for EnabledFlags...

Signature
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
dengerous@mail.ru - 08 Nov 2005 18:07 GMT
Thank you , Carlos. But the problem is not in the flag. The flag is
switched fine. The problem is once statusOption of command was set to
vsCommandStatusSupported , changing it to vsCommandStatusEnabled +
vsCommandStatusSupported makes no effect at all.
You can try your code, it just doesn't work.
Carlos J. Quintero [VB MVP] - 10 Nov 2005 09:32 GMT
It should work the next time that QueryStatus is called by the IDE. It works
for me using VS 2005 Release Candidate.

Signature
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
> Thank you , Carlos. But the problem is not in the flag. The flag is
> switched fine. The problem is once statusOption of command was set to
> vsCommandStatusSupported , changing it to vsCommandStatusEnabled +
> vsCommandStatusSupported makes no effect at all.
> You can try your code, it just doesn't work.