Find X,Y on DoubleClick Event on panel with scrolling

G

Guest

Hi,

I've panel in my windows form, and i want to get the exact mouse position
when i double click.
I used:
Point p = this.panel1.PointToClient(Cursor.Position);

but now, if i'm pointing on the top-left corner of the panel i get the
cordinates (0,0), and then, i'm scrolling with the mouse whell, and then i
double click again, on the same corner and i get the same result.
I understand why it happens, my question is, how can i get the exact
cordinates based on the location of the panel and the form.

for example, if my panel size is 40,100 and if my top left corner is 0,0 and
after i'm scrolling i'm actullay pointing on the middle of the panel, so i
want to get 40,50, and then after one more scroll i want to get 40,100...

hope i was clear... :)

Thanks a lot...
 
P

Peter Duniho

Gidi said:
Hi,

I've panel in my windows form, and i want to get the exact mouse position
when i double click.
I used:
Point p = this.panel1.PointToClient(Cursor.Position);

but now, if i'm pointing on the top-left corner of the panel i get the
cordinates (0,0), and then, i'm scrolling with the mouse whell, and then i
double click again, on the same corner and i get the same result.
I understand why it happens, my question is, how can i get the exact
cordinates based on the location of the panel and the form.

The answer is the same as for the last "I have a scrollable panel"
question you asked: you need to handle this yourself based on the
position of the scroll bars in the control.

In case you've forgotten which thread contained the specifics for this
answer already:
http://groups.google.com/group/micr...read/thread/e3aeaf3e706c82b9/2f841df617c6fb2f

By the way, IMHO it's a mistake to use Cursor.Position to determine the
mouse position.

Usually for Click and DoubleClick, you don't need the mouse position.
For those cases where you do, you should get it from the MouseDown event
that goes with the Click or DoubleClick event.

I don't think it's terrible to use Cursor.Position, but it's not the
best way either.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top