I have a panel called panel1.

What I wonder how it is possible to do is that when you click the mouse on the location 304,369 in the panel, I want to display a messageBox.

How would that be possible to identify the location in code ?

private: System::Void panel1_MouseDown(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
{

if( ??? )
{
    MessageBox::Show("You clicked Location 304,369 in the panel  
                                      with the mouse !");

}

}

Recommended Answers

All 2 Replies

You get where the click came from via the e parameter. e->X gives you the x coordinate and e->Y the y. It's going to be tricky to get your user to grab the exact point I think, you may want to use a (small) range.

I understand, I did set an area where the user can press as you said... that worked fine:

private: System::Void panel1_MouseDown(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) 
{
	 if( e->X >= 304 && e->X <= 346 && e->Y >= 369 && e->Y <= 392 )
	 {
		 MessageBox::Show("Clicked Area");
	 }
}

Thank you...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.