Page 1 of 1

Transparent form

Posted: Thu Jul 17, 2014 7:36 am
by Dummy1912
Hello,

seems all know how to make a Transparent Form
yea sure we do :) but why using the Transparencykey to set your form into

now you can even use a easier way:

what do we need:
A Form

how it works:
important message: Do never ever ever set your form show in taskbar because this code will not work trust me i know ;)

double click on the form
so we get the sub load
Code: Select all
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles  MyBase.Load
           FormBorderStyle = Windows.Forms.FormBorderStyle.None
           Me.ShowInTaskbar = False
           Me.ShowIcon = False
Try
            Me.BackColor = Color.Black
            Dim margins As MARGINS = New MARGINS
            margins.LeftWidth = -1
            margins.RightWidth = -1
            margins.TopHeight = -1
            margins.Buttomheight = -1
            Dim result As Integer = DwmExtendFrameIntoClientArea(Me.Handle, margins)
        Catch ex As Exception 'will be used if this above code does not work
            TransparencyKey = BackColor
        End Try
End Sub
or you can also use the sub new
Code: Select all
Public Sub New()
 InitializeComponent()
            FormBorderStyle = Windows.Forms.FormBorderStyle.None
            Me.ShowInTaskbar = False
            Me.ShowIcon = False
Try
            Me.BackColor = Color.Black
            Dim margins As MARGINS = New MARGINS
            margins.LeftWidth = -1
            margins.RightWidth = -1
            margins.TopHeight = -1
            margins.Buttomheight = -1
            Dim result As Integer = DwmExtendFrameIntoClientArea(Me.Handle, margins)
        Catch ex As Exception 'will be used if this above code does not work
            TransparencyKey = BackColor
        End Try
End Sub
have fun
hope you like this one
if some of you didn't know about this


NOT MY CODE JUST WANTED TO SHARE WITH YOU ALL ;)
#Birthday

Re: Transparent form

Posted: Mon Jul 28, 2014 12:56 pm
by smashapps
This is an interesting way of making the form transparent.
Is there a reason why this method is better than just setting the transparency key in the design view? Seems easier that way.

Re: Transparent form

Posted: Mon Jul 28, 2014 1:46 pm
by Dummy1912
hi #smashapps

well yea
if you use the default way and if your pc don't work great with transparent then you get a black or whatcolor you used at the background

with this it doesn't matter it stays transparent so far i tested it :)
the best way to test this is in windows xp
because the transparent does not work 100% in xp
so seems this way it does perfect ;)

#Birthday

Re: Transparent form

Posted: Mon Jul 28, 2014 5:45 pm
by XTechVB
You didn't do this by yourself, i saw it before on Daniweb.com if i'm not mistaken.
You should really give credit to the original author dude!

Good piece of code though.

Re: Transparent form

Posted: Mon Jul 28, 2014 6:05 pm
by Dummy1912
#XTechVB
sorry i don't use daniweb
and i never said i made this code
read again and you will know

i only said:
seems all know how to make a Transparent Form
yea sure we do :) but why using the Transparencykey to set your form into

now you can even use a easier way:

Re: Transparent form

Posted: Mon Jul 28, 2014 11:18 pm
by smashapps
#XTechVB does have a point, you didn't say the code wasn't yours.