Cmfcribboncombobox message response

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.