如何将CMFCButton显示为按下/检查? [英] How to show CMFCButton as pressed/checked?
问题描述
我想在此帖子的行中按下状态显示CMFCButton:
CMFCButtons - 有没有人真的使用过这些?
我有类似的动机使用它们(图片和can)支持工具提示支持,但也希望显示这种按下状态,类似于使用推送类似将CButton复选框(即设计器中的ICheckEditor,BS_AUTOCHECKBOX)转换为按钮的方式设计师中的属性(BS_PUSHLIKE)。
似乎使用基类方法
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
CButton::SetCheck(BST_CHECKED);
不会像使用普通的CButton那样使其显示为按下。
我也尝试过使用CMFCButton :: SetCheckedImage()方法,但似乎无法改变外观。
任何想法都会欣赏d。谢谢。
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.
推荐答案
此问题已解决。
我在对话框中创建了一个按钮,试图将其设置为CMFCButton。这意味着在资源编辑器中,它显示为IDC_MYCONTROL(按钮控件)IButtonEditor(如属性窗格中的顶部DDL所示)。它出现在RC中:
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
需要做的是从对话框中删除按钮,然后从工具箱中拖出一个复选框控件,在属性窗格中显示为IDC_MYCONTROL(复选框控件)ICheckEditor。然后设置'外观|将Like'属性推送到True。在代码中,现在可以将其设置为具有相应BEGIN_MESSAGE_MAP条目和DoDataExchange()的CMFCButton:
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);
就RC而言,它现在显示为:
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
最后但并非最不重要的是,如果你想要的话,现在可以有6个图像代表单个CMFCButton它是基于图像的:
Last but not least, it is now possible to have 6 images represent the single CMFCButton if you want it to be image based:
CMFCButton::SetImage()
CMFCButton::SetCheckedImage()
其中后一个函数定义在检查/推入正常,热和禁用时按钮的外观。同样,基类CButton :: SetCheck()可以工作。
对不起,我没有快速回复Kyudos。
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.
这篇关于如何将CMFCButton显示为按下/检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!