Click here to Skip to main content
15,886,519 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: binary trees Pin
CPallini5-Dec-15 10:00
mveCPallini5-Dec-15 10:00 
GeneralRe: binary trees Pin
Amr.Mohammad876-Dec-15 0:49
Amr.Mohammad876-Dec-15 0:49 
GeneralRe: binary trees Pin
Amr.Mohammad876-Dec-15 0:49
Amr.Mohammad876-Dec-15 0:49 
GeneralRe: binary trees Pin
CPallini6-Dec-15 3:47
mveCPallini6-Dec-15 3:47 
GeneralRe: binary trees Pin
Amr.Mohammad8724-Dec-15 20:14
Amr.Mohammad8724-Dec-15 20:14 
GeneralRe: binary trees Pin
CPallini25-Dec-15 8:43
mveCPallini25-Dec-15 8:43 
QuestionService only works once useing Pin
derek-20084-Dec-15 12:58
derek-20084-Dec-15 12:58 
QuestionAdding a new button to and existing CMFCRibbonBar "tab" Pin
S.T.K4-Dec-15 6:22
S.T.K4-Dec-15 6:22 
I have a large legacy application being updated to use newer CMFCRibbonBar. This application is large and the creation of the CMFCRibbonBar involves converting a lot of legacy icons and menu structures so is a bit complicated to extract and post here. I will add further details as people request them.

But the general gist is:
The application works fine and has a valid and working CMFCRibbonBar.
That ribbon bar has 11 categories across the top. With hundreds of panel buttons and menu buttons.
I have also recreated the same structure using CMFCRibbonButton to create a quick old style menu system which has been added to the m_wndRibbonBar via the AddToTabs. This give me a working drop down menu in the top right had corner. I believe there is a general web example which people may be familiar with which create a “window style” dropdown where you to change the MFC window manager style from windows 2000 through to windows7.
My menu is created from scratch at application startup and is not taken from a menu resource as this application predates this structure.
I use commands like the following to construct this menu:
pQuickMenu = new CMFCRibbonButton(ID_MENU++,TEXT("Quick Menu"),-1,-1,0);

pQuickButton = new CMFCRibbonButton(ID_MENU++,wMenuCommand,-1,-1,0);
pQuickMenu->AddSubItem(pQuickButton,-1);


m_wndRibbonBar.AddToTabs(pQuickMenu);

The problem I am having is dynamically adding new buttons to this quick menu at a later date.
When I originally created this quick menu I kept the pointer to this structure that was used to add to the ribbon. Therefore I am able to add to the quickmenu.

pQuickBut = new CMFCRibbonButton(ID_MENU,wMenuCommand,NULL,0,hSmall,0,0);
pQuickMenu->AddSubItem(pQuickBut,ilp);

If I add a new button to the existing stored top level quick menu using the stored pQuickMenu pointer, the button does appear. The text is correct and the button is selectable.
Except that the button is not operated upon when clicked.

If I add the button to the m_wndRibbonBar instead then it works so I know there is a valid command handler.

Down within the MFC code, clicking on my new quick access menu enters a routine called:
CMFCRibbonBaseElement::NotifyCommand(BOOL bWithDelay)
This extracts the command id correctly.
UINT uiID = GetNotifyID();
But it then checks for a valid ribbonbar.
CMFCRibbonBar* pRibbonBar = GetTopLevelRibbonBar();
This fails and returns a null pointer. Thus the command processing structure is exited.

As a test, if I call m_wndRibbonBar.AddToTabs(pQuickMenu) again for a second time adding the same menu to the RibbonBar a second time, then the origial becomes corrupt but the new command does work.
I am therefore assuming (guessing) that when the AddToTabs is called there is a ribbon handle stored with the commands. When I add directly to the existing structure after the original call to AddToTabs, a valid ribbon handle is not happening.

In the old style of things I would detach my quick menu, update it and then reattach. But I do not know how to do this (or even if it is nessesary) in the new CMFC classes.

The command: m_wndRibbonBar.removeallfromtabs(); deletes the whole of my pQuickMenu structure so I can not then add to it.

Is there anyone who can help explain how to dynamicaly add new buttons to an exising menu that has been added to a ribbonbar tab.
Any help appreciated.

Thanks.
Steve.

-- modified 7-Dec-15 4:13am.
GeneralRe: I now have an MFC example project that highlights my issue. Pin
S.T.K6-Dec-15 23:25
S.T.K6-Dec-15 23:25 
GeneralRe: Adding a new button to and existing CMFCRibbonBar "tab" Pin
S.T.K10-Dec-15 2:37
S.T.K10-Dec-15 2:37 
AnswerRe: Adding a new button to and existing CMFCRibbonBar "tab" Pin
S.T.K17-Dec-15 23:55
S.T.K17-Dec-15 23:55 
QuestionC++ - Accessibility of object after deletion. (illegal still working), why this is happening? Pin
Satish Shankar Jagtap3-Dec-15 23:54
Satish Shankar Jagtap3-Dec-15 23:54 
AnswerRe: C++ - Accessibility of object after deletion. (illegal still working), why this is happening? Pin
CPallini4-Dec-15 0:17
mveCPallini4-Dec-15 0:17 
AnswerRe: C++ - Accessibility of object after deletion. (illegal still working), why this is happening? Pin
Jochen Arndt4-Dec-15 1:45
professionalJochen Arndt4-Dec-15 1:45 
GeneralRe: C++ - Accessibility of object after deletion. (illegal still working), why this is happening? Pin
CPallini4-Dec-15 9:18
mveCPallini4-Dec-15 9:18 
QuestionFloating point conversion Pin
Still learning how to code3-Dec-15 22:19
Still learning how to code3-Dec-15 22:19 
AnswerRe: Floating point conversion Pin
Michael_Davies3-Dec-15 22:29
Michael_Davies3-Dec-15 22:29 
GeneralRe: Floating point conversion Pin
Richard MacCutchan3-Dec-15 22:40
mveRichard MacCutchan3-Dec-15 22:40 
GeneralRe: Floating point conversion Pin
Michael_Davies4-Dec-15 21:08
Michael_Davies4-Dec-15 21:08 
GeneralRe: Floating point conversion Pin
Richard MacCutchan4-Dec-15 22:12
mveRichard MacCutchan4-Dec-15 22:12 
AnswerRe: Floating point conversion Pin
Richard MacCutchan3-Dec-15 22:39
mveRichard MacCutchan3-Dec-15 22:39 
AnswerRe: Floating point conversion Pin
Jochen Arndt3-Dec-15 23:10
professionalJochen Arndt3-Dec-15 23:10 
GeneralRe: Floating point conversion Pin
Still learning how to code5-Dec-15 0:29
Still learning how to code5-Dec-15 0:29 
AnswerRe: Floating point conversion Pin
CPallini3-Dec-15 23:30
mveCPallini3-Dec-15 23:30 
GeneralRe: Floating point conversion Pin
k50544-Dec-15 4:21
mvek50544-Dec-15 4:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.