Click here to Skip to main content
15,903,362 members
Home / Discussions / C#
   

C#

 
QuestionLoop Pin
shamsteady10-Mar-07 17:25
shamsteady10-Mar-07 17:25 
AnswerRe: Loop Pin
Guffa10-Mar-07 18:09
Guffa10-Mar-07 18:09 
GeneralRe: Loop Pin
shamsteady10-Mar-07 18:17
shamsteady10-Mar-07 18:17 
AnswerRe: Loop Pin
Christian Graus10-Mar-07 19:40
protectorChristian Graus10-Mar-07 19:40 
QuestionDES Encryption Pin
Ravun10-Mar-07 16:47
Ravun10-Mar-07 16:47 
AnswerRe: DES Encryption Pin
Dominik Reichl11-Mar-07 3:21
Dominik Reichl11-Mar-07 3:21 
GeneralRe: DES Encryption Pin
Ravun11-Mar-07 12:28
Ravun11-Mar-07 12:28 
QuestionTrail of Tears Part 2 (i.e. Control Locations)... Pin
new_phoenix10-Mar-07 12:11
new_phoenix10-Mar-07 12:11 
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't even have to create an array of points, you can just calculate the position directly in the timer event.



---
single minded; short sighted; long gone;
AnswerRe: Trail of Tears Part 2 (i.e. Control Locations)... Pin
M-Hall10-Mar-07 13:03
M-Hall10-Mar-07 13:03 
GeneralRe: Trail of Tears Part 2 (i.e. Control Locations)... Pin
Guffa10-Mar-07 13:33
Guffa10-Mar-07 13:33 
QuestionWallpaper Pin
CodeItWell10-Mar-07 11:04
CodeItWell10-Mar-07 11:04 
AnswerRe: Wallpaper Pin
Dawid Mazuruk10-Mar-07 23:36
Dawid Mazuruk10-Mar-07 23:36 
QuestionArray Pin
shamsteady10-Mar-07 9:23
shamsteady10-Mar-07 9:23 
AnswerRe: Array Pin
Travis D. Mathison10-Mar-07 9:59
Travis D. Mathison10-Mar-07 9:59 
GeneralRe: Array Pin
shamsteady10-Mar-07 10:02
shamsteady10-Mar-07 10:02 
GeneralRe: Array Pin
Christian Graus10-Mar-07 10:30
protectorChristian Graus10-Mar-07 10:30 
QuestionDifferences between strings Pin
tzuiop10-Mar-07 5:51
tzuiop10-Mar-07 5:51 
AnswerRe: Differences between strings Pin
Christian Graus10-Mar-07 5:57
protectorChristian Graus10-Mar-07 5:57 
AnswerRe: Differences between strings Pin
Phillip M. Hoff10-Mar-07 16:43
Phillip M. Hoff10-Mar-07 16:43 
Questionmove image through a path [modified] Pin
waleed9910-Mar-07 5:33
waleed9910-Mar-07 5:33 
AnswerRe: move image through a path Pin
Christian Graus10-Mar-07 5:43
protectorChristian Graus10-Mar-07 5:43 
GeneralRe: move image through a path Pin
waleed9910-Mar-07 21:13
waleed9910-Mar-07 21:13 
QuestionProblem with painting a form Pin
-raada-10-Mar-07 5:06
-raada-10-Mar-07 5:06 
AnswerRe: Problem with painting a form Pin
Christian Graus10-Mar-07 5:15
protectorChristian Graus10-Mar-07 5:15 
GeneralRe: Problem with painting a form Pin
-raada-10-Mar-07 7:49
-raada-10-Mar-07 7:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.