Question

On a WinForm with an extended borders, when i place a text on the glass area it doesn't appear right.

This is how the text looks like Status

a busy cat http://img833.imageshack.us/img833/4732/95454282.png ![form][1]

how can i fix the text to appear normally?

Was it helpful?

Solution

Text in Winforms is rendered with an alpha of 0. Which makes it transparent when you draw on glass. So you'll see the background color, not the ForeColor you selected.

Drawing text on glass is troublesome, you can't get it easily anti-aliased correctly since the background of the text isn't well defined. Note how the screenshot shows how Windows addresses that problem, the text in the window caption has a milky-white background, thus ensuring that the anti-aliasing properly blends the letter into the background.

Which is what you need to do as well. You get text drawn like that with pinvoke, DrawThemeTextEx() with the DTT_GLOWSIZE flag option. Visit pinvoke.net for the required declarations or use this project. And don't forget to provide a fallback so this window still looks decent on older Windows versions. And newer versions, glass is no longer appropriate for Windows 8.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top