Click here to Skip to main content
15,892,809 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
PraiseRe: problem in solving "C4996" error Pin
VISWESWARAN199811-Dec-15 0:39
professionalVISWESWARAN199811-Dec-15 0:39 
AnswerRe: problem in solving "C4996" error Pin
Richard MacCutchan10-Dec-15 21:57
mveRichard MacCutchan10-Dec-15 21:57 
PraiseRe: problem in solving "C4996" error Pin
VISWESWARAN199811-Dec-15 0:40
professionalVISWESWARAN199811-Dec-15 0:40 
QuestionPassing double pointer to function Pin
elelont29-Dec-15 21:49
elelont29-Dec-15 21:49 
AnswerRe: Passing double pointer to function Pin
Richard MacCutchan9-Dec-15 22:29
mveRichard MacCutchan9-Dec-15 22:29 
QuestionResize a Dialog Box (MDI-Application) Pin
Schehaider_Aymen7-Dec-15 23:05
Schehaider_Aymen7-Dec-15 23:05 
AnswerRe: Resize a Dialog Box (MDI-Application) Pin
Jochen Arndt7-Dec-15 23:29
professionalJochen Arndt7-Dec-15 23:29 
GeneralRe: Resize a Dialog Box (MDI-Application) Pin
Schehaider_Aymen9-Dec-15 2:30
Schehaider_Aymen9-Dec-15 2:30 
QuestionIssue with CFolderPickerDialog Pin
Prasanth.outofboxt7-Dec-15 18:50
Prasanth.outofboxt7-Dec-15 18:50 
AnswerRe: Issue with CFolderPickerDialog Pin
Richard MacCutchan7-Dec-15 22:15
mveRichard MacCutchan7-Dec-15 22:15 
GeneralRe: Issue with CFolderPickerDialog Pin
Prasanth.outofboxt14-Dec-15 21:39
Prasanth.outofboxt14-Dec-15 21:39 
QuestionSplitting Video Pin
savitap6-Dec-15 23:37
savitap6-Dec-15 23:37 
SuggestionRe: Splitting Video Pin
Richard MacCutchan7-Dec-15 0:33
mveRichard MacCutchan7-Dec-15 0:33 
Questionbinary trees Pin
Amr.Mohammad875-Dec-15 4:09
Amr.Mohammad875-Dec-15 4:09 
QuestionRe: binary trees Pin
CPallini5-Dec-15 4:25
mveCPallini5-Dec-15 4:25 
AnswerRe: binary trees Pin
Amr.Mohammad875-Dec-15 5:36
Amr.Mohammad875-Dec-15 5:36 
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 

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.