473,385 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Need to track mouse cords in order to move a Panel object

Jay
I need to be able to move a Panel on a windows Form at run time using
the mouse. I have tried adding a MouseDown event handler to the Panel
and then within the MouseDown handler adding a MouseMove event to the
Panel and then setting the Panel's Location to a new Point(x, y) with
x and y set to the mouse's x and y, but this does not work because the
MouseDown event of Panel only sends the cords of the mouse within that
Panel. I need to be able to move the Panel within the Form and need to
get the cords of the mouse within the Form in order to set the Panel's
Location.

I've also tried adding a MouseMove event to the Form when the Panel's
MouseDown event is called and then setting the Panel's Location based
on the cords of the Mouse events of the Form, but this has problems
because the Form doesn't receive mouse events while the cursor is
moving within the bounds of the Panel, cause the moving to be very
choppy.

Doesn't anyone have an idea as to how to handle this problem?

Thanks in advance,
I apologize if this has been asked already.
Jason
Nov 15 '05 #1
1 2875
When the mouse down is clicked you need to capture the mouse. Check out the
Control.Capture:

http://msdn.microsoft.com/library/de...pturetopic.asp

Mind the wrap

Regards
Lee
"Jay" <ja*********@yahoo.com> wrote in message
news:1e**************************@posting.google.c om...
I need to be able to move a Panel on a windows Form at run time using
the mouse. I have tried adding a MouseDown event handler to the Panel
and then within the MouseDown handler adding a MouseMove event to the
Panel and then setting the Panel's Location to a new Point(x, y) with
x and y set to the mouse's x and y, but this does not work because the
MouseDown event of Panel only sends the cords of the mouse within that
Panel. I need to be able to move the Panel within the Form and need to
get the cords of the mouse within the Form in order to set the Panel's
Location.

I've also tried adding a MouseMove event to the Form when the Panel's
MouseDown event is called and then setting the Panel's Location based
on the cords of the Mouse events of the Form, but this has problems
because the Form doesn't receive mouse events while the cursor is
moving within the bounds of the Panel, cause the moving to be very
choppy.

Doesn't anyone have an idea as to how to handle this problem?

Thanks in advance,
I apologize if this has been asked already.
Jason

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: John Champaign | last post by:
Hi all, I'm working on an educational applet for a child with special needs. He's got a bit of a trick to make my life more difficult... To interact with the applet he needs to click on...
1
by: LRD | last post by:
Form not refreshing after autopostback unless keyboard or mouse move Hi, We created several new ASP.NET C# forms for our intranet. In each form we use panels for different sections of the...
5
by: gsb | last post by:
I track the mouse location like this code: function mousePos(e) { var p = new Object(); if(e) { p.x = e.pageX; p.y = e.pageY; } else { p.x = event.x; p.y = event.y; } ... (show) }...
12
by: mdb | last post by:
My app has a notify icon in the systray. I want the left mouse click to initiate a menu, and a right-mouse click to do something else. Normally, for a button, I would listen to MouseDown and if I...
3
by: AinO | last post by:
Hi, (VS2003/c# - System.Windows.Forms) Is there a way to know (have an event triggered) if the mouse leaves a form, if this form's client area is completly covered with child controls ? I...
16
by: Niels Jensen | last post by:
I have been developing a little project which draw's a hexgrid on a panel within a form similar to this - it:s used as a client from a e-mail based strategy game: ____ ____ / \...
2
by: Sam | last post by:
Hi, I can't figure out how to detect when my mouse cursor leaves a panel control. It should not trigger the event (or do anything) when the mouse leave the panel but still is over a control that...
1
by: YouPoP | last post by:
I am doing an app (C# 2.0) where you can draw in a panel with your mouse in "real time". I actually have 2 problems; 1- it does not really is "real time", if your mouse move fast or very fast the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.