Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / IDE / November 2005

Tip: Looking for answers? Try searching our database.

enabling disabled menu item

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dengerous@mail.ru - 07 Nov 2005 21:39 GMT
first, I set command control to be disabled , then at some point I want
to enable it.
so here's what I tried in QueryStatus method:

if EnabledFlag then
statusOption = vsCommandStatusSupported
else
statusOption = vsCommandStatusEnabled + vsCommandStatusSupported
end if

But, unfortunately, the item stays disabled all the time. Any ideas?
Mikhail Arkhipov (Microsoft) - 08 Nov 2005 04:41 GMT
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
Carlos J. Quintero [VB MVP] - 08 Nov 2005 12:14 GMT
> 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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.