Subclass a Checkbox

I want to disable using the mouse to check a checkbox.

I ran across this:

      // Call the check box window procedure first
      lRet = CallWindowProc(lpCheckProc, hWnd, wMessage, wParam,

      // If lParam points to an MSG structure
      if (lParam)
         lpmsg = (LPMSG)lParam;
         if (lpmsg->message == WM_CHAR)
            if (lpmsg->wParam == 'x' || lpmsg->wParam == 'X')
               // Select the check box when user presses "X"
               SendMessage(hWnd, BM_SETCHECK, TRUE, 0);
               lRet |= DLGC_WANTMESSAGE;
            else if (lpmsg->wParam == 'o' || lpmsg->wParam == 'O')
               // Clear the check box when user presses "O"
               SendMessage(hWnd, BM_SETCHECK, FALSE, 0);
               lRet |= DLGC_WANTMESSAGE;
      return lRet;

which appears to be on the right track. But the mouse will still work I assume.

This is in a dialog, using win32. Can anyone help me get this to work?


Ps. Before anyone gets into usability issues, I am only tackling this to see if I *could*. Just studying, this won't be in production. :)
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Dariusz DziaraProgrammerCommented:
I guess that checking, unchecking checkbox (by using mouse) is implemented by handling mouse messages like WM_LBUTTONDOWN so if you want to change it you should replace such handler by your own. For example do nothing in WM_LBUTTONDOWN for checkox.
edvinsonAuthor Commented:
Ok good start! Could you show me an example of 'doing nothing' with it? I am fairly new.
Dariusz DziaraProgrammerCommented:
  return 0;        // means that application processed message

I hope this is enough.

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
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

From novice to tech pro — start learning today.