473,698 Members | 2,635 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 2560
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
1873
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
20176
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
3585
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
10609
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
6991
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
3653
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
9365
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
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8610
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
9170
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8902
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,...
1
6528
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
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
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.