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.