HELP: Simple Check Box 
Author Message
 HELP: Simple Check Box

    I am new to Visual C++ and have version 6.0. Anyway, I am having trouble
changing the state of a check box. Here's a summary:

    Ok when I call the dlg.CheckDlgButton function I get an ASSERT error in
DEBUG build and nothing happens to the check box in RELEASE build. Everything
else works fine including writing text the edit fields, etc. The ASSERT is
related to an hWnd handle or something. I know this is something simple that I
am missing. Do I need to get a hWnd handle or something? If so, how?

Code snippet:

CPortTermDlg dlg;
 m_pMainWnd = &dlg;
 // Put a check in the box
 dlg.CheckDlgButton(IDC_RANGESCAN, 1); // The fails with an ASSERT in DEBUG,
                                                                      // nothing
happens in RELEASE
 int nResponse = dlg.DoModal();

 Thanks in advance for any help.....



Mon, 14 May 2001 03:00:00 GMT  
 HELP: Simple Check Box

Quote:

>     I am new to Visual C++ and have version 6.0. Anyway, I am having trouble
> changing the state of a check box. Here's a summary:

>     Ok when I call the dlg.CheckDlgButton function I get an ASSERT error in
> DEBUG build and nothing happens to the check box in RELEASE build. Everything
> else works fine including writing text the edit fields, etc. The ASSERT is
> related to an hWnd handle or something. I know this is something simple that I
> am missing. Do I need to get a hWnd handle or something? If so, how?

> Code snippet:

> CPortTermDlg dlg;
>  m_pMainWnd = &dlg;
>  // Put a check in the box
>  dlg.CheckDlgButton(IDC_RANGESCAN, 1); // The fails with an ASSERT in DEBUG,
>                                                                       // nothing
> happens in RELEASE
>  int nResponse = dlg.DoModal();

>  Thanks in advance for any help.....

Move the check box operation into the dialog's OnInitDialog function.  At the place where you are doing it the dialog exists as some allocated memory, but that is all it is.  First it needs to create its window and its controls, which happens when you call DoModal.


Mon, 14 May 2001 03:00:00 GMT  
 HELP: Simple Check Box
Hi Edipus,

Quote:

>    I am new to Visual C++ and have version 6.0. Anyway, I am having
trouble
>changing the state of a check box. Here's a summary:
>Code snippet:

>CPortTermDlg dlg;
> m_pMainWnd = &dlg;
> // Put a check in the box
> dlg.CheckDlgButton(IDC_RANGESCAN, 1); // The fails with an ASSERT in
DEBUG,
>                                                                      //

nothing

It's not correct at all.
First, you need initialize your modal dialog (Look at your next code). And
make any initiliazition inside and only inside of dialog box class.

The better way is use initialization of dialog items in the InitDialog()
function.

Quote:
>happens in RELEASE
> int nResponse = dlg.DoModal();

> Thanks in advance for any help.....

Best regards,

Oleg A. Bekhter (Fay)



Tue, 15 May 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help : Any simple method to check the existence of a file

2. Checking the Check Box Status in Viusal C++

3. Check box in dialog won't stay checked

4. Help - Using a member variable associated with a check box

5. HELP: Check Box

6. Help: CListCtrl check box

7. Help: CTreeControl with check boxes question

8. List with columns containing both text and combo boxes / check boxes

9. How to create a check box in a group box label

10. Multiple check boxes in a list control box

11. Display Check box over Group box problem?

12. List Box with Check Boxes

 

 
Powered by phpBB® Forum Software