by William Keith (4 Submissions)
Category: Graphics
Difficulty: Advanced
Date Added: Wed 3rd February 2021
Rating:
(2 Votes)

Recently I found myself wanting more than what DrawText could offer: I wanted to be able to render rich text. Rather than write a function for this myself, I wondered whether I could accomplish this with a RichTextBox, and quite simply in fact. Unfortunately it doesn't render text transparently usually. Unless, that is, you set the WS_EX_TRANSPARENT style, at which point it does render transparently, giving you unlimited text drawing power! Note that the method used to get the RichTextBox to actually draw the text (that is sending it EM_FORMATRANGE) can also be used to measure the text with a slight modification (MSDN will tell you how).
API DeclarationsQuite a few.