views:

79

answers:

1

When using TextRenderer.DrawText(), what does setting the TextFormatFlags.Internal flag actually do?

Equivalently, what does setting the DT_INTERNAL flag to Win32's DrawTextEx() function do?

More to the point, when should I set that flag and when should I not set it?

The documentation says: "Uses the system font to calculate text metrics", but I'm not entirely sure what that means. I've done some limited testing and setting the flag seems to change how the font is rendered when using a small font size, but doesn't seem to make a difference when using a large font size.

+1  A: 

It means that regardless of what font you actually use, it does its calculations as if you were using the system font instead. For example, let's assume your system font it 12 points. If you're using a 30 point font along with the DT_INTERNAL flag, each line will only be advanced enough for the (12-point) system font, not your 30-point font, so each line of text will overlap with the previous.

The "INTERNAL" basically means "for Windows' internal use only" -- I'm reasonably certain I've never used this flag in any real code.

Jerry Coffin
FWIW, I have an owner-drawn subitem in a ListView, and I found that I needed to use DT_INTERNAL in order to get my text to look exactly like the text drawn by the ListView itself.
Daniel Stutzbach