Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Trail of Tears Part 2 (i.e. Control Locations)...

Trail of Tears Part 2 (i.e. Control Locations)...

Scheduled Pinned Locked Moved C#
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    new_phoenix
    wrote on last edited by
    #1

    Guffa: In response to the following response, I need to ask for some further input. I was able to successfully cause a Timer control to trigger when the dragged control was dropped. However, the dragDropTimer_Tick event cannot retrieve any control so that it could modify its location. Here is what I have so far:

    	private static void ProvideDragPathReturnToParent(Control ctrl, int intX\_end, int intY\_end, 
    		int intX\_start, int intY\_start)
    	{
    		Timer dragDropTimer = new Timer();
    		dragDropTimer.Enabled = true;
    		dragDropTimer.Interval = 2;
    		dragDropTimer.Tick +=new EventHandler(dragDropTimer\_Tick);
    		dragDropTimer.Start();
    	}
    
    
    	private static void dragDropTimer\_Tick(object sender, System.EventArgs e)
    	{
    		int x = 0, y = 0;
    		//Control cthis = ((Control)sender);
    
    		for (int index = 0; index <= 64; index++)
    		{
    			x = pt\_start.X + (intX\_end - pt\_start.X) \* index / 64;
    			y = pt\_start.Y + (intY\_end - pt\_start.Y) \* index / 64;
    		}
    		
    		//cthis.Location = new System.Drawing.Point(x, y);
    		
    		MessageBox.Show("Hello");
    	}
    

    The pt_start System.Drawing.Point was moved to become a public variable in the DragDropHandler. The problem is that I cannot access the control itself because the dragDropTimer_tick event handler has a sender object but it is not the same type as the control being dragged or dropped. How would I access the control itself to implement your suggestion? The timer event handler does actually show MessageBoxes saying the word "Hello" every interval. Please provide additional information. P.S. Others may respond as well. *****************Guffa's Message********** We start with this: new_phoenix wrote: and how would a timer be used to get the form to redraw itself? If you use a timer to trigger the movement of the control, the main message pump would handle messages in between the timer events. If you just change the location of the control, both the control and the previous area of the control will be invalidated. This creates messages that will be handled by the message pump. The message pump will call the Paint event of the control and the form, which will repaint the control and the part of the form that was invalidated. new_phoenix wrote: How could it be done in a loop The x position of a point on the line can be interpolated like this: x = startX + (endX - startX) * index / 64 where index is the index of the point from 0 to 64. The y position can be calculated in the same way. You don

    M G 2 Replies Last reply
    0
    • N new_phoenix

      Guffa: In response to the following response, I need to ask for some further input. I was able to successfully cause a Timer control to trigger when the dragged control was dropped. However, the dragDropTimer_Tick event cannot retrieve any control so that it could modify its location. Here is what I have so far:

      	private static void ProvideDragPathReturnToParent(Control ctrl, int intX\_end, int intY\_end, 
      		int intX\_start, int intY\_start)
      	{
      		Timer dragDropTimer = new Timer();
      		dragDropTimer.Enabled = true;
      		dragDropTimer.Interval = 2;
      		dragDropTimer.Tick +=new EventHandler(dragDropTimer\_Tick);
      		dragDropTimer.Start();
      	}
      
      
      	private static void dragDropTimer\_Tick(object sender, System.EventArgs e)
      	{
      		int x = 0, y = 0;
      		//Control cthis = ((Control)sender);
      
      		for (int index = 0; index <= 64; index++)
      		{
      			x = pt\_start.X + (intX\_end - pt\_start.X) \* index / 64;
      			y = pt\_start.Y + (intY\_end - pt\_start.Y) \* index / 64;
      		}
      		
      		//cthis.Location = new System.Drawing.Point(x, y);
      		
      		MessageBox.Show("Hello");
      	}
      

      The pt_start System.Drawing.Point was moved to become a public variable in the DragDropHandler. The problem is that I cannot access the control itself because the dragDropTimer_tick event handler has a sender object but it is not the same type as the control being dragged or dropped. How would I access the control itself to implement your suggestion? The timer event handler does actually show MessageBoxes saying the word "Hello" every interval. Please provide additional information. P.S. Others may respond as well. *****************Guffa's Message********** We start with this: new_phoenix wrote: and how would a timer be used to get the form to redraw itself? If you use a timer to trigger the movement of the control, the main message pump would handle messages in between the timer events. If you just change the location of the control, both the control and the previous area of the control will be invalidated. This creates messages that will be handled by the message pump. The message pump will call the Paint event of the control and the form, which will repaint the control and the part of the form that was invalidated. new_phoenix wrote: How could it be done in a loop The x position of a point on the line can be interpolated like this: x = startX + (endX - startX) * index / 64 where index is the index of the point from 0 to 64. The y position can be calculated in the same way. You don

      M Offline
      M Offline
      M Hall
      wrote on last edited by
      #2

      The sender object in your dragDropTimer_Tick event is going to be the timer, try creating a public variable of type control and setting it to the calling control in your ProvideDragPathReturnToParent event and use that variable in your dragDropTimer_Tick event Hope that helps

      1 Reply Last reply
      0
      • N new_phoenix

        Guffa: In response to the following response, I need to ask for some further input. I was able to successfully cause a Timer control to trigger when the dragged control was dropped. However, the dragDropTimer_Tick event cannot retrieve any control so that it could modify its location. Here is what I have so far:

        	private static void ProvideDragPathReturnToParent(Control ctrl, int intX\_end, int intY\_end, 
        		int intX\_start, int intY\_start)
        	{
        		Timer dragDropTimer = new Timer();
        		dragDropTimer.Enabled = true;
        		dragDropTimer.Interval = 2;
        		dragDropTimer.Tick +=new EventHandler(dragDropTimer\_Tick);
        		dragDropTimer.Start();
        	}
        
        
        	private static void dragDropTimer\_Tick(object sender, System.EventArgs e)
        	{
        		int x = 0, y = 0;
        		//Control cthis = ((Control)sender);
        
        		for (int index = 0; index <= 64; index++)
        		{
        			x = pt\_start.X + (intX\_end - pt\_start.X) \* index / 64;
        			y = pt\_start.Y + (intY\_end - pt\_start.Y) \* index / 64;
        		}
        		
        		//cthis.Location = new System.Drawing.Point(x, y);
        		
        		MessageBox.Show("Hello");
        	}
        

        The pt_start System.Drawing.Point was moved to become a public variable in the DragDropHandler. The problem is that I cannot access the control itself because the dragDropTimer_tick event handler has a sender object but it is not the same type as the control being dragged or dropped. How would I access the control itself to implement your suggestion? The timer event handler does actually show MessageBoxes saying the word "Hello" every interval. Please provide additional information. P.S. Others may respond as well. *****************Guffa's Message********** We start with this: new_phoenix wrote: and how would a timer be used to get the form to redraw itself? If you use a timer to trigger the movement of the control, the main message pump would handle messages in between the timer events. If you just change the location of the control, both the control and the previous area of the control will be invalidated. This creates messages that will be handled by the message pump. The message pump will call the Paint event of the control and the form, which will repaint the control and the part of the form that was invalidated. new_phoenix wrote: How could it be done in a loop The x position of a point on the line can be interpolated like this: x = startX + (endX - startX) * index / 64 where index is the index of the point from 0 to 64. The y position can be calculated in the same way. You don

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        Please keep the responses in the same thread.

        --- single minded; short sighted; long gone;

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups