Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

I have created a CButton variable for the check box called m_check. Next I added m_check.SetCheck in OnInitDialog.

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!

like image 984
m170115 Avatar asked Jan 27 '26 01:01

m170115


2 Answers

I figured it out in case anybody wants to know. Add this in OnInitDialog:

CButton* pBtn = (CButton*) GetDlgItem(IDC_XXXXXX);
pBtn->SetCheck(1);
like image 149
m170115 Avatar answered Jan 29 '26 14:01

m170115


I think you forgot parenthesis in the SetCheck function. It should be

BOOL CModelDlg::OnInitDialog() {
....
m_check.SetCheck(TRUE);
....
like image 29
tozzio Avatar answered Jan 29 '26 16:01

tozzio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!