How to make a common button valid or invalid

Source: Internet
Author: User
The control of this button status is different from the control of the button status on the toolbar;
Assume that there is a button resource with ID idc_button_deletemap on a dialog box, And the dialog box class of this dialog box has been created. The effect to be achieved is: if one of the items in the map list is selected, the delete button is valid; otherwise, the button is invalid;
Interface 1:

Figure 1
Choose View> classwizard from the menu to open the MFC wizard, select the member variables label, select class as the class in the dialog box, select idc_button_deletemap, and click the addvariable button, add a variable named m_deletebutton, category is control, and type is cbutton for this ID;
The remaining work is relatively simple. Add the following to the map list nm_setfocus Event Response Function: Code : 1 Void Cmapviewerdialog: onsetfocustreemaptree (nmhdr * Pnmhdr, lresult * Presult)
2 {
3 // Todo: add your control notification handler code here
4 If (M_maptree.getselecteditem () ! = Null)
5 M_deletebutton.enablewindow ();
6 Else
7 M_deletebutton.enablewindow (false );
8 * Presult =   0 ;
9 }

In this case, OK.

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.