Board index » cppbuilder » Saving Memo Font to ini?

Saving Memo Font to ini?

  Hiyas.  I let the user specify a font/background color for a Memo, and
I'd like to save that info in an ini and reload it the next time the
program is run.  I only need to save:

Memo -> Color
Memo -> Font -> Name
Memo -> Font -> Color
Memo -> Font -> Style..  which has bold/italic/underline/strikeout settings
Memo -> Font -> Size

Any help on using WritePrivateProfileString to save these values would be
most appreciated. (They aren't normal string values..which makes it
difficult).

Thanks.  =)

--inedag

///////////////

"...I'm not one of those who think Bill Gates is the devil. I simply
suspect that if Microsoft ever met up with the devil, it wouldn't need an
interpreter."

(From N. Petreley's column, "Down to the Wire", Sep. '96 issue of
Inforworld)

///////////////

 

Re:Saving Memo Font to ini?


Here's a hack I "created" some time ago,
it's using an undocumented "feature" to read
the inner value of the TFontStyle Set:

create some variables "transfer"-variables;

   TFontStyles style_dummy;

// set up the reference to the dummy Style- variable:

   long &style_ref = (long &)style_dummy;
   style_ref = 0; // <<<< important if the "set" only contains 8 bits...

To save the style to the inifile:

   style_dummy = Memo1->Font->Style; // move the Style to the dummy

   IniFile->WriteInteger(... style_ref);  // style_ref is refering to
style_dummy

To read it back again:

   style_ref = IniFile->ReadInteger(...);    // read the value from the
inifile
   Memo1->Font->Style = style_dummy;  // assign the Style-values to Memo

You have to convert the value from style_ref (long) to the string yourself
<g>

Ingvar

-------------------------

inedag <ine...@hotmail.com> skrev i inl?gg
<01bd261e$8bbc74e0$c908a...@none.cts.com>...

Quote
>   Hiyas.  I let the user specify a font/background color for a Memo, and
> I'd like to save that info in an ini and reload it the next time the
> program is run.  I only need to save:

> Memo -> Color
> Memo -> Font -> Name
> Memo -> Font -> Color
> Memo -> Font -> Style..  which has bold/italic/underline/strikeout settings
> Memo -> Font -> Size

> Any help on using WritePrivateProfileString to save these values would be
> most appreciated. (They aren't normal string values..which makes it
> difficult).

> Thanks.  =)

> --inedag

Other Threads