Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question on OnMouseMove

Status
Not open for further replies.

FancyPrairie

Programmer
Oct 16, 2001
2,917
US
I have 36 textboxes on my web form all lined up in a row with each one touching the other. When the user clicks on one of the textboxes, I change its background color to Red and move a panel on top of the textbox (panel has the same dimensions as the textbox). When the user moves the mouse over the right or left edge of the panel I change the cursor to "w-resize". As the user holds the mouse button down he can resize the width of the panel. Each textbox that the panel covers turns red. If the user moves the mouse in the other direction, the background color of the textboxes that are not covered by the panel are changed from red to silver.

This all works fine as long as I don't move the mouse to fast. If I move the mouse too fast, the color of some of the text boxes doesn't get changed to silver. It appears that my code can not keep up with the mouse. However, the code that changes the size of the panel as the mouse moves keeps up as well as a label I drag along with the mouse. It's just the code that changes the background color of the textboxes that can't keep up.

Is there some way that I can ensure that all of the code is executed before the next cycle into the code? Note that I'm doing this via the OnMouseMove event of the document.
 
DO you have a URL where we can take a look at the actual effects you are talking about, and the code used?


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
No I don't. This is my first ASP.net 2.0 application so there may be (I'm sure there is) a better way of doing it. But, basically, each textbox represents an hour of the day. I want the user to be able to select the beginning hour and then drag the mouse to select the range of hours. As the mouse moves over the next hour I want that text box to turn red. Now, obviously, I will also give the user the option of entering the time period range rather than using the mouse. Everything works ok except if I move the mouse to fast backwards and forwards the code fails to toggle the colors of some of the textboxes. So I guess my basic question is, is there some way I can force the code to complete before it executes again (i.e. DoEvents...Access function)
 
You will probably have to work out from the X / Y coordinates of the mouse cursor how many "steps" you need to highlight.

This should be easy enough if you know the width of the text boxes, the start position of the mouse [down event], the start position of the text boxes, and the current mouse position.

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
BillyRayPreachersSon, I thought of that, but hoping there was some other way. Right now I'm just toggling the color off/on of a single textbox as the panel moves over it. I really didn't want to reset the color of all textboxes within the range each time one textbox changed.

I'm going to look into the drag method to see if that handles it any better. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top