Hi,
I am switching our application over to use GDI text rendering for all the controls. I noticed the text on a button is rendered 1 pixel below where it is rendered using GDIPlus. Is there a way to prevent this? It causes the bottom of the text to be clipped on smaller buttons. The attached print screen shows 2 of the exact same buttons, the one on the left is using GDI.
Thanks,
Bill
Hello,
I am just checking about the progress of this issue. Did you solve your issue accordingly to the information that Michael provided you?
Let me know if you need any further assistance.
Hi Mike,
Thanks for your help. For now we will leave the buttons drawing with GDI Plus
Hi Bill,
I took a look and I see the behavior you are describing, but I don't think there is anything we can do about this.
Both buttons are creating a TextUIElement and they are both in the same position with the same rect. So we are drawing the same text into the same rectangle in both cases, and it's Windows that is behaving differently in GDI than in GDI+. It looks like in GDI mode, they are shifting the text down 1 pixel from the top of the rect for some reason.
The only way around this that I can see is to use a CreationFilter to make the ImageAndTextUIElement bigger.
Or, you could just make the button one pixel taller.
If you want to try the CreationFilter approach, you would do something like this:
MyCreationFilter myCreationFilter = new MyCreationFilter(); private void Form1_Load(object sender, EventArgs e) { this.ultraButton1.CreationFilter = myCreationFilter; } public class MyCreationFilter : IUIElementCreationFilter { #region IUIElementCreationFilter Members void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent) { if (parent is UltraButtonUIElement) { ImageAndTextUIElement imageAndTextUIElement = parent.GetDescendant(typeof(ImageAndTextUIElement)) as ImageAndTextUIElement; if (imageAndTextUIElement != null) { imageAndTextUIElement.Rect = parent.RectInsideBorders; } } } bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent) { return false; } #endregion }