If you select different items on cmfcribboncombobox, you should respond
On_cbn_selchange
But cmfcribboncombobox in the functional package of vs2008sp1 does not seem to respond to this message. The following describes
Cmfcribboncombobox dynamic establishment, binding, prompt, message response:
First, in mainfrm. cpp:
Cmfcribboncombobox * pcombosimple2 = new cmfcribboncombobox (id_language, false, 75, _ T ("syntax coloring"), 3 );
Pcombosimple2-> additem (_ T ("ADA "));
Pcombosimple2-> selectitem (0 );
Ppanelstyle-> Add (pcombosimple2); // ppanelstyle is cmfcribbonpanel
Then: Create a # define id_language 61447 in resource. h.
Next, add a prompt message "id_language" to the string table of the RC resource file. This is the color of the language/n style"
Finally, define a message afx_msg void onselectlanguage () in the header file of C * view ();
Bind the message on_command (id_language, onselectlanguage) to the implementation file of C * view)
The message function is implemented below:
Void C * view: onselectlanguage ()
{
// Todo: add the command handler code here
Cmfcribbonbar * pribbon = (cmainframe *) gettoplevelframe ()-> getribbonbar ();
Assert_valid (pribbon );
Cmfcribboncombobox * psizecombo = dynamic_downcast (cmfcribboncombobox, pribbon-> findbyid (id_language ));
If (psizecombo = NULL)
{
Return;
}
Afxmessagebox (psizecombo-> getedittext ());
}
Well, now compile and run the program. After selecting an item in the combo box, the name of this item will pop up.