Page 1 of 1

How to draw custom control based on some standard controls?

Posted: Tue Oct 28, 2008 9:42 am
by bloodlee
Hi, all.

I want to create a custom button which will draw a small bitmap(4x4) at the left-bottom corner of the button. This bitmap is used to indicate some kind of status.

Before I will write my own OnPaint(), in which I will draw the border, the label and the bitmap. But the work is complex and it will take me a lot of time, like doing some position calculating work, handling resize event and fixing the bad flicker!

This time, I just want to paste a small bitmap on a standard button! I just want to know whether there are some methods to draw the bitmap based on the standard controls. So I can just paint the bitmap on the default well-drawed dc. That will save a lot of time. :D

Any suggestions?
Thanks and regards.

Posted: Wed Oct 29, 2008 8:06 am
by Grrr
You should check wxRendererNative. It has functions to draw standard UI elements.

Posted: Thu Oct 30, 2008 3:21 am
by bloodlee
Thanks. I will have a try.

Re: How to draw custom control based on some standard contro

Posted: Thu Oct 30, 2008 9:53 am
by NinjaNL
bloodlee wrote:This time, I just want to paste a small bitmap on a standard button! I just want to know whether there are some methods to draw the bitmap based on the standard controls. So I can just paint the bitmap on the default well-drawed dc. That will save a lot of time.
You could also use a wxCustomButton from wxThings.

http://wxcode.cvs.sourceforge.net/viewv ... /wxthings/

It has the ability of drawing a button with both a bitap and label. I'm not sure if you can place the bitmap at the lower left, but even here you have options (alter the positioning code of the control / creating a bitmap sized as required - but with the upper part simply reflecting the background colour of the button).

It might offer a starting point for you.