Board index » cppbuilder » Align Text withing RichEdit

Align Text withing RichEdit


2007-01-22 03:41:06 AM
cppbuilder1
Hi,
I Have a Table that feeds a RichEdit with information about customers (name, address, etc.) to enable the user to print labels.
The info is placed on the RichEdit based on a Grid that the user defines. It looks like this
| |
Where the first bar is the location of the start of first label (customer info...) and the second bar is the start of the second label...like this (ideally)
| |
Joe DowJones John Black
123 Best Street 456 Mentra
Denver, CO San Franciso, CA
United States USA
However, after populating the RichEdit using the SelStart and SelText, the text is not aligned!!! and it looks like this
| |
Joe Dow John Black
123 Best Street 456 Mentra
Denver, CO San Franciso, CA
United States USA
The problem is info being inserted under the first bar "pushes" the rest and causes the disalignment
Is there a way I scan all the lines and remove the extra space
and align the text under the second column, so it look like I previously stated
| |
Joe DowJones John Black
123 Best Street 456 Mentra
Denver, CO San Franciso, CA
United States USA
Many thanks in advance
Rob
 
 

Re:Align Text withing RichEdit

rob kemp wrote:
Quote
I Have a Table that feeds a RichEdit
You did not tell how you care for alignment of the collums. But it
looks as if you use space for it.
Why dont you use tab's ? You can adjust the tabpositions.
Hans.
 

Re:Align Text withing RichEdit

Hans Galema wrote:
Quote
looks as if you use space for it.
spaces
Hans.
 

{smallsort}

Re:Align Text withing RichEdit

In fact, I use spaces.
I tried the tabs \t but with some texts, especially small, one tab wasn't enough...and the disalignment accured regardless
Rob
Hans Galema < XXXX@XXXXX.COM >wrote:
Quote
Hans Galema wrote:

>looks as if you use space for it.

spaces

Hans.
 

Re:Align Text withing RichEdit

"rob kemp" < XXXX@XXXXX.COM >wrote:
Quote

In fact, I use spaces.
I tried the tabs \t but with some texts, especially small, one tab wasn't enough...and the disalignment accured regardless

Ive tried using tabs, but found them inconsistant.
I fount that formatting the line worked well using sprintf().
I set the column width for strings like this - %-30s.
and with floats like this %7.2f. This seems to work quite well.
Cheers,
David
 

Re:Align Text withing RichEdit

rob kemp wrote:
Quote
I tried the tabs \t but with some texts, especially small, one tab wasn't enough...and the disalignment accured regardless
Please wrap your lines manually. It is difficult to reply selective now.
One tab should do. Then adjust the tabposition. You did not react on this
remark though.
Hans.
 

Re:Align Text withing RichEdit

"rob kemp" < XXXX@XXXXX.COM >wrote in message
Quote

In fact, I use spaces.
I tried the tabs \t but with some texts, especially small, one tab wasn't
enough...and the disalignment accured regardless
...
why don't you use tables? fill up the cells,
set table's position and col sisez.
 

Re:Align Text withing RichEdit

Do you mean that I should put only one Tab between the
two bars (| TAB |) and then adjust the length of the tab?
How can I adjust the TabPosition? I googled looking for an
example with no success (Borland C++ example)
thanks
Rob
Hans Galema < XXXX@XXXXX.COM >wrote:
Quote
rob kemp wrote:

>I tried the tabs \t but with some texts, especially small, one tab wasn't enough...and the disalignment accured regardless

Please wrap your lines manually. It is difficult to reply selective now.

One tab should do. Then adjust the tabposition. You did not react on this
remark though.

Hans.
 

Re:Align Text withing RichEdit

rob kemp wrote:
Quote
How can I adjust the TabPosition? I googled looking for an
example with no success (Borland C++ example)
You can determine the position for every tab.
// set tabstops
int firstpos = 150;
int distance = 50; //45; //40; //60;
int ntabstops = 10;
if ( RichEdit->Font->Name == "Courier New" )
firstpos = 180;
RichEdit->SelStart = 0;
RichEdit->SelLength = 0xEFFFFFF; // well a large enough value
unsigned char tabstopnr = -1;
//TRichEdit Byte 8-bit unsigned integer unsigned char typedef
int pos = firstpos;
while ( ++tabstopnr < ntabstops )
{
RichEdit->Paragraph->Tab[tabstopnr] = pos;
pos += distance;
}
RichEdit->Paragraph->TabCount = ntabstops;
RichEdit->SelLength = 0;
Hans.