Saving and applying specific font properties on the fly, from an ASCII file.

  • Thread starter Thread starter RooLoo
  • Start date Start date
R

RooLoo

Hey all!

Using VB.Net... How can I save the font properties of a textbox to an ASCII
file and later read the file and apply the properties back to the textbox?

Users use multiple workstations, so I need to save the info into an INI file
as the registry does not move with the users. Also, the settings will not be
saved in the same location as the program itself, so configuration files
will not work. I need to save the users text preferences and cannot see a
way to do this in VB.Net.

Thanks!
 
You are kidding, right?

As I described... I cannot use the serialization as the file is stored on a
network folder, not with the application.

There MUST be some way to extract the font.bold, font.name, etc. values and
then reapply them later.
 
But why do I need to create a new font object when the textbox already
has a perfectly good font property to manipulate???
 
Some One said:
But why do I need to create a new font object when the textbox
already has a perfectly good font property to manipulate???

Problaby because in Windows, you can't change a font after creation. I'm not
sure, so have a look at

MSDN
graphics and multimedia
Windows-GDI
SDK documentation
Windows GDI
Fonts and Text
 
Hello,

Armin Zingler said:
Problaby because in Windows, you can't change a
font after creation. I'm not sure, so have a look at

AFAIK you are right.

Regards,
Herfried K. Wagner
 
I'm really trying to get this to work with only partial success...

My line of code looks like this (pardon the wrapping):
txtPad.Font = New System.Drawing.Font(iniFile.getValue("FontFace",
"Arial"), Val(iniFile.getValue("FontSize", "10")))

where iniFile.getValue returns a STRING from a file. (
iniFile.getValue(strKey, strDefault) )

The above line of code works, BUT it does not apply any STYLE to the font. I
have not found a way to store the font style to a file and then be able to
recover and reapply it.
 
Hello,

RooLoo said:
My line of code looks like this (pardon the wrapping):
txtPad.Font = New System.Drawing.Font(iniFile.getValue("FontFace",
"Arial"), Val(iniFile.getValue("FontSize", "10")))

where iniFile.getValue returns a STRING from a file. (
iniFile.getValue(strKey, strDefault) )

The above line of code works, BUT it does not apply any
STYLE to the font. I have not found a way to store the
font style to a file and then be able to recover and reapply it.

Convert the font style to an integer and save/load it.

Regards,
Herfried K. Wagner
 
My line of code looks like this (pardon the wrapping):
Convert the font style to an integer and save/load it.

Thanks Herfried, but I did try that and Windows complained about
conversion... To be honest, I used the VAL function (as I did above
for the size of the font) which doesn't return and INT type, but I
assumed that because of the error I was getting, that this wasn't just
a simple enumeration where any numeric value should work.

I will definately look again.
 
Hello,

Snorton said:
Thanks Herfried, but I did try that and Windows
complained about conversion... To be honest, I
used the VAL function (as I did above for the size
of the font) which doesn't return and INT type, but I
assumed that because of the error I was getting, that
this wasn't just a simple enumeration where any numeric
value should work.

Untested:

Did you try "CType(Integer.Parse(<string value representing integer>),
FontStyle)"?

Regards,
Herfried K. Wagner
 
Back
Top