mfc - Disable visual style for a single CButton -


if create normal cbuttons this:

button visual styles enabled

i accidentally created older looking buttons when did following:

class cclickbutton : public cbutton {     afx_msg int oncreate (lpcreatestruct lpcs);     declare_dynamic(cclickbutton);     declare_message_map(); };  implement_dynamic(cclickbutton, cbutton);  begin_message_map(cclickbutton, cbutton)     on_wm_create() end_message_map()  int cclickbutton::oncreate (lpcreatestruct lpcs) {     return 0; } 

button older look

now create buttons in style. (because want add bitmap. , when using style, give visual feedback of getting 'pushed down'. new style tints background blue , hidden bitmap on top of button. alternative question be, if there easy way tint image when button gets pressed.)

what proper way tell mfc create kind of buttons? omitting the oncreate message base class feels wrong me. , not sure if leads other side effects not aware of yet.

i found information on how change visual style whole program. want change selected buttons.

visual styles can enabled , disabled on per-window basis. msdn provides information on how turn off visual styles:

you can turn off visual styles control or controls in window calling setwindowtheme function follows:

setwindowtheme(hwnd, l" ", l" "); 


to implement in mfc cbutton-derived class, put code in oncreate-handler:

int cclickbutton::oncreate( lpcreatestruct lpcs ) {     ::setwindowtheme( m_hwnd, l" ", l" " );     return cbutton::oncreate( lpcs ); } 


if using dialog resource build gui , attach cclickbutton existing standard button control using ddx_control function after dialog (and controls) have been created, oncreate-handler not called. specific scenario have turn off visual styles @ later point. ideal candidate overriding virtual presubclasswindow method:

void cclickbutton::presubclasswindow() {     ::setwindowtheme( m_hwnd, l" ", l" " );     cbutton::presubclasswindow(); } 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -