Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / September 2007

Tip: Looking for answers? Try searching our database.

Find X,Y on DoubleClick Event on panel with scrolling

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gidi - 30 Sep 2007 22:12 GMT
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...
Peter Duniho - 30 Sep 2007 22:54 GMT
> Hi,
>
[quoted text clipped - 8 lines]
> 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/microsoft.public.dotnet.languages.csharp/browse_t
hread/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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.