By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,992 Members | 967 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,992 IT Pros & Developers. It's quick & easy.

Detecting Transparent as a color

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.