DrawText 3 sentences within a rect
Posted on 2000-02-23
Given a node / rectangular region and a DC, I have 3 text sentences that I want to display
| 102. This is the
| second sentence,
| the number was the
| first. This is the
| third sentence.
The first sentence is the node 'number' which should be shown in a red italic font. The second sentence is in bold (and a slightly larger font). The third sentence is in normal font. It all has to word wrap and the node should grow in size to accomodate all the text.
The ::DrawText API function relies on a single rectangular area, whereas I have three potentially irregularly shaped areas (because I want to draw each sentence appended to each previous sentence, rather than beginning each sentence on a new line).
Some advice I got was that I probably need to use the more primitive CDC:TextOut method, together with CDC:SetTextAlign method. The TextOut method allows to draw a string starting at a specific position with the current font of the DC. However, TextOut does not automatically do wordwrap, so I may have to do wordwrap manually.
Can someone give me the Delphi code to achieve this? The code has to run in a DLL that is callable by my VC++ activeX - so I hope that doesn't complicate things too much.