473,683 Members | 2,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Detecting Transparent as a color

I am using the following code to move a label on a form at runtime:

If myMousedown = lblP1JoyRight.N ame Then

If lblP1JoyRight.B ackColor.Equals (Color.Transpar ent) Then

bTransCk = True

lblP1JoyRight.B ackColor = clrLabelMove

End If

lblP1JoyRight.L ocation = New System.Drawing. Point(Cursor.Po sition.X -
mouseX, Cursor.Position .Y - mouseY)

bMouseMove = True

End If
I am attempting to see if the labels background color is transparent. If it
is, I want to set a flag (bTransCk), change it to a color a users has
selected under the options menu (clrLabelMove), move the control (while it
is using the user selected backcolor, "clrLabelMove") , then set it back to
transparent after the move is complete. Transparency seems to really draw on
system resources while dragging a control. Anyways, the problem is that the
control won't seem to detect as transparent even though it is. If I have a
picture for my background on my form I can see through the label. If I drag
the label I can see through it while dragging it. But it just won't detect
as transparent. I am able to change the label background colors at runtime
with code. The funny thing is that if I select the label and set it's
background to transparent using a menu option I have, it then detects it as
transparent during the mouse_move event. I must be checking with the wrong
syntax or not handling the color properly. Any ideas here?

Thanks,
John


Nov 20 '05 #1
4 2558
More information:

I am creating layouts, saving them and reopening them. I store the
information in XML files. I use this code to write to the XML file:

dr1("BackColor" ) = lblP1JoyUp.Back Color.ToArgb

This is how it stores it:

<BackColor>1677 7215</BackColor>

And I read it back in using this code:

lblP1JoyUp.Back Color = Color.FromArgb( ds.Tables(0).Ro ws(0).Item(6))

Thanks,
John

"jcrouse" <me> wrote in message
news:uU******** ********@TK2MSF TNGP09.phx.gbl. ..
I am using the following code to move a label on a form at runtime:

If myMousedown = lblP1JoyRight.N ame Then

If lblP1JoyRight.B ackColor.Equals (Color.Transpar ent) Then

bTransCk = True

lblP1JoyRight.B ackColor = clrLabelMove

End If

lblP1JoyRight.L ocation = New System.Drawing. Point(Cursor.Po sition.X -
mouseX, Cursor.Position .Y - mouseY)

bMouseMove = True

End If
I am attempting to see if the labels background color is transparent. If it is, I want to set a flag (bTransCk), change it to a color a users has
selected under the options menu (clrLabelMove), move the control (while it
is using the user selected backcolor, "clrLabelMove") , then set it back to
transparent after the move is complete. Transparency seems to really draw on system resources while dragging a control. Anyways, the problem is that the control won't seem to detect as transparent even though it is. If I have a picture for my background on my form I can see through the label. If I drag the label I can see through it while dragging it. But it just won't detect
as transparent. I am able to change the label background colors at runtime
with code. The funny thing is that if I select the label and set it's
background to transparent using a menu option I have, it then detects it as transparent during the mouse_move event. I must be checking with the wrong
syntax or not handling the color properly. Any ideas here?

Thanks,
John

Nov 20 '05 #2
You can't detect a transparent pixel - the OS doesn't draw it - hence it
being transparent!!
You'll only be able to detect the pixel "underneath ".
_______________ _______________ _
The Grim Reaper

"jcrouse" <me> wrote in message
news:uU******** ********@TK2MSF TNGP09.phx.gbl. ..
I am using the following code to move a label on a form at runtime:

If myMousedown = lblP1JoyRight.N ame Then

If lblP1JoyRight.B ackColor.Equals (Color.Transpar ent) Then

bTransCk = True

lblP1JoyRight.B ackColor = clrLabelMove

End If

lblP1JoyRight.L ocation = New System.Drawing. Point(Cursor.Po sition.X -
mouseX, Cursor.Position .Y - mouseY)

bMouseMove = True

End If
I am attempting to see if the labels background color is transparent. If it is, I want to set a flag (bTransCk), change it to a color a users has
selected under the options menu (clrLabelMove), move the control (while it
is using the user selected backcolor, "clrLabelMove") , then set it back to
transparent after the move is complete. Transparency seems to really draw on system resources while dragging a control. Anyways, the problem is that the control won't seem to detect as transparent even though it is. If I have a picture for my background on my form I can see through the label. If I drag the label I can see through it while dragging it. But it just won't detect
as transparent. I am able to change the label background colors at runtime
with code. The funny thing is that if I select the label and set it's
background to transparent using a menu option I have, it then detects it as transparent during the mouse_move event. I must be checking with the wrong
syntax or not handling the color properly. Any ideas here?

Thanks,
John

Nov 20 '05 #3
Color.Transpare nt in dotnet is White with no Alpha (&H00FFFFFF).
Transparent pixels in a bitmap are 0 (&H00000000) or Black with no Alpha.
So you must check for both Color.Transpare nt and 0.

How are you detecting the backcolor of the label?

--
Mick Doherty
http://dotnetrix.co.uk
"jcrouse" <me> wrote in message
news:uU******** ********@TK2MSF TNGP09.phx.gbl. ..
I am using the following code to move a label on a form at runtime:

If myMousedown = lblP1JoyRight.N ame Then

If lblP1JoyRight.B ackColor.Equals (Color.Transpar ent) Then

bTransCk = True

lblP1JoyRight.B ackColor = clrLabelMove

End If

lblP1JoyRight.L ocation = New System.Drawing. Point(Cursor.Po sition.X -
mouseX, Cursor.Position .Y - mouseY)

bMouseMove = True

