CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 1999
    Posts
    22

    I need help with checkbox

    I had two checkboxes in my dialog. I did use ClassWizard to attaching two functions for those checkboxes in my Dlg.cpp file. However, I don't know where I shall put the code (in.cpp or dlg.cpp)for controling those checkboxes when the user click on one of checkboxes? For example, one of my checkboxes was named "top". when the user click on the checkbox, the program will read through the file the user enter, and pick up data related with "top" checkbox. I really want to know where I can put those code to execute those works, after the user click on "top" button.
    Anyone can help me out?
    thank you.


  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: I need help with checkbox

    Usually, the action does not start when the user clicks the checkbox. The real work starts when the user presses "Go", "Start", "Ok", or some button that lets the processing start. This is good UI design.

    The place to do the processing would be in the OnOk(), OnStartProcessing(), or some function that is called when the user selects "Start". In the processing function, you would determine what checkbox has been checked, and then set up what you need to do.

    Regards,

    Paul McKenzie



  3. #3
    Join Date
    May 1999
    Location
    Houston - TX - US
    Posts
    29

    Re: I need help with checkbox

    Hi,
    You can put all those code in ON_BN_CLICKED for that check box button in the ur dialod derived class.

    Hope this helps U.
    Good Luck.
    Yash.


  4. #4
    Join Date
    Apr 1999
    Posts
    22

    Re: I need help with checkbox

    Thank you for your help. Actually, I already created functions for both of checkboxes. I just don't know how to make the program to response the user's action, when the user clicks on one of boxes. I include the functions of checkboxes here. Do you have any good idea about my problem?
    thank you for you help.
    void CDesignDlg::OnTop()
    {

    }

    void CDesignDlg::OnBottom()
    {
    // TODO: Add your control notification handler code here

    }
    I have two check boxes, one is for "top" and the
    other is for "bottom." I have OnTop() to handle when the user clicks the
    "top" box, and I have OnBottom() to handle when the user clicks the
    "bottom" box. when the user clicks on "top" box, the program will doing something, and when the user clicks on "bottom" box, the program will doing something else.



  5. #5
    Join Date
    Apr 1999
    Posts
    27,449

    Re: I need help with checkbox

    First, Check out CButton::GetCheck() to determine the state of the checkbox and CButton::SetCheck() to set the state. You will need to get the CWnd of the checkbox control for this to work. This can be done by calling (CButton *)GetDlgItem(Id), where Id is the identifier that you gave the control when you created the checkbox.

    Second, you need to setup handlers for each checkbox control. You would do this through class wizard.


    Regards,

    Paul McKenzie


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured