Print Page | Close Window

Enable-Disable Menu

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=8078
Printed Date: 16 May 2024 at 9:12pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Enable-Disable Menu
Posted By: KumarCJ
Subject: Enable-Disable Menu
Date 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.



Replies:
Posted By: Oleg
Date 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


Posted By: jimmy
Date Posted: 20 September 2007 at 3:55am
Hi,

Use FindControl instead of your own 'for loop'.

  Jimmy



Posted By: Oleg
Date 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


Posted By: KumarCJ
Date Posted: 29 September 2007 at 12:58am
Thanks alot jimmy / Oleg :)


Posted By: jjqin
Date Posted: 18 December 2007 at 5:46pm
Hi,
 
Which example show Update handlers trick?
 
Regards,
 
-JianJing


Posted By: Oleg
Date Posted: 19 December 2007 at 10:57am
Almost all.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Pariksh*t
Date Posted: 08 July 2008 at 2:59am

oleg what about dynamic menus?

how will you handle event handling of that?



Posted By: znakeeye
Date 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 :)


Posted By: Pariksh*t
Date 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


Posted By: Smucker
Date 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)




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net