I use a panel and if the user Leftclicks an area with the mouse, I am trying to set the variable LeftRightClick to "Left" and the same for rightclick, "Right".
Then I call the button43_MouseDown event to show the correct MessageBox, depending on if it was a leftClick or RightClick.
When doing this the messageBox: MessageBox:: Show("LeftClick");
is always shown even that a rightclick was made.
I wonder why this is happening ?
String^ LeftRightClick; //Global Variable
private: System::Void panel1_MouseDown(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e)
{
if( e->Button == System::Windows::Forms::MouseButtons::Left )
{
if( e->X >= 304 && e->X <= 346 && e->Y >= 369 && e->Y <= 392 )
{
LeftRightClick = "Left";
}
}
if( e->Button == System::Windows::Forms::MouseButtons::Right )
{
if( e->X >= 304 && e->X <= 346 && e->Y >= 369 && e->Y <= 392 )
{
LeftRightClick = "Right";
}
}
button43_MouseDown(nullptr, nullptr);
}
private: System::Void button43_MouseDown(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e)
{
if( LeftRightClick == "Left" )
{
MessageBox::Show("LeftClick");
}
if( LeftRightClick == "Right" )
{
MessageBox::Show("RightClick");
}
}