why black color?

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
16 posts Page 1 of 2
Contributors
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

why black color?
Dummy1912
hello,

can anyone tell me why i get always a black backcolor instead of transparent color
even search on google it seems i do everything correct and still gets a black color
Code: Select all
    Inherits Button
    Public Sub New()
        Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or _
                ControlStyles.UserPaint Or _
               ControlStyles.OptimizedDoubleBuffer, True)
        BackColor = Color.Transparent
    End Sub
Code: Select all
Protected Overrides Sub OnPaint(pevent As PaintEventArgs)
        Dim g As Graphics = pevent.Graphics
        g.SmoothingMode = SmoothingMode.AntiAlias
        g.Clear(Color.Transparent)
        g.DrawImage(Frmpl.Px1.Image, 0, 0, 39, 41)
    End Sub
Image

thanks
Last edited by Dummy1912 on Mon Feb 17, 2014 1:58 pm, edited 1 time in total.
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Re: why black color?
XTechVB
Try removing this line
Code: Select all
g.Clear(Color.Transparent)
You can find me on Facebook or on Skype mihai_92b
User avatar
Shim
VIP - Donator
VIP - Donator
Posts: 882
Joined: Wed Dec 14, 2011 5:02 am

Re: why black color?
Shim
Maybe the picture has that backcolor
Find my programs on Softpedia
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: why black color?
Dummy1912
XTechVB wrote:
Try removing this line
Code: Select all
g.Clear(Color.Transparent)
#XTechVB,

tried it, but when run app black color comes back :(
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
noypikami
VIP - Donator
VIP - Donator
Posts: 151
Joined: Sat Dec 22, 2012 1:49 am

Re: why black color?
noypikami
the bitmap is empty that is why it's color is black.
try to make a rectangle and fill it with the (new solidbrush(me.backcolor))
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Re: why black color?
XTechVB
What are you trying to do? Draw a PNG image while keeping it's transparent background?
You can find me on Facebook or on Skype mihai_92b
User avatar
noypikami
VIP - Donator
VIP - Donator
Posts: 151
Joined: Sat Dec 22, 2012 1:49 am

Re: why black color?
noypikami
i guess he/she is making a class for a custom control.
i pretty sure, that the bitmap will turn out black , because its empty.
it's just set to the size of the control or something.
User avatar
smashapps
Coding Guru
Coding Guru
Posts: 961
Joined: Tue Apr 05, 2011 8:41 am

Re: why black color?
smashapps
#Dummy1912 try this:
Code: Select all
Public Sub InitializeMyForm()
    BackColor = Color.Black
    ' Make the background color of form display transparently.
    TransparencyKey = BackColor
End Sub 'InitializeMyForm
To have a transparent color on the form, it needs to have a TransparencyKey set to the same color that you want transparent.

Hope I helped, and the code is from MSDN.
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: why black color?
Dummy1912
#smashapps sorry but this can't be used:
'TransparencyKey' is not declared. It may be inaccessible due to its protection level.

#noypikami
last time we checked i'm still a HE :lol:
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Re: why black color?
XTechVB
'TransparencyKey' is not declared. It may be inaccessible due to its protection level.
I believe only "Form" type controls have the "TransparencyKey" property. Won't work on other controls.
You can find me on Facebook or on Skype mihai_92b
16 posts Page 1 of 2
Return to “Coding Help & Support”