473,408 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Detecting Transparent as a color

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

If myMousedown = lblP1JoyRight.Name Then

If lblP1JoyRight.BackColor.Equals(Color.Transparent) Then

bTransCk = True

lblP1JoyRight.BackColor = clrLabelMove

End If

lblP1JoyRight.Location = New System.Drawing.Point(Cursor.Position.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 2532
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.BackColor.ToArgb

This is how it stores it:

<BackColor>16777215</BackColor>

And I read it back in using this code:

lblP1JoyUp.BackColor = Color.FromArgb(ds.Tables(0).Rows(0).Item(6))

Thanks,
John

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

If myMousedown = lblP1JoyRight.Name Then

If lblP1JoyRight.BackColor.Equals(Color.Transparent) Then

bTransCk = True

lblP1JoyRight.BackColor = clrLabelMove

End If

lblP1JoyRight.Location = New System.Drawing.Point(Cursor.Position.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****************@TK2MSFTNGP09.phx.gbl...
I am using the following code to move a label on a form at runtime:

If myMousedown = lblP1JoyRight.Name Then

If lblP1JoyRight.BackColor.Equals(Color.Transparent) Then

bTransCk = True

lblP1JoyRight.BackColor = clrLabelMove

End If

lblP1JoyRight.Location = New System.Drawing.Point(Cursor.Position.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.Transparent 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.Transparent and 0.

How are you detecting the backcolor of the label?

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

If myMousedown = lblP1JoyRight.Name Then

If lblP1JoyRight.BackColor.Equals(Color.Transparent) Then

bTransCk = True

lblP1JoyRight.BackColor = clrLabelMove

End If

lblP1JoyRight.Location = New System.Drawing.Point(Cursor.Position.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).Rows(0).Item(6) = "16777215" Then

lblP1JoyUp.BackColor = Color.Transparent

Else

lblP1JoyUp.BackColor = Color.FromArgb(ds.Tables(0).Rows(0).Item(6))

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

Thnaks,
John

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

If myMousedown = lblP1JoyRight.Name Then

If lblP1JoyRight.BackColor.Equals(Color.Transparent) Then

bTransCk = True

lblP1JoyRight.BackColor = clrLabelMove

End If

lblP1JoyRight.Location = New System.Drawing.Point(Cursor.Position.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
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...
8
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...
1
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 ...
3
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...
7
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...
8
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...
6
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,...
2
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,...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.