views:

83

answers:

1

Hi, I would like to have a line aligned in such way, that some first words are aligned left and some last words are aligned right, but all are in the same line:

| text 1                           text2 |
| Lorem ipsum             dolor sit amet |

Is that possibile? How can I do that?

+1  A: 

As far as I know, the only way is to use tab stops. You simply create a right-justified tab stop at the very right edge. Then you have to write your text as

text 1\ttext2
Lorem ipsum\tdolor sit amet

where \t is a Tab character (i.e. U+0009).

Andreas Rejbrand
This is ok, but I have several problems defining tabstops. For example I can't make Right-aligned tab work. I use RichEdit20.dll on windows 7 so setting pf.rgxTabs to 0x2000000 should work, am I wrong?
bartek
See http://msdn.microsoft.com/en-us/library/bb787942(v=VS.85).aspx:"Bits 24-27 can specify one of the following values to indicate the tab alignment. These bits do not affect the rich edit control display for versions earlier than Microsoft Rich Edit 3.0."
Andreas Rejbrand
But according to http://msdn.microsoft.com/en-us/library/bb787873(v=VS.85).aspx Riched20.dll corresponds to Microsoft Rich Edit 3.0
bartek
Yes, it shoud definitely work. 3.0 was included already in Windows ME...
Andreas Rejbrand
@bartek: You shoud set rgxTabs to ThePositionOfTheRightEdge + 0x2000000. ThePositionOfTheRightEdge should be in the order or a few thousand "twips". But I am not able to make the tab stop right-aligned either...
Andreas Rejbrand
I just tried to create a RTF file in Microsoft Word 2007 that uses right-justified tab stops, and when I load the RTF file in my RichEdit control, the tab stop is indeed right-aligned, and the PARAFORMAT2 looks exactly as we expect. It is somewhat of a mystery why it does not work...
Andreas Rejbrand
Although generally a very ugly solution, it might be sufficient for your needs: You could create a RTF file in Microsoft Word and include it as a resource stream in your EXE, and then simply load it programmatically into the RichEdit control. Then, of course, you can alter the contents of the control programmatically, but retaining the right-aligned tab stop. If nothing else works, this might be *good enough* for your application. After all, many features of the RichEdit control are just to support reading of files created in Microsoft Word.
Andreas Rejbrand