in Education by
How can one get the coordinates of a mouse click inside a panel? For instance I want to be able to put pixels wherever I click with my mouse. I can handle the drawing part, but I don't know how to make my program to listen for that click event, and how to get x/y coordinates of it so it can draw in right place. I never saw a similar piece of code, and I was unable to find relevant information with google so I can't show any code "how I tried to achieve that" because I simply didn't :/ I have no clue how to start. I am probably searching the wrong keywords, but I am sure that it can be done. EDIT: Thank you all JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
The Click event is not the right choice. It can be generated both by the mouse and the keyboard so it doesn't pass the mouse position. A button for example can be clicked by pressing the space bar. This of course won't happen for a panel. Simply use the MouseUp event instead. Check the passed e->Button property. A panel is not the good choice either btw. It is not double-buffered so it is likely to start flickering when the drawing gets intricate. It doesn't redraw properly when the size changes. A PictureBox doesn't have these problems. Just treat it like the panel, implement its Paint event and don't set the Image property.

Related questions

0 votes
    I'm translating a library written in C++ to C#, and the keyword 'union' exists once. In a struct ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    I'm translating a library written in C++ to C#, and the keyword 'union' exists once. In a struct ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    I'm trying to PInvoke into this C++ library function: int Initialize(Callback* callback); struct Callback { ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 21, 2022 in Education by JackTerrance
0 votes
    I'm trying to PInvoke into this C++ library function: int Initialize(Callback* callback); struct Callback { ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    In my dll there is a method that I want to export. //Works: extern "C" __declspec(dllexport) // ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    In my dll there is a method that I want to export. //Works: extern "C" __declspec(dllexport) // ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    In my dll there is a method that I want to export. //Works: extern "C" __declspec(dllexport) // ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    In my dll there is a method that I want to export. //Works: extern "C" __declspec(dllexport) // ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I'm having an annoying problem registering a javascript event from inside a user control within a formview ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 13, 2022 in Education by JackTerrance
0 votes
    I found found several question's answers similar to this, I tried some of them, but no luck. May ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I found found several question's answers similar to this, I tried some of them, but no luck. May ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 8, 2022 in Education by JackTerrance
0 votes
    I'm attempting to automate a payment system, where the "Pay with PayPal" button is within an iFrame. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I have been developing a webpage which uses n number of dropdownlists which are binding dynamically inside a ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 18, 2022 in Education by JackTerrance
0 votes
    I've got a Sharepoint WebPart which loads a custom User Control. The user control contains a Repeater which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 22, 2022 in Education by JackTerrance
0 votes
    I've got a Sharepoint WebPart which loads a custom User Control. The user control contains a Repeater which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
...