Using glyphs in C#

  • Thread starter Thread starter rancidpunx
  • Start date Start date
R

rancidpunx

Hi!

I want to do kind of an easy thing, but i don't now HOW:

I have a lot of buttons, i want to place glyphs on them!
Unfortunately, i didn't found kind of a "glyph-property", so i don't
know how to do that!

I just thought about writing a class that handles this on my own, but
it's sounds a bit hard! ;-)
Furthermore, I'm very surprised that this function isn't natively
supported?!?

Home somebody can help!
 
maybe this will work for you...

Button btn = new Button()
btn.Image = Image.FromFile("filename");

Regards,
John
 
A glyph is a symbol. A symbol is an image. Are you saying that you don't
know how to put an image on a button? Or am I lacking some key piece of
information?

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

A lifetime is made up of
Lots of short moments.
 
A glyph IS a symbol / image indeed, BUT a glyph contains the images of
several states, for example in a glyph there are 2 images, one for the
state the button is klicked (and stays clicked), and one for the button
in "normal" state!

I know, i could use 2 images instead, and simply change it in depending
of the button-state for example, but i have A LOT of buttons, and i
often used my glyphs in an other programming language and it all worked
fine....
 
Ah, my bad, I didn't realize you were talking about the "Glyph" that is part
of the System.Windows.Forms.VisualStyles namespace. I thought you were
talking about the generic term. Sorry.

I must confess I haven't had much opportunity to delve into this namespace
very deeply. It's some pretty deep and complex stuff. It's all linked in
with the XP Operating System, and it's skinning ability. I don't really
think that's what you want. Perhaps instead you could create your own
inherited Button class, your own Glyph class, with several different Bitmaps
to use, and manage the OnPaint method of the Button to draw the surface of
the Button with one of the Bitmaps, depending upon the Button state.

If you're interested in digging into the System.Windows.Forms.VisualStyles
namespace, there's plenty of documentation on it in the MSDN Library:

http://msdn2.microsoft.com/en-us/system.windows.forms.visualstyles.aspx

Your basic starting point looks to be 2 classes: VisualStyleElement and
VisualStyleRenderer.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

A lifetime is made up of
Lots of short moments.
 
Thanks, i'll try it!


Kevin said:
Ah, my bad, I didn't realize you were talking about the "Glyph" that is part
of the System.Windows.Forms.VisualStyles namespace. I thought you were
talking about the generic term. Sorry.

I must confess I haven't had much opportunity to delve into this namespace
very deeply. It's some pretty deep and complex stuff. It's all linked in
with the XP Operating System, and it's skinning ability. I don't really
think that's what you want. Perhaps instead you could create your own
inherited Button class, your own Glyph class, with several different Bitmaps
to use, and manage the OnPaint method of the Button to draw the surface of
the Button with one of the Bitmaps, depending upon the Button state.

If you're interested in digging into the System.Windows.Forms.VisualStyles
namespace, there's plenty of documentation on it in the MSDN Library:

http://msdn2.microsoft.com/en-us/system.windows.forms.visualstyles.aspx

Your basic starting point looks to be 2 classes: VisualStyleElement and
VisualStyleRenderer.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

A lifetime is made up of
Lots of short moments.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top