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

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!
 
R

RooLoo

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.
 
S

Some One

But why do I need to create a new font object when the textbox already
has a perfectly good font property to manipulate???
 
A

Armin Zingler

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
 
H

Herfried K. Wagner

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
 
R

RooLoo

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.
 
H

Herfried K. Wagner

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
 
S

Snorton

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.
 
H

Herfried K. Wagner

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top