Action on form dragging

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pablojoshua
    New Member
    • Jun 2007
    • 10

    #1

    Action on form dragging

    When you click and hold the top bar (border/border style) of a program and drag, it moves around the program with any program. How do you have an action be executed when you start dragging the program and an action be executed when the program has stopped being dragged?

    I want to have the program become transparent when it is dragged, and then solid again when it is places somewhere on the user's screen. The code that I want to be executed when it starts being dragged is:
    Code:
    MakeTransparent Me.hWnd, 100
    and when the program is places somewhere:
    Code:
    MakeTransparent Me.hWnd, 250

    Thanks & Cheers!
  • daniel aristidou
    Contributor
    • Aug 2007
    • 494

    #2
    Originally posted by pablojoshua
    When you click and hold the top bar (border/border style) of a program and drag, it moves around the program with any program.
    Im not sure understand this line...could you please rephrase it

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      I don't think there is any event that will tell you the form is being dragged. Since your program sort of works within its window(s), in a sense you could say that from your program's point of view, nothing is happening. Just like the user moving the monitor on the desk - means thing to your program.

      Of course it's not that simple. There must be some way to detect it, especially since I'm sure we've all seen it done. But I think you will have to use some sort of API function (possibly a callback one) to detect the drag operation outside of the "normal" event procedures.

      One way to investigate would be to put a line of code in every event for a test form, to Debug.Print the name of the event. Then drag the form and see what events are triggered.

      Obviously some events won't be very helpful. For instance, you might find that ReSize and/or Paint will fire, but only after the form is dropped. Likewise, watching for changes in the Top/Left properties may not tell you anything until after the fact.

      Note also, a lot of this will probably behave differently depending on whether the user has "show form while dragging" switched on.

      Comment

      Working...