CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    [RESOLVED] CButton SetCheck problem with Unchecking

    One small problem is heating me up so finally posted here to get the solution. As the thread name, Im trying to Uncheck a Checkbox control with following code.

    Code:
      else if((point.x >= (rcRememPass.left - 4) && point.x <= rcRememPass.right) && (point.y >= rcRememPass.top && point.y <= rcRememPass.bottom))
      {
        if(m_CheckBoxRemem.GetState() == BST_CHECKED)
          m_CheckBoxRemem.SetCheck(0);
        else
          m_CheckBoxRemem.SetCheck(1);
      }
    Above code snippet is from OnLButtonUp(). Whereas else part working good why the if part is failing to uncheck the box ?. Any ideas ?
    ◄◄ hypheni ►►

  2. #2
    Join Date
    Apr 2007
    Posts
    162

    Re: CButton SetCheck problem with Unchecking

    Quote Originally Posted by hypheni View Post
    One small problem is heating me up so finally posted here to get the solution. As the thread name, Im trying to Uncheck a Checkbox control with following code.

    Code:
      else if((point.x >= (rcRememPass.left - 4) && point.x <= rcRememPass.right) && (point.y >= rcRememPass.top && point.y <= rcRememPass.bottom))
      {
        if(m_CheckBoxRemem.GetState() == BST_CHECKED)
          m_CheckBoxRemem.SetCheck(0);
        else
          m_CheckBoxRemem.SetCheck(1);
      }
    Above code snippet is from OnLButtonUp(). Whereas else part working good why the if part is failing to uncheck the box ?. Any ideas ?
    Probably should be using GetCheck() not GetState()

  3. #3
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,641

    Re: CButton SetCheck problem with Unchecking

    Unless I am mistaken, it should be something like:

    Code:
    if(m_CheckBoxRemem.GetState() & BST_CHECKED)
    Nobody cares how it works as long as it works

  4. #4
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: CButton SetCheck problem with Unchecking

    Well, there was some focusing issue I guess. Still I replaced my code with GetCheck() instead of GetState().
    ◄◄ hypheni ►►

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