Click to See Complete Forum and Search --> : Calling a function on an event?


dr995
February 1st, 2007, 02:33 AM
Dear all

I have a check box and when the check box gets checked i would like to start this application. The application is external and i am using SHELLEXECUTE.

But i dont know how to do it because the code for the event is inside the form.h header file. If i try and put some more includes that are necesary for the SHELLEXECUTE structure i get compile errors.

private: System::Void checkBox1_CheckedChanged(System::Object * sender, System::EventArgs * e)
{
if(this->checkBox1->Checked == true);
****at this point call a function that will start my external application

Would anyone will be able to help me with that?

Thank you for your time and help.

Sincerely

cilu
February 1st, 2007, 03:05 AM
[ redirected ]

Pravin Kumar
February 1st, 2007, 04:23 AM
Hello,

You will have to handle the WM_COMMAND message of the window, in which the checkbox is placed. Check for messages from the checkbox and take appropriate action depending on its state.

BOOL CCheckDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
if (LOWORD(wParam) == IDC_CHECK)
{
if (((CButton*) GetDlgItem(IDC_CHECK))->GetCheck() == 1)
{
// Changing from unchecked to checked
MessageBox("Unchecked -> Checked");
}
else
{
// Changing from checked to unchecked
MessageBox("Checked -> Unchecked");
}
}
return CDialog::OnCommand(wParam, lParam);
}

It is assumed here that IDC_CHECK is the ID of the checkbox, placed in the window object of type CCheckDlg.

Regards,
Pravin.

dr995
February 1st, 2007, 05:10 PM
Would that work in .Net?

And with the ID of check box you have specified....How to obtain that?

Cheers