Detect control movement in screen ???

yes, indeed we can use Control.Move event to know when a control moves. But, what if the control moves in screen because we move the form  Yes, we can solve this by adding event handler to the form's Move event. But again, what if the control has multiple level of parenting i.e. control is contained within a panel then contained within a form, and the panel is moved  Basically, I wanna know how to detect if a control moves in screen even a pixel. Any idea

Answer this question

Detect control movement in screen ???

  • Kristian PD

    How do you detect a double click on a listbox on a UserControl, to the main form, where the user control is attached.
  • D.Hamilton

    Since position of controls are relative to its containers position, a control moves along with its parent. So I think you are searching for nonexisting troubles. It would get rather nasty when controls wouldn't move along with its parent!

  • H.Ashok

    <strong>PointToScreen</strong> is needed to convert from coordinate <strong>Graphics</strong> uses to the coordinates <strong>ControlPaint</strong> needs, for some reason the .Net framework has its <strong>DrawReversibleLine</strong> routine in ControlPaint while it is more usefull along with other reversible draw routines in Graphics, perhaps some future .Net version (The peaks I have at 2.0 doesn't mention, but I do hope so)
  • tvance929

    An example would be nice.
  • Venkataramana

    Create your own custom event similar to listbox doubleclick event. When the listbox doubleclick event is raised within the usr control, catch it and raise your custom event.
  • dhika

    Thx for your reply. But, my intention is to detect the movement, not to stop or even prevent it from moving along with its parent. :) Yes indeed, position of controls is always relative to its containers position if looking at the control's location property, what about PointToScreen function  What does it mean to you  or someone might not even know if such function exists

    What I want could be achieved by using Timer, to get the control position in screen using PointToScreen function. However, I dont wanna perform unnecessary step when the control is not moving at all in screen coordinate.

    Well, any other ideas are really welcome.

  • Detect control movement in screen ???