Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am wanting to show a CMFCButton in a pressed state along the lines of this post here:
CMFCButtons - does anyone really use these?

I have a similar motivation for using them (image and tooltip support out of the can), but also want to show this 'pressed' state, similar to how in the way that a CButton checkbox (ie ICheckEditor in designer, BS_AUTOCHECKBOX) can be turned into a pushbutton using the 'Push Like' attribute in designer (BS_PUSHLIKE).

It seems that using the base class method
C++
CButton::SetCheck(BST_CHECKED);

does not make it appear pressed like it would if using a regular CButton.

I have also tried using the CMFCButton::SetCheckedImage() method, but can't seem to make the appearance change.

Any ideas would be appreciated. Thanks.
Posted
Comments
Kyudos 23-Nov-15 19:14pm    
Did you figure this out? I have the same issue...
Edit:
...OK I Found the sample that shows how :)
DavidCarr 4-Dec-15 21:05pm    
Pls post the link here to the sample that shows how for others.

1 solution

This problem was resolved.

I had created a button in the dialog and was trying to just set it up as a CMFCButton. This means that in the Resource Editor, this appears as a 'IDC_MYCONTROL (Button Control) IButtonEditor' (as shown in the top DDL in the Properties pane). It was appearing in the RC as:
PUSHBUTTON      "My Caption",IDC_MYCONTROL,7,100,54,14


What needs to happen is to delete the button from the dialog, and drag on a checkbox control from the toolbox, appearing as a 'IDC_MYCONTROL (Check-box Control) ICheckEditor' in the Properties pane. Then set the 'Appearance | Push Like' attribute to True. Within the code, this can now be set up as a CMFCButton with the corresponding BEGIN_MESSAGE_MAP entry and DoDataExchange():
DDX_Control(pDX, IDC_MYCONTROL, m_chkMFCButton);


In terms of the RC, it now appears as:
CONTROL        "My Caption",IDC_MYCONTROL,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | WS_TABSTOP,7,100,54,14


Last but not least, it is now possible to have 6 images represent the single CMFCButton if you want it to be image based:
C++
CMFCButton::SetImage()
CMFCButton::SetCheckedImage()

where the latter function defines the appearance of the button when checked/pushed in for normal, hot, and disabled. As well, the base class CButton::SetCheck() works.

Sorry I didn't reply faster Kyudos.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900