tags:

views:

176

answers:

2

Hello,

Does anyone know any information on implementing the TextImageRelation property on a button? Since it is impossible to paint a custom background without having to also paint the foreground, I need at least an idea of how the algorithm works.

I can't find any info on it.

Thanks

A: 

Your question could use a few more details. I presume you are talking about writing your own implementation of a ToolStripButton? MSDN has a pretty thorough example of how to implement a ToolStripItem (which is the basis for ToolStripButton), including how the TextImageRelation property would be used. Look at the ComputeImageAndTextLayout() method in the example for specifics. I don't understand from your question how the custom background & foreground painting is a problem.

Alan McBee
A: 

Actually I'm making a custom WinForm Button control. The only way to have a custom painting routine is to override the entire Paint call. The problem is that means my own code has to compute the image and text layout. I was wondering if anyone had any information on how the algorithm works.