I would like to get the AUTOCHECKBOX Button to perform one task when Checked and yet another when Unchecked.

The following peice of my program writes "on" to a result window when it is clicked on. I would like for it to write "off" to the same result window when it is clicked off.

I would appreciate any help.


      ON_BN_CLICKED(IDC_BUTTON2, HandleButton2)      


// Handle the r_cont button
void CWindow::HandleButton2()
         char x_dir[ ] = "on";

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.

In your function , you can use the ::SendMessage as follows :

int x = ::SendMessage(hWndControl,BM_GETCHECK,0,0);
if (x == 0)
{ // NOT checked code }
{ // Checked Code }

You must provide the handle of the control , and I do not know how MFC does it , OWL uses the HWindow member for the parent window , so you can use ::GetDlgItem(HWindow,Item_Id);

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
RandyGAuthor Commented:
Once again this service is great.

WxW's answer was very prompt and helpful.

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.