How to Make Form Transparent While Dragging / Out of Focus?

I was wondering how to make my form turn transparent when I go to move it by dragging it, and then bring it back to opaque once I let go of it. Also, how could I make the form turn transparent while it is out of focus, and turn opaque when it regains focus?

A solution to either or both of the problems would be appreciated.

Thank you.

[354 byte] By [blabus] at [2007-12-24]
# 1
You can detect that the form is active/inactive with the Activate and Deactivate events. Detecting dragging is going to take more work. You'll need to implement the WndProc() method and detect a WM_MOVING message to see it starting to move and WM_EXITSIZEMOVE when it stops. Yell if you need code.
nobugz at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2

Thanks for the help nobugz. Activate and deactivate worked. Also, I solved the other one as well- I used this code:

Private Sub MainForm_ResizeBegin(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.ResizeBegin

Me.Opacity = 0.6

End Sub

Private Sub MainForm_ResizeEnd(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.ResizeEnd

Me.Opacity = 1

End Sub

It works great, whether I'm resizing the control or just moving it.

Anyway, thanks for your help.

blabus at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...