1. Add the font and color variables in the dialog box class declaration
Public: cfont m_myfont; // font object colorref m_mycolor; // color object
2. initialize the font and color in the oninitdialog () function of the dialog box initialization function.
// Todo: add additional initialization code m_myfont.createpointfont (150, _ T (" 文 "); m_mycolor = RGB (255, 0,255 );
3. Add the message response function wm_ctlcolor for the dialog box class, and add the code in its message response function onctlcolor ().
Afx_msg hbrush onctlcolor (CDC * PDC, cwnd * pwnd, uint nctlcolor); // message response function declaration
On_wm_ctlcolor () // message ing
Hbrush cxxxdlg: onctlcolor (CDC * PDC, cwnd * pwnd, uint nctlcolor) // message response function implementation {hbrush HBr = cdialog: onctlcolor (PDC, pwnd, nctlcolor ); // todo: change any DC attributes here if (pwnd-> getdlgctrlid () = idc_static_week) {PDC-> SelectObject (& m_myfont ); // set the font PDC-> settextcolor (m_mycolor); // set the color} // todo: return another paint brush return HBr if it is not the required paint brush by default ;}