[英]How to set checkbox as check by default in an MFC dialog application?
I'm trying to set some check boxes as checked by default in my MFC dialog when it runs. 我试图在运行MFC对话框时将某些复选框设置为默认选中状态。
I have created a CButton
variable for the check box called m_check
. 我为名为m_check
的复选框创建了一个CButton
变量。 Next I added m_check.SetCheck
in OnInitDialog
. 接下来,我在OnInitDialog
添加了m_check.SetCheck
。
BOOL CModelDlg::OnInitDialog()
{
....
m_check.SetCheck;
....
The error always appears: 该错误始终出现:
Error: a pointer to a bound function may only be used to call the function. 错误:指向绑定函数的指针只能用于调用该函数。
I'm not sure what this error means. 我不确定这个错误是什么意思。 Any help would be appreciated. 任何帮助,将不胜感激。 Thank you! 谢谢!
I figured it out in case anybody wants to know. 我想通了,以防万一有人想知道。 Add this in OnInitDialog
: 在OnInitDialog
添加它:
CButton* pBtn = (CButton*) GetDlgItem(IDC_XXXXXX);
pBtn->SetCheck(1);
I think you forgot parenthesis in the SetCheck function. 我认为您在SetCheck函数中忘记了括号。 It should be 它应该是
BOOL CModelDlg::OnInitDialog() {
....
m_check.SetCheck(TRUE);
....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.