Gunnez Forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Make form transparent while dragging

Go down

Make form transparent while dragging Empty Make form transparent while dragging

Post by Admin Wed Oct 13, 2010 10:34 am

Hi guys,

Here is a VB snippet that, when moved, the window becomes transparent.

Private Const WM_NCLBUTTONDOWN As Long = &HA1
Private Const WM_NCLBUTTONUP As Long = &HA0
Private Const WM_MOVING As Long = &H216
Private Const WM_SIZE As Long = &H5
Protected Overrides Sub DefWndProc(ByRef m As System.Windows.Forms.Message)
Static LButtonDown As Boolean
(checks left click)
If CLng(m.Msg) = WM_NCLBUTTONDOWN Then
'(as long as left button is down LButtonDown returns true)
LButtonDown = True
ElseIf CLng(m.Msg) = WM_NCLBUTTONUP Then
' (As long as left button is up, LButtonDown returns false)
LButtonDown = False
End If
If LButtonDown Then
If CLng(m.Msg) = WM_MOVING Then
'Changes form opacity to 70% if the form is being dragged
' You can change the 0.7 to anything 0.1 = 10% 0.2 = 20 % and so on
If Me.Opacity <> 0.9 Then Me.Opacity = 0.5
ElseIf CLng(m.Msg) = WM_SIZE Then
'Set the forms opacity to 60% if user is resizing the window
If Me.Opacity <> 0.6 Then Me.Opacity = 0.6
End If
ElseIf Not LButtonDown Then
If Me.Opacity <> 1.0 Then Me.Opacity = 1.0
End If
MyBase.DefWndProc(m)
End Sub



Gunnez
Admin
Admin
Admin

Posts : 125
Points : 5338
Join date : 2010-09-21
Age : 27
Location : Australia

https://mpgh.forumotion.com

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum