Re: (Color myColor = Color.LightBlue) returns value RGB{0x0}??? by Sami
Sami
Thu Jan 27 04:44:33 CST 2005
Hello,
Thanks for the prompt reply.
I might not have been very clear.
My first question was why I get a value of RGB{0x0} for Color.LightBlue (or
any other colour for that matter). Shouldn't it give me a valid RGB value?
As for the second question, I still don't understand your answer.
I am using a non-rectangular bitmap as the background for my form. Then I
set the Transparency Key Property of my form to the same colour as the
background colour of my bitmap image. By default I don't fall through. e.g.
if I have my form directly on top of the desktop I am able to see other app
icons through the transparent background of my form but am unable to start
the apps by double-clicking on them which makes sense since I didn't tell my
code to do that. How would I do that programmatically?
--
Regards,
Sami
[Remove Numbers from e-mail address to use it]
"Morten Wennevik" <MortenWennevik@hotmail.com> schrieb im Newsbeitrag
news:opsk9bd8ygklbvpo@pbn_computer...
> Hi Sami,
>
> There are two possible solutions for the colors not being equal.
> 1: myColor isn't LightBlue
> 2: myColor has a different alpha value than 255, which it probably might
> if the image contains transparent parts.
>
> To ignore the alpha value you can just check for
>
> if(myColor.R == colorToCompare.R && myColor.G == colorToCompare.G &&
> myColor.B == colorToCompare.B)
> {
> //the colors are sort of the same
> }
>
> As for the second question, I never had a problem with clicking on a
> transparent part of my form not falling through. Not sure what kind of
> transparency you are using, try setting the form's TransparencyKey
> property to the same color as the form's backcolor. Use the same
> backcolor for your image's Transparency (I never tried transparent forms
> with bitmaps though, so I'm not sure they would work).
>
>
> On Thu, 27 Jan 2005 10:51:16 +0100, Sami <s8a2m9i1_i5s1l9a6m@hotmail.com>
> wrote:
>
> > Hello,
> > I just started out with Windows.Forms and was going through the MS
> > tutorials.
> > In the tutorial where you can create a non-rectangular shaped window by
> > using your own window painted with some paint utility, I am having some
> > problems with trying to compare the color of the pixel that I retrieve
> > using
> > Bitmap.GetPixel(...) method.
> >
> > My pseudo-code looks like this:
> >
****************************************************************************
> > ******
> > OnMouse_Click(...)
> > {
> > Color myColor = Bitmap.GetPixel(e.X, e.Y);
> > Color colorToCompare = Color.LightBlue; // At this point I notice
> > that the colorToCompare variable has a value of RGB{0x0}???!!! why?
> >
> > if (myColor == colorToCompare)
> > // then execute logic which never does.
> > }
> >
****************************************************************************
> > *******
> >
> > I have another question. The reason I am trying to get the color of the
> > pixel is because I want to allow a mousemove event only when the user
> > clicks
> > the mouse on the visible region of my form and not on its transparent
> > background. But I still have the problem that when a user clicks on the
> > transparent background of my window the icons (e.g.) that I see on that
> > position are not chosen? How can I choose the background items on a
> > desktop
> > or if there is another application on the background when a user clicks
> > on
> > the transparent background of my form?
>
>
>
> --
> Happy Coding!
> Morten Wennevik [C# MVP]