End If
I am attempting to see if the labels background color is transparent. If it is, I want to set a flag (bTransCk), change it to a color a users has
selected under the options menu (clrLabelMove), move the control (while it
is using the user selected backcolor, "clrLabelMove") , then set it back to
transparent after the move is complete. Transparency seems to really draw on system resources while dragging a control. Anyways, the problem is that the control won't seem to detect as transparent even though it is. If I have a picture for my background on my form I can see through the label. If I drag the label I can see through it while dragging it. But it just won't detect
as transparent. I am able to change the label background colors at runtime
with code. The funny thing is that if I select the label and set it's
background to transparent using a menu option I have, it then detects it as transparent during the mouse_move event. I must be checking with the wrong
syntax or not handling the color properly. Any ideas here?

Thanks,
John

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004
Nov 20 '05 #4
Resolved! I forced it to transparent with this code:

If ds.Tables(0).Ro ws(0).Item(6) = "16777215" Then

lblP1JoyUp.Back Color = Color.Transpare nt

Else

lblP1JoyUp.Back Color = Color.FromArgb( ds.Tables(0).Ro ws(0).Item(6))

End If
I'm still not sure why this was necessary though.

Thnaks,
John

"jcrouse" <me> wrote in message
news:uU******** ********@TK2MSF TNGP09.phx.gbl. ..
I am using the following code to move a label on a form at runtime:

If myMousedown = lblP1JoyRight.N ame Then

If lblP1JoyRight.B ackColor.Equals (Color.Transpar ent) Then

bTransCk = True

lblP1JoyRight.B ackColor = clrLabelMove

End If

lblP1JoyRight.L ocation = New System.Drawing. Point(Cursor.Po sition.X -
mouseX, Cursor.Position .Y - mouseY)

bMouseMove = True

End If
I am attempting to see if the labels background color is transparent. If it is, I want to set a flag (bTransCk), change it to a color a users has
selected under the options menu (clrLabelMove), move the control (while it
is using the user selected backcolor, "clrLabelMove") , then set it back to
transparent after the move is complete. Transparency seems to really draw on system resources while dragging a control. Anyways, the problem is that the control won't seem to detect as transparent even though it is. If I have a picture for my background on my form I can see through the label. If I drag the label I can see through it while dragging it. But it just won't detect
as transparent. I am able to change the label background colors at runtime
with code. The funny thing is that if I select the label and set it's
background to transparent using a menu option I have, it then detects it as transparent during the mouse_move event. I must be checking with the wrong
syntax or not handling the color properly. Any ideas here?

Thanks,
John

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1870
by: Querejeto | last post by:
Hello: Is it possible to detect programmatically the constness of a member function when it is called? That is, I would like to see a generic implementation (i.e. it does not depend on the class Base) of the createInstance function below that produces the output: Output:
8
6488
by: djmanmaster | last post by:
Am I right in thinking that images with transparent areas (GIFs or PNGs) should allow clicks to "pass through" to any underlying elements behind them? I have had no luck getting this to work in IE or Firefox. I have tried GIF and PNG with 'binary' transparency and PNG24 with 'alpha' transparency (obviously the latter won't work in IE without the AlphaImageLoader trick). Here is a test page for you to see it not working in action:
1
20174
by: Efkas | last post by:
My application have some level : 1. MyButton class with Label inheritance 2. MyComponent as User Control loading and positionning some of MyButtons 3. MyApp loading and positionning MyComponent I prefer don't insert a background in MyComponent, and using the MyApp one as general background with MyComponent positionned, but I am not able to have MyComponent background transparent.
3
3101
by: Steve Koon | last post by:
Any thoughts on getting this project to work or suggesting another method would be appreciated. Steve ========================================== Project: A Windows Form which acts as a Whiteboard. The Form contains 3
7
3582
by: Peter Oliphant | last post by:
Using MakeTransparent one can supposedly turn a color used in a Bitmap to transparent. But, it looks to me like all it does it set these pixels to the color BackColor of the Control it's attached to. Thus, when I set White to the transparent color of a Bitmap stored in the Image of a PictureBox and placed the PictureBox on a Form which has a BackColor of black, it turned the white pixels of the bitmap image to black, but these black pixels...
8
10605
by: Grahammer | last post by:
Is it possible to set the background of a usercontrol as transparent? I tried setting the background image of the usercontrol to a transparent GIF, but that caused MAJOR problems. I'm making some controls that aren't rectangular and it won't be pretty if I end up with a grey rectangle behind each one. http://msdn.microsoft.com/library/en-us/vbcon/html/vbtskGivingYourControlTransparentBackground.asp?frame=true
6
6989
by: jcrouse | last post by:
I have the following mouse events assigned to a label control. Is the a way I can tell which mouse button the users has clicked with? Private Sub lblP1JoyUp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblP1JoyUp.Click If bMouseMove = False Then If bCtrlKey = True Then
2
3652
by: Pascal | last post by:
Je veux que mes label soit transparent aussi sur mes picturebox alors j'écris : i want my labels to be transparent on my pictureboxes so i wrote : Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Label1.Parent = PictureBox1 Label1.BackColor = Color.Transparent Label2.Parent = PictureBox2 Label2.BackColor = Color.Transparent
4
9355
by: ray well | last post by:
in my app i need to make a RichTextbox control transparent. i need it to be a like a pane of glass lying on a sheet of paper, where u can see everything on the sheet of paper not covered by text written on the glass pane. i need to be able to see the control or form that is underneath the RichTextbox, and at the same time to be able to write and erase text to the RichTextbox. i'm assuming that it is the backcolor that hides what is...
0
8504
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8922
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8751
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8771
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5789
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2934
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2195
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1921
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.