![]() |
How to handle Dynamic created menus Event Handling |
Post Reply
|
| Author | |
Pariksh*t
Groupie
Joined: 26 June 2008 Location: India Status: Offline Points: 77 |
Post Options
Thanks(0)
Quote Reply
Topic: How to handle Dynamic created menus Event HandlingPosted: 08 July 2008 at 12:44am |
|
hi this is pariksh*t. i am implementing dynamic menus in a ribbonbar. i amthrough with that. i am handling all the events of this menu whose ids gets dynamically created in function---- BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);But the problem is that the menu items are disabled as i have not done
void OnUpdate11111(CCmdUI* pCmdUI);void On11111(); 11111 is the id of a menu item. This id is dynamically generated....if i dont write these 2 functions my menu items gets disabled
Now the issue is at the compile time i have no idea about no of menu items which will generate at run time
so i cant write
void OnUpdate#(CCmdUI* pCmdUI);
void On#();
at compile time
what should i do?
Reply asap.
Regards,
Pariksh*t.
|
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
Posted: 08 July 2008 at 6:25am |
|
Hi,
How it worked before with simple CMenu ? I sure it will work same with our CommandBars.
|
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
Pariksh*t
Groupie
Joined: 26 June 2008 Location: India Status: Offline Points: 77 |
Post Options
Thanks(0)
Quote Reply
Posted: 08 July 2008 at 7:06am |
|
Dear oleg thanx for reply But i didnt get you. There is no issue with your commandbars or menus the question was about how to do event handling of dynamically generated menus in Xtreme toolkit. i managed to do the same in mfc in a dialog based app. But problem with Xtreme Toolkit is that it compells me to write OnUpdate#() and On#() for each & every ID of menu which generates at run time and the no of IDs is not fixed ............
do reply
|
|
![]() |
|
Smucker
Senior Member
Joined: 02 February 2008 Status: Offline Points: 156 |
Post Options
Thanks(0)
Quote Reply
Posted: 08 July 2008 at 8:15am |
|
All you should need are:
ON_UPDATE_COMMAND_UI_RANGE ON_COMMAND_RANGE |
|
|
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) |
|
![]() |
|
Pariksh*t
Groupie
Joined: 26 June 2008 Location: India Status: Offline Points: 77 |
Post Options
Thanks(0)
Quote Reply
Posted: 08 July 2008 at 10:54pm |
|
thanx
but for RANGE you should know the 1st and last id
in my case i know 1st id but not the last one as it generates at run time
so the problem is still not resolved.................
![]() do reply.....
![]() |
|
![]() |
|
Smucker
Senior Member
Joined: 02 February 2008 Status: Offline Points: 156 |
Post Options
Thanks(0)
Quote Reply
Posted: 09 July 2008 at 1:53am |
|
Just define an arbitrary maximum; surely 1000 should be more than enough; for example:
#define IDC_DYNAMIC_FIRST 20000 #define IDC_DYNAMIC_LAST 20999 If you need different ranges for different things (I do), just use separate ranges for each. If you need to assign IDs arbitrarily to different functions, use an array of structures indexed by [id - IDC_DYNAMIC_FIRST] to locate a structure that defines what that particular ID does (for example, a call to a named macro). |
|
|
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) |
|
![]() |
|
Pariksh*t
Groupie
Joined: 26 June 2008 Location: India Status: Offline Points: 77 |
Post Options
Thanks(0)
Quote Reply
Posted: 09 July 2008 at 2:03am |
|
hi
here in ur answer u r asuming that there will be maximum 999 ids which will get generate......what if there are more than 999 ids which generates at run time ?
|
|
![]() |
|
Smucker
Senior Member
Joined: 02 February 2008 Status: Offline Points: 156 |
Post Options
Thanks(0)
Quote Reply
Posted: 09 July 2008 at 2:52am |
|
Then make it 10000 rather than 1000. How big of a menu do you think your users can deal with? Are you going to cover the entire screen with toolbar buttons?
If you need that many dynamically assigned IDs, I think you have a bigger problem than a fixed maximum. By using an array indexed by ID as I mentioned, you can reuse IDs of removed items. |
|
|
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) |
|
![]() |
|
Pariksh*t
Groupie
Joined: 26 June 2008 Location: India Status: Offline Points: 77 |
Post Options
Thanks(0)
Quote Reply
Posted: 09 July 2008 at 4:25am |
|
hi
yes i guess this is the last thing that i can do in this situation
but wait.....
in sdi an dmdi applications there is one variable
CFrameWnd::m_bAutoMenuEnable , using this variable with EnableMenuItem() can solve the problem
but my app is dialog based
thanx for help
![]() |
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |