deryk_2784

deryk_2784

  • NA
  • 27
  • 0

help! i want a loop to continue while my mouse is over a picture box but stop when it leaves

Sep 1 2004 2:43 AM
hi everyone. right now, i have a map graphic displayed on my program's main screen. around it are four buttons. what i basically want to happen is, since the map is too big to show all at once, i want to use the four buttons to make the map scroll left or right. let's call the top button "UpMap". i currently have an action set for its mouseenter that goes something like: //UpMove, yMap, and xMap are all global variables UpMove = true; //to tell the program to keep the image moving upward while(UpMove) { yMap -= 1; //to set the image to a point 1 pixel higher than its previous location this.map_graphic.Location = new System.Drawing.Point(xMap, yMap); } for the mouseleave, i have something like: UpMove = false; i take it once the mouse enters the picture box area, UpMove is set to true and the loop starts and continues. supposedly, once the mouse leaves the area, it should set UpMove to false, thus stopping the loop. but what happens is that the loop continues infinitely, and the image moves up continuously and i can't even close the application window. any ways to fix this or any other suggestions on how to do it? :) thanks!

Answers (3)