CMenus : How to use menu handles instead of menu resource ID when needed ?
-
Hi, I show that some CMenu methods, need the ID of the menu that is already created inside the resource manager. But, if the CMenu is created dynamically how do I assign a unique ID for that object ? If that is not possible, then how can I "translate" the menu handle to this unique resource ID so it would compatible with the Win32 API functions ? Regards,
sdancer75
-
Hi, I show that some CMenu methods, need the ID of the menu that is already created inside the resource manager. But, if the CMenu is created dynamically how do I assign a unique ID for that object ? If that is not possible, then how can I "translate" the menu handle to this unique resource ID so it would compatible with the Win32 API functions ? Regards,
sdancer75
-
Hi, I show that some CMenu methods, need the ID of the menu that is already created inside the resource manager. But, if the CMenu is created dynamically how do I assign a unique ID for that object ? If that is not possible, then how can I "translate" the menu handle to this unique resource ID so it would compatible with the Win32 API functions ? Regards,
sdancer75
You can definitely assign
ID
s to dynamically created menu items, see the CMenu::AppendMenu[^] method.THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite
-
You can definitely assign
ID
s to dynamically created menu items, see the CMenu::AppendMenu[^] method.THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite
From MSDN AppendMenu function 7 out of 10 rated this helpful - Rate this topic Appends a new item to the end of the specified menu bar, drop-down menu, submenu, or shortcut menu. You can use this function to specify the content, appearance, and behavior of the menu item. That's correct, but if the menu is a brand new dynamically created popupmenu and I dont want to append it to an existing menu, there is no point to use AppendMenu, right ?
sdancer75
-
From MSDN AppendMenu function 7 out of 10 rated this helpful - Rate this topic Appends a new item to the end of the specified menu bar, drop-down menu, submenu, or shortcut menu. You can use this function to specify the content, appearance, and behavior of the menu item. That's correct, but if the menu is a brand new dynamically created popupmenu and I dont want to append it to an existing menu, there is no point to use AppendMenu, right ?
sdancer75
Not right. When you dynamically create a menu, it has no items: you have to use the
AppendMenu
method to add, at least a menu item to it.THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite
-
You can definitely assign
ID
s to dynamically created menu items, see the CMenu::AppendMenu[^] method.THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite
-
From MSDN AppendMenu function 7 out of 10 rated this helpful - Rate this topic Appends a new item to the end of the specified menu bar, drop-down menu, submenu, or shortcut menu. You can use this function to specify the content, appearance, and behavior of the menu item. That's correct, but if the menu is a brand new dynamically created popupmenu and I dont want to append it to an existing menu, there is no point to use AppendMenu, right ?
sdancer75
-
That's the id of the associated command, which is not the same as resource id. But maybe that is what the OP is really asking for.
You are right, of course (on both the points, I hope).
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite
-
I suspect you are getting your terminology wrong, and as suggested please show the code that you are having problems with, and why you think it needs this id.
Richard MacCutchan wrote:
I suspect you are getting your terminology wrong, and as suggested please show the code that you are having problems with, and why you think it needs this id.
Yes, there was a terminology wrong from my side..... The misunderstanding was done when I tried to initialize a CXTPBrowseButton from Codejock's framework and I needed a resource ID menu but I only create that menu dynamically. The code example I tried to customize is :
m_edit1.Initialize(this, BES_XTP_POPUPMENU, IDR_POPUP);
and is declared like
virtual bool Initialize(CWnd* pParentWnd, DWORD dwBStyle, UINT nMenu = 0, int nSubMenuIndx = 0);
It seems that I dont have an option in this situation to pass an object handle !!!! My worng thoughts was that I just needed an ID just to make an object unique for the internal use of the MFC framework but I didn't thought that it was merely a unique RESOURCE ID. Thanks for clarifying this..... I just dazed and confused.
sdancer75
-
Richard MacCutchan wrote:
I suspect you are getting your terminology wrong, and as suggested please show the code that you are having problems with, and why you think it needs this id.
Yes, there was a terminology wrong from my side..... The misunderstanding was done when I tried to initialize a CXTPBrowseButton from Codejock's framework and I needed a resource ID menu but I only create that menu dynamically. The code example I tried to customize is :
m_edit1.Initialize(this, BES_XTP_POPUPMENU, IDR_POPUP);
and is declared like
virtual bool Initialize(CWnd* pParentWnd, DWORD dwBStyle, UINT nMenu = 0, int nSubMenuIndx = 0);
It seems that I dont have an option in this situation to pass an object handle !!!! My worng thoughts was that I just needed an ID just to make an object unique for the internal use of the MFC framework but I didn't thought that it was merely a unique RESOURCE ID. Thanks for clarifying this..... I just dazed and confused.
sdancer75