how to grey check box in visual c++ 5.0

I would like to, when loading dialog box (property page) after checking status of check box to, if it is checked to grey it to ptevent editing. (once checked, can not be unchecked any more)

Compailer is visual c++ 5.0 OS windows NT

mzdravkoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

inprasCommented:
Hi
Try doing this
//Explicitly checking check box
       m_Check.SetCheck(1);
//If checked then disable
      if( m_Check.GetCheck())
      {
            m_Check.EnableWindow(FALSE);
      }

Regards
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mzdravkoAuthor Commented:
Hi Inpras,

I have already done that. I just wanted to ask for a way ti amke it grey. It is already disabled with EnableWindow(FALSE) but it is still in white color. I need to be grey to show user that it can not be changed.

Sorry for missunderstanding

regards
0
SDUCommented:
Try this:
Note, I don't know the RGB for grey but that should not be a problem to find

Add a member variable like this
   CBrush                  m_WhiteBrush;

in your OnInitDialog,
   m_WhiteBrush.CreateSolidBrush(RGB(255,255,255));   // This brusk is white


then add this method
HBRUSH YourClass::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
      HBRUSH hbr = YourBaseClass::OnCtlColor(pDC, pWnd, nCtlColor);

   if ( pWnd->GetDlgCtrlID() == IDC_YOUR_CTL_ID )
   {
      if ( nCtlColor == CTLCOLOR_STATIC )
      {
         pDC->SetBkColor(RGB(255,255,255));  // This background is white
         hbr = m_WhiteBrush;
      }
   }

   return hbr;
}

It worked for me when I wanted to have a readonly edit box with a white background
0
inprasCommented:
Hi mzdravko

1 Create a brush with grey color


2 map the OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)

in this fn write the fol code
      if (pWnd->GetDlgCtrlID() == IDC_CHECK1)      
      {
//You can check here for the getcheck
if(m_Check.GetCheck())
{
            pDC->SetBkColor("Your color");
            hbr = m_WtB;
}
      }
and to prevent user to change it
//in onclick event
3 void CCheckDlg::OnCheck1()
{
      if( !m_Check.GetCheck())
      {
            m_Check.SetCheck(TRUE);
      }
}
Hope this helps

Regards
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.