Thread View: borland.public.cppbuilder.nativeapi
6 messages
6 total messages
Started by Mike Collins
Wed, 12 Jul 2006 16:17
DrawText / DrawText, word wrapping and long strings
Author: Mike Collins
Date: Wed, 12 Jul 2006 16:17
Date: Wed, 12 Jul 2006 16:17
21 lines
1966 bytes
1966 bytes
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
Re: DrawText / DrawText, word wrapping and long strings
Author: Remy Lebeau (TeamB)
Date: Wed, 12 Jul 2006 16:57
Date: Wed, 12 Jul 2006 16:57
20 lines
1582 bytes
1582 bytes
"Mike Collins" <its@TheBottomOfThePost.com> wrote in message news:44b5208b@newsgroups.borland.com... > 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? > 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
Re: DrawText / DrawText, word wrapping and long strings
Author: Mike Collins
Date: Wed, 12 Jul 2006 17:07
Date: Wed, 12 Jul 2006 17:07
21 lines
1825 bytes
1825 bytes
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@no.spam.com> wrote in message
news:44b529fa$1@newsgroups.borland.com...
>
> "Mike Collins" <its@TheBottomOfThePost.com> wrote in message
> news:44b5208b@newsgroups.borland.com...
>
>> the resultant data / ansistring is 172 characters long and is a solid
>> block of text without any spaces in it.
>
>
Re: DrawText / DrawText, word wrapping and long strings
Author: Remy Lebeau (TeamB)
Date: Thu, 13 Jul 2006 00:15
Date: Thu, 13 Jul 2006 00:15
18 lines
1826 bytes
1826 bytes
"Mike Collins" <its@TheBottomOfThePost.com> wrote in message news:44b52c62@newsgroups.borland.com... > 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
Re: DrawText / DrawText, word wrapping and long strings
Author: Mike Collins
Date: Thu, 13 Jul 2006 02:25
Date: Thu, 13 Jul 2006 02:25
20 lines
1783 bytes
1783 bytes
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@no.spam.com> wrote in message news:44b590c9$1@newsgroups.borland.com... > > "Mike Collins" <its@TheBottomOfThePost.com> wrote in message > news:44b52c62@newsgroups.borland.com... >
Re: DrawText / DrawText, word wrapping and long strings
Author: Remy Lebeau (TeamB)
Date: Thu, 13 Jul 2006 05:37
Date: Thu, 13 Jul 2006 05:37
16 lines
1625 bytes
1625 bytes
"Mike Collins" <its@TheBottomOfThePost.com> wrote in message news:44b5af24@newsgroups.borland.com... > 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads