Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Enable-Disable Menu
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Enable-Disable Menu

 Post Reply Post Reply
Author
Message
KumarCJ View Drop Down
Groupie
Groupie
Avatar

Joined: 02 April 2007
Location: India
Status: Offline
Points: 96
Post Options Post Options   Thanks (0) Thanks(0)   Quote KumarCJ Quote  Post ReplyReply Direct Link To This Post Topic: Enable-Disable Menu
    Posted: 19 September 2007 at 8:25am
Hi,
 
For enabling/disabling menu item I am using below code:
 
CXTPPopupBar* pCommandBar;

int nCount = pCommandBar->GetControls()->GetCount();
int i = 0;
for (i = 0; i < nCount; i++)
{
    CXTPControl* pCommandBarNew =  pCommandBar->GetControl(i);
          
    if (pCommandBarNew->GetID() == ID_WINDOW_MORE)
    {
        pCommandBarNew->SetEnabled(FALSE);
        pCommandBarNew->SetFlags(xtpFlagManualUpdate);
    }
}

In this case every time searching for menu id in "for" loop.
 
Is there any other way to get the menu id directly(without using "for" loop) for enable/disable the menu item.
 
Thanks,
KumarCJ.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 19 September 2007 at 1:53pm

Hello,

Why you so don't like update handlers??? Please check how our sample Enable/Disable commands.
 
Don't use this loops, use Update handlers.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
jimmy View Drop Down
Senior Member
Senior Member


Joined: 11 November 2003
Location: Austria
Status: Offline
Points: 515
Post Options Post Options   Thanks (0) Thanks(0)   Quote jimmy Quote  Post ReplyReply Direct Link To This Post Posted: 20 September 2007 at 3:55am
Hi,

Use FindControl instead of your own 'for loop'.

  Jimmy

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 21 September 2007 at 1:06am
Hello,
 
FindControl and all these loops are very bad designed solutions. User can remove control, can copy to another toolbar, can move it etc. FindControl can failed or don't update copied controls.
 
Use Actions or Update handlers.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
KumarCJ View Drop Down
Groupie
Groupie
Avatar

Joined: 02 April 2007
Location: India
Status: Offline
Points: 96
Post Options Post Options   Thanks (0) Thanks(0)   Quote KumarCJ Quote  Post ReplyReply Direct Link To This Post Posted: 29 September 2007 at 12:58am
Thanks alot jimmy / Oleg :)
Back to Top
jjqin View Drop Down
Newbie
Newbie


Joined: 18 October 2007
Location: United States
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote jjqin Quote  Post ReplyReply Direct Link To This Post Posted: 18 December 2007 at 5:46pm
Hi,
 
Which example show Update handlers trick?
 
Regards,
 
-JianJing
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 19 December 2007 at 10:57am
Almost all.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Pariksh*t View Drop Down
Groupie
Groupie
Avatar

Joined: 26 June 2008
Location: India
Status: Offline
Points: 77
Post Options Post Options   Thanks (0) Thanks(0)   Quote Pariksh*t Quote  Post ReplyReply Direct Link To This Post Posted: 08 July 2008 at 2:59am

oleg what about dynamic menus?

how will you handle event handling of that?

Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 08 July 2008 at 6:32am
Pariksh*t, update-handlers rocks. If you mean dynamic menus as in "I don't know how many items I will add here", then you need a command-range and an UPDATE_UI_COMMAND_RANGE-handler. A common sample is to add all IE-favorites to a menu. The trick is to say "there will be at most 1000 items":
 
#define ID_FIRST_ITEM 20000
#define ID_LAST_ITEM (ID_FIRST_ITEM + 999)
 
UPDATE_UI_COMMAND_RANGE(ID_FIRST_ITEM, ID_LAST_ITEM, OnItem)
 
... not sure if this is what you were asking. But at least I got the opportunity to code a bit :)
Back to Top
Pariksh*t View Drop Down
Groupie
Groupie
Avatar

Joined: 26 June 2008
Location: India
Status: Offline
Points: 77
Post Options Post Options   Thanks (0) Thanks(0)   Quote Pariksh*t Quote  Post ReplyReply Direct Link To This Post Posted: 08 July 2008 at 6:38am
thanx a lot....
but this is the problem with me at compile time we have no idea about no of ids to be generated......otherwise this idea will work for sure my friend
do reply
bye
Back to Top
Smucker View Drop Down
Senior Member
Senior Member
Avatar

Joined: 02 February 2008
Status: Offline
Points: 156
Post Options Post Options   Thanks (0) Thanks(0)   Quote Smucker Quote  Post ReplyReply Direct Link To This Post Posted: 08 July 2008 at 8:22am
How do you assign ids? Random numbers?

As long as you have a starting point and a max, use the range functions.


Product: Xtreme Toolkit Pro version 13.2 (Unicode, static build)

Platform: Windows 200x/XP/Vista/Win7 (32/64 bit)

Language: Visual C++ 9.0 (Studio 2008)

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.