user3112790
user3112790

Reputation: 1

VC++ 2010 - if button1 is clicked

I have a little problem with my script. I would like to check if the button1 was clicked in another event (pictureBox_Click). How could I do it?

It should works like this:

private: System::Void pictureBox_Click(System::Object^  sender, System::EventArgs^  e) {

if (button1 is clicked=true)
{
  code;
  code;
  code;
}

if (button2 is clicked=true)
{
  code;
  code;
  code;
}

}

I will be grateful for help.

Upvotes: 0

Views: 563

Answers (1)

Reed Copsey
Reed Copsey

Reputation: 564791

You'd need to store when the button was clicked in a variable. Add an event handler for the button click events, and store the values.

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e)
{
    buttonClicked = true;
}
private: System::Void pictureBox_Click(System::Object^  sender, System::EventArgs^  e)
{
     if (buttonClicked)
     {
         // ... 

Upvotes: 1

Related Questions