MFC's Dynamic Create button

Source: Internet
Author: User

Open vs Create an MFC dialog-based project and dynamically create a button instance in the dialog initialization method:

1> CButton *pmybutton = new CButton ();

2>pmybutton->create (_t ("ButtonName"), ws_child| Ws_vivible_bs_pushbutton,crect (10,20,80,80), This,idc_mybutton);

Compile will prompt Idc_mybutton undefined, at this time open the resource file to find stringtable, add Idc_mybutton

The 3> is recompiled, and the interface displays the style of the button that is worn.

4> Add On_bn_click (ID, method name) message to add a message to the function map of the CPP file

5> Add button The declaration and implementation of the corresponding method Clickmybutton ();

6> specific implementation content is written inside the method.

MFC's Dynamic Create button

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.