Board index » cppbuilder » Captions regarding Form's DFM (similar question)

Captions regarding Form's DFM (similar question)


2003-10-23 10:24:55 AM
cppbuilder17
hello again!
okay, ive posted a question about text being converted
when the form is saved into a dfm.
<thanks for the ever-helpful mr.gambit for replies>
so, now i understand what happens with the text.
but now i need to know how to convert it back to ansistring.
elaborate...
when i saved a form with a button with a caption "arigatou"
in japanese characters, and the dfm is created. then i
get this value #12354#12426#12364#12392#12358 as the caption.
how can i convert "#12354#12426#12364#12392#12358" back
into the original AnsiString?
btw im reading the dfm, and not loading it as a form.
so i would be getting the "#123..." value as a string too.
oh! and is set the option "Text DFM" in bcb6 when saving the form.
pls, pls, pls help.
 
 

Re:Captions regarding Form's DFM (similar question)

"mickey" < XXXX@XXXXX.COM >wrote in message
Quote
how can i convert "#12354#12426#12364#12392#12358"
back into the original AnsiString?
The easiest way to work with the DFM data is to use TReader and TWriter, not
to try to manipulate the data directly. There is too much to support
manually that is already implemented for you. Then you can simply call
TReader::ReadString() and TReader::ReadWideString() when needed.
Th alternative is to use the undocumented TParser class, which the DFM
streaming system uses internally for helping with the parsing of the DFM
when it is in text mode.
Quote
btw im reading the dfm, and not loading it as a form.
so i would be getting the "#123..." value as a string too.
oh! and is set the option "Text DFM" in bcb6 when saving the form.
I don't know where the "Text DFM" feature actually comes into play, but the
actual DFM streaming code always works in binary mode. My guess would be
that only the .DFM file itself is stored in Text, but is then always
converted to binary when being stored to the application's resources during
compiling/linking. At some point, it has to be converted to binary when the
stream starts involving loading the DFM into actual component instances.
Gambit
 

Re:Captions regarding Form's DFM (similar question)

"mickey" < XXXX@XXXXX.COM >wrote in message
Quote
how can i convert "#12354#12426#12364#12392#12358"
back into the original AnsiString?
If you have it available, I would strongly suggest that you look at the VCL
source code, all of the DFM parsing and streaming is in Classes.pas.
Gambit
 

{smallsort}

Re:Captions regarding Form's DFM (similar question)

->Classes.pas.
oh! this file is interesting!
and yeah i was able to convert the #123... kind of value
to its original string
i made the digit part (12354) into a value of a SmallInt,
then i set this SmallInt into a value of a WideCharacter.
then putting these characters into an ansistring was
easy. i just followed how the classes.pas did it.
and i hope i did it right.
->Gambit
once again, you are such a great help!
a million thanks! ...make that a gazillion!
 

Re:Captions regarding Form's DFM (similar question)

"mickey" < XXXX@XXXXX.COM >wrote in message
Quote
i just followed how the classes.pas did it. and i hope i did it right.
Why not just use the existing functionality that Classes.pas exposes, rather
than trying to re-write everything manually?
Gambit