Hello,

I need a button control that will allow me to display mutiple icons/bitmaps
simultaneously.
Say for example you had a standard Forms.Button with text "Device 1" and you
need to display
small icons in each corner of the button to show state/status of Device 1.

Is an owner-drawn button my only option? This sounds like a daunting task.
I am unable to find any code examples or 3rd party products that even come
close.
Its hard to believe that I am the only one that needs such an animal.

Please help if you can.

Thanks, Jeff

Re: Owner-Drawn Buttons in C# by Andy

Andy
Thu Aug 05 11:21:22 CDT 2004

"Jeff" <backspin@sandwedge.com> wrote in message
news:O221iPveEHA.2396@TK2MSFTNGP11.phx.gbl...
> Hello,
>
> I need a button control that will allow me to display mutiple
icons/bitmaps
> simultaneously.
> Say for example you had a standard Forms.Button with text "Device 1" and
you
> need to display
> small icons in each corner of the button to show state/status of Device 1.
>
> Is an owner-drawn button my only option? This sounds like a daunting
task.
> I am unable to find any code examples or 3rd party products that even come
> close.
> Its hard to believe that I am the only one that needs such an animal.
>
> Please help if you can.
>
> Thanks, Jeff
>

I needed such an animal, and found the basis for it here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbpowerpack.asp

However, that is VB, which happened to work for me. It looks like a
sizeable effort to port to C#. But perhaps it can be enought to steer you
in the right direction?

Best Regards,

Andy



Re: Owner-Drawn Buttons in C# by Mick

Mick
Thu Aug 05 12:26:13 CDT 2004

You'll find source for an OwnerDraw button on my site.
http://dotnetrix.co.uk/buttons.html

An alternative is to create a new bitmap of appropriate size and draw an
icon in each corner of the bitmap. Then assign this new bitmap to the
buttons image property.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html


"Jeff" <backspin@sandwedge.com> wrote in message
news:O221iPveEHA.2396@TK2MSFTNGP11.phx.gbl...
> Hello,
>
> I need a button control that will allow me to display mutiple
icons/bitmaps
> simultaneously.
> Say for example you had a standard Forms.Button with text "Device 1" and
you
> need to display
> small icons in each corner of the button to show state/status of Device 1.
>
> Is an owner-drawn button my only option? This sounds like a daunting
task.
> I am unable to find any code examples or 3rd party products that even come
> close.
> Its hard to believe that I am the only one that needs such an animal.
>
> Please help if you can.
>
> Thanks, Jeff
>
>
>
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.719 / Virus Database: 475 - Release Date: 12/07/2004



Re: Owner-Drawn Buttons in C# by Jeff

Jeff
Thu Aug 05 12:46:11 CDT 2004

Mick,

Thanks for the help. I'm looking at your code now.
Wow, you worked hard on this one!

I have been trying to get the bitmap approach to work, but have run into a
Bitmap.MakeTransparent roadblock. This approach should be simple...

If you have a moment, please look at my "Frustration..." post that discusses
the
MakeTransparent bug.

Regards, Jeff



Re: Owner-Drawn Buttons in C# by Mick

Mick
Thu Aug 05 14:14:56 CDT 2004

What's the problem with Bitmap.MakeTransparent()?

Try this code out.

Rectangle BitmapRect = Rectangle.FromLTRB(0, 0, button1.Width,
button1.Height);
BitmapRect.Inflate(-6, -6);
Bitmap srcImage = new Bitmap(@"c:\test.bmp");
srcImage.MakeTransparent();
Bitmap bmp = new Bitmap(BitmapRect.Width, BitmapRect.Height);
Graphics g = Graphics.FromImage(bmp);
//TopLeft corner
g.DrawImage(srcImage, Point.Empty);
//Topright corner
g.DrawImage(srcImage, BitmapRect.Width - srcImage.Width, 0, srcImage.Width,
srcImage.Height);
//BottomLeft corner
g.DrawImage(srcImage, 0, BitmapRect.Height - srcImage.Height,
srcImage.Width, srcImage.Height);
//BottomRight corner
g.DrawImage(srcImage, BitmapRect.Width - srcImage.Width, BitmapRect.Height -
srcImage.Height, srcImage.Width, srcImage.Height);
button1.Image = new Bitmap(bmp);
g.Dispose();
bmp.Dispose();


--
Mick Doherty
http://dotnetrix.co.uk/nothing.html


"Jeff" <backspin@sandwedge.com> wrote in message
news:OZOieQxeEHA.3348@TK2MSFTNGP12.phx.gbl...
> Mick,
>
> Thanks for the help. I'm looking at your code now.
> Wow, you worked hard on this one!
>
> I have been trying to get the bitmap approach to work, but have run into a
> Bitmap.MakeTransparent roadblock. This approach should be simple...
>
> If you have a moment, please look at my "Frustration..." post that
discusses
> the
> MakeTransparent bug.
>
> Regards, Jeff
>
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.719 / Virus Database: 475 - Release Date: 12/07/2004



Re: Owner-Drawn Buttons in C# by Jeff

Jeff
Fri Aug 06 06:20:58 CDT 2004

Mick,

I owe you one!
Your 4-corners icon code works great.
I'm not sure why this call to MakeTransparent( ) works
and the other doesn't (see Frustration post).

Also, your Owner-Drawn button code on your site rocks!
Strategically setting the corner radius even yields a great round button!

For now, I will stick to the simpler "4-corners" code.

Thank you, thank you, thank you!

Regards, Jeff



Re: Owner-Drawn Buttons in C# by Jeff

Jeff
Fri Aug 06 08:56:03 CDT 2004

Mick,

I was focusing on the wrong class.
The Bitmap::MakeTransparent( ) looks fine.
However, Control::BackgroundImage appears to be the culprit.
Using ButtonBase::Image appears to work fine with the bitmap that
was manipulated by MakeTransparent( ).

Lesson learned: avoid BackgroundImage, and use Image instead!

Thanks again.

Regards, Jeff



Re: Owner-Drawn Buttons in C# by Mick

Mick
Fri Aug 06 09:25:21 CDT 2004

I was about to ask why you were using BackgroundImage instead of Image.
Although, even with BackgroundImage I'm not seeing any problem. Perhaps it's
something to do with the image you're using.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html


"Jeff" <backspin@sandwedge.com> wrote in message
news:uHr5e07eEHA.1724@TK2MSFTNGP10.phx.gbl...
> Mick,
>
> I was focusing on the wrong class.
> The Bitmap::MakeTransparent( ) looks fine.
> However, Control::BackgroundImage appears to be the culprit.
> Using ButtonBase::Image appears to work fine with the bitmap that
> was manipulated by MakeTransparent( ).
>
> Lesson learned: avoid BackgroundImage, and use Image instead!
>
> Thanks again.
>
> Regards, Jeff
>
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.719 / Virus Database: 475 - Release Date: 12/07/2004



Re: Owner-Drawn Buttons in C# by Jeff

Jeff
Fri Aug 06 12:23:18 CDT 2004

Mick,

I used BackgroundImage because I didn't know any better.
Prior to getting your solution, I really investigated the
MakeTransparent & BackgroundImage issue. It appears there
may be some platform dependance with BackgroundImage. Some
people see it, others don't. I have tried all types of images
and they all result in a black background with other buttons drawn
on top. (Its pretty wacky). Maybe its a video card/driver
thing?

Thanks for all of your help.

Cheers, Jeff