By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,731 Members | 1,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,731 IT Pros & Developers. It's quick & easy.

Action on form dragging

pablojoshua
P: 10
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:
Expand|Select|Wrap|Line Numbers
  1. MakeTransparent Me.hWnd, 100
and when the program is places somewhere:
Expand|Select|Wrap|Line Numbers
  1. MakeTransparent Me.hWnd, 250

Thanks & Cheers!
Feb 2 '08 #1
Share this Question
Share on Google+
2 Replies


daniel aristidou
100+
P: 491
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
Feb 3 '08 #2

Expert 5K+
P: 8,434
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.
Feb 4 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.