How to draw custom control based on some standard controls?

Are you writing your own components and need help with how to set them up or have questions about the components you are deriving from ? Ask them here.
Post Reply
bloodlee
Experienced Solver
Experienced Solver
Posts: 77
Joined: Thu Nov 30, 2006 10:49 am
Location: Shenzhen, CHN

How to draw custom control based on some standard controls?

Post by bloodlee » Tue Oct 28, 2008 9:42 am

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.

Grrr
Earned some good credits
Earned some good credits
Posts: 126
Joined: Fri Apr 11, 2008 8:48 am
Location: Netherlands

Post by Grrr » Wed Oct 29, 2008 8:06 am

You should check wxRendererNative. It has functions to draw standard UI elements.

bloodlee
Experienced Solver
Experienced Solver
Posts: 77
Joined: Thu Nov 30, 2006 10:49 am
Location: Shenzhen, CHN

Post by bloodlee » Thu Oct 30, 2008 3:21 am

Thanks. I will have a try.

NinjaNL
Moderator
Moderator
Posts: 899
Joined: Sun Oct 03, 2004 10:33 am
Location: Oosterwolde, Netherlands

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

Post by NinjaNL » Thu Oct 30, 2008 9:53 am

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.
Follow the development of my screenplay authoring program at http://wxscreenplaywriter.blogspot.com/

Post Reply