Solved

BS_AUTOCHECKBOX

Posted on 1998-04-16
2
938 Views
Last Modified: 2008-02-01
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.

Thanks
Randy

BEGIN_MESSAGE_MAP( CWindow, CFrameWnd )
      ON_BN_CLICKED(IDC_BUTTON2, HandleButton2)      

END_MESSAGE_MAP()

// Handle the r_cont button
void CWindow::HandleButton2()
{
         char x_dir[ ] = "on";
        SetDlgItemText(IDC_RESULT5,x_dir);
}

0
Comment
Question by:RandyG
2 Comments
 
LVL 6

Accepted Solution

by:
WxW earned 50 total points
ID: 1184341
In your function , you can use the ::SendMessage as follows :

int x = ::SendMessage(hWndControl,BM_GETCHECK,0,0);
if (x == 0)
{ // NOT checked code }
else
{ // 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);
0
 

Author Comment

by:RandyG
ID: 1184342
Once again this service is great.

WxW's answer was very prompt and helpful.

Thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question