BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DrawText / DrawText, word wrapping and long strings

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
Mike Collins
Guest





PostPosted: Wed Jul 12, 2006 9:17 pm    Post subject: DrawText / DrawText, word wrapping and long strings Reply with quote



Hi all, got what seems like a really simple problem but can work out how to
solve it. I'm coding up a function in a DLL that will print a registration
card for the user to send to use.

Instead of having the hassel of using a reporting tool, i decided to simply
use the TPrinter object and write directly to the canvas. All seems pretty
fine and dandy until i came to try and display the registration code. It is
the product of an public / private encryption system and the resultant data
/ ansistring is 172 characters long and is a solid block of text without any
spaces in it.

When I use this with DrawText or DrawTextEx it will not wrap the test so the
string goes of the end of the canvas / page. I assum this is because it
can't find any blank spaces between 'words'. I've tried all variations of
the flags but i get the same results...

Does anyone have any suggestions that i can use?

Many thanks in advance...

Mike C
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Jul 12, 2006 9:57 pm    Post subject: Re: DrawText / DrawText, word wrapping and long strings Reply with quote



"Mike Collins" <its (AT) TheBottomOfThePost (DOT) com> wrote in message
news:44b5208b (AT) newsgroups (DOT) borland.com...

Quote:
the resultant data / ansistring is 172 characters long and is a solid
block of text without any spaces in it.

Does it have any hyphens in it?

Quote:
When I use this with DrawText or DrawTextEx it will not wrap the
test so the string goes of the end of the canvas / page. I assum this
is because it can't find any blank spaces between 'words'.

Spaces are not the only thing that can allow a string to be split.

I am assuming that you are specifying the DT_WORDBREAK flag, is that right?
What does the string actually look like?


Gambit
Back to top
Mike Collins
Guest





PostPosted: Wed Jul 12, 2006 10:07 pm    Post subject: Re: DrawText / DrawText, word wrapping and long strings Reply with quote



Yep, using the DT_WORDBREAK flag.

The encrypted block of text looks like this:
"U8m8Kr2hMPiT7Fs2XfDgtKVaID+XVSILmivZ3u/4gwjp6+ehDRo5NOUPSbIQWN7oUkdc0tMgKahe1dFr1joY1OtJ10wq7f87LLSVP0ZmhkG3hdrzKaMnZwxHozhGmHZLUgkoIVSpUb+hz/iGbvTYKUg7eljYjg0Ntbs72qoNFwk="

- the newsreader might wrap this... I'm passing it into the DLL as a char
pointer. I'm trying to write it out into a block with the canvas.

Any ideas?


"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote in message
news:44b529fa$1 (AT) newsgroups (DOT) borland.com...
Quote:

"Mike Collins" <its (AT) TheBottomOfThePost (DOT) com> wrote in message
news:44b5208b (AT) newsgroups (DOT) borland.com...

the resultant data / ansistring is 172 characters long and is a solid
block of text without any spaces in it.

Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Jul 13, 2006 5:15 am    Post subject: Re: DrawText / DrawText, word wrapping and long strings Reply with quote

"Mike Collins" <its (AT) TheBottomOfThePost (DOT) com> wrote in message
news:44b52c62 (AT) newsgroups (DOT) borland.com...

Quote:
The encrypted block of text looks like this:

That is a base64-encoded string. There are no characters in base64 that
allow adequate word breaking. You will have to break up the string
manually, such as every xx number of characters. That is what email does,
for instance - each line is a fixed number of characters (usually around 76)
regardless of the encoding used. You could use 86 to break the line into of
2 lines of even length. Alternatively, you will likely have to query your
Canvas for the number of available pixels per line, and the number of pixels
per character, and then manually draw different portions of the string
accordingly on multiple lines.


Gambit
Back to top
Mike Collins
Guest





PostPosted: Thu Jul 13, 2006 7:25 am    Post subject: Re: DrawText / DrawText, word wrapping and long strings Reply with quote

Cool, that is what i figured - can't expect everything from the api's. It's
not a huge issue, the canvas size should not change drastically and I know
the size of encrypted block.

Just out of interest, do you know any good references on this sort of
thing - i want to create a more advanced print out i.e. watermarks and
possibly angled or rotated text but i can seem to find much other that
DrawText and TextOut...

As always, thanks alot for you help,

Mike C


"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote in message
news:44b590c9$1 (AT) newsgroups (DOT) borland.com...
Quote:

"Mike Collins" <its (AT) TheBottomOfThePost (DOT) com> wrote in message
news:44b52c62 (AT) newsgroups (DOT) borland.com...
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Jul 13, 2006 8:10 am    Post subject: Re: DrawText / DrawText, word wrapping and long strings Reply with quote

"Mike Collins" <its (AT) TheBottomOfThePost (DOT) com> wrote in message
news:44b5af24 (AT) newsgroups (DOT) borland.com...

Quote:
Just out of interest, do you know any good references on this sort
of thing - i want to create a more advanced print out i.e. watermarks
and possibly angled or rotated text but i can seem to find much other
that DrawText and TextOut...

Use CreateFontIndirect() to use rotated fonts. Set the lfOrientation member
of the LOGFONT structure to the angle of rotation. You can then use
SelectObject() to apply the font to any Canvas prior to writing text on it.
Make sure that you are using a TrueType font, though.


Gambit
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.