Last updated:
22. July 2001

User Interface Programming

(Start main menu) Home ­ Articles ­ Book ­ Resources (End main menu)

Default But­ton Code Fragment: Listing 1


(Start sub-menu)

Java

User Interface Programming Column

Features

Tech Tips

Reviews

Code Archive


Range Slider

Splitter Controls and Dialog Resizing


 

Feedback…

My blog »

(End sub-menu)

//
// Disabling and Re-enabling a Default But­ton:
//
BEGIN_MESSAGE_MAP(TestDialog, CDialog)
//{{AFX_MSG_MAP(TestDialog)
ON_EN_SETFOCUS(IDC_MULTILINE, OnSetfocusMultiline)
ON_EN_KILLFOCUS(IDC_MULTILINE, OnKillfocusMultiline)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
 
//////////////////////////////////////////////
// TestDialog mes­sage handlers
// The member _defButton is of class CButton.
 
void TestDialog::OnSetfocusMultiline() {
 
    SetDefID( 0 ); // sends DM_SETDEFID
    _defButton.SetButtonStyle(
        _defButton.GetButtonStyle() & ~BS_DEFPUSHBUTTON );
}
 
void TestDialog::OnKillfocusMultiline() {
 
    SetDefID( IDC_OK ); // sends DM_SETDEFID
    _defButton.SetButtonStyle(
        _defButton.GetButtonStyle() | BS_DEFPUSHBUTTON );
}
 
// end of file

(Start bottom menu)

TopHomeArticlesBookResources
Win­dows De­vel­oper Maga­zineR&D BooksCMP Books
Amazon.comAmazon.co.ukContact Petter Hesselberg

(End bottom menu)

Back to Article