Question[Help]Checkbox1(For Transparency)

Posts 1–10 of 10 · Page 1 of 1
[Help]Checkbox1(For Transparency)
Hey guys, quick question.

I have a checkbox and when its checked i want the program to become transparent when it gets dragged. When its NOT checked then it will NOT go trans. when i drag it.

Code for checkbox1.
[PHP]
If Checkbox1.Checked = True Then[/PHP]
i dont know what to do from here


code for transparency by Nextgen1

[PHP]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

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




[/PHP]
Quote Originally Posted by zmansquared View Post
Hey guys, quick question.

I have a checkbox and when its checked i want the program to become transparent when it gets dragged. When its NOT checked then it will NOT go trans. when i drag it.

Code for checkbox1.
[PHP]
If Checkbox1.Checked = True Then[/PHP]
i dont know what to do from here


code for transparency by Nextgen1

[PHP]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

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




[/PHP]
Code:
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
if checkbox1.checked = true then
'transparent code here
else
'show code here
end if
    End Sub
where it says 'transparent code here do i leave the ' infront or no

Edit: I get alot of errors. can you put it in and post here please?
Quote Originally Posted by zmansquared View Post
where it says 'transparent code here do i leave the ' infront or no

Edit: I get alot of errors. can you put it in and post here please?
Yah ill put it into a code later
Ok thanks. Pm if you can
Quote Originally Posted by zmansquared View Post
Ok thanks. Pm if you can
sorry your gonna have to have nextgen help you with this, its his code so i dnt really know what it does xD


I will add it in a few

(or so)
Here are the modifications , Whole code.

[php]
Public Class Form1

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)

If CheckBox1.Checked = True Then
Static LButtonDown As Boolean

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)
Else

Static LButtonDown2 As Boolean

If CLng(m.Msg) = WM_NCLBUTTONDOWN Then
'(as long as left button is down LButtonDown returns true)
' LButtonDown2 = True
ElseIf CLng(m.Msg) = WM_NCLBUTTONUP Then
' (As long as left button is up, LButtonDown returns false)
' LButtonDown2 = False
End If
If LButtonDown2 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 LButtonDown2 Then
If Me.Opacity <> 1.0 Then Me.Opacity = 1.0
End If
MyBase.DefWndProc(m)
End If

End Sub

End Class
[/php]

This code will only set transparency on resize and move if checkbox is checked, otherwise , normal
WOW. thanks a bunch. you rock


/close due to solved
/ Solved

/ Closed

and Not a problem at all
Posts 1–10 of 10 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?