Click here to Skip to main content
15,867,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hey guys,

i'm working on a small project where the user is able to choose a font via a CFontDialog.
When the User selects a Font and Color from the ColorDialog i'm parsing the LOGFONT Structure into a simple String and save this string in a text field.
The string have the basic structure "FaceName,size,color"
Sample: Arial,10,#000000

Before i open the CFontDialog the next time, i parse the string back into a LOGFONT structure.

Now i wan't to write a check function to check if the string is valid or not.
If the string contains invalid letters, i skip the part of the string while i parse it back to a LOGFONT structure, and the Dialog shows the initial values (in case of size = nothing).
But what if the our customer change the font and dont open the CFontDialog again? It's susceptible for errors.

Could anyone suggest me a way, how to check if the parameters are valid or not without opening the CFontDialog?
Then i could check if the parameter is valid when the user press the save button.

I know it is not the best way to implement a font control, but my boss want it this way (i have no idea why)
Posted
Updated 16-Jul-14 19:44pm
v2
Comments
Richard MacCutchan 16-Jul-14 11:33am    
Why are you using CColorDialog and not CFontDialog?
C3D1 17-Jul-14 1:43am    
Oh sorry, that's a miskate. I use the CFontDialog not the CColorDialog.
I correct it right now. Thanks for the hint.

1 solution

Use the EnumFonts[^] function to check if the fontname is valid.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900