Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Don't hard-code font names and size

Total Hit ( 1763)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Unless you have good reason to do otherwise, you should always use standard fonts in your programs, because this ensures that your application will work on every Windows system.

If you want to use non-standard fonts, you should at least adopt the following guidelines:

Click here to copy the following block
Assign the font to form and controls through code in the Form_Load event procedure, not directly to the form or the control at design time. Most important, protect the assignment with an On Error statement, so that if the font 't exist you can still use the default font. doesn
Provide the end user with a method to customize the font name and size, for example by editing an INI file or the Registry. Obviously, editing the Registry is a risky operation, and it should be performed only by experienced users, so usually the INI file is better. Alternatively, provide a distinct utility that configures the program through an easy-to-use interface.
While 're on this topic, please note that in general Visual Basic doesn't raise an error when you assign an unsupported size of a font, but silently uses the closest valid font size that is less than the requested size. Therefore, the only way to test if a given font size actually exists is to check that the assignment was successful. Here's a routine that lets you assign a font size to any object, and returns True if the specified font size is supperted: we
Function SetFontSize(obj As Object, FontSize As Integer) As Boolean
  On Error Resume Next
  obj.Font.Size = FontSize
  SetFontSize = (obj.Font.Size = FontSize)
End Function


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.