Tech Note 11b: NS Basic Controls Fonts

Feb 27, 2007

© NSB Corporation. All rights reserved.

NSFont ActiveX

This control is part of NS BASIC Controls package. Please see its documentation to get full information about this package.

1. Overview

The NSFont control is not a visual object. It is a standard storage for font settings used by the visual controls in the library. Like the image lists you rarely need to create it directly. The controls that use one or more NSFont objects create them implicitly and expose them to the application through their properties. From that point further you just change the properties of the exposed font as needed. For example to make the font bold in a list view control you simply need to do this:

NSListView1.Font.Bold = True

Of course, it is possible and sometimes more convenient to create a NSFont object initialize it and then assign to the corresponding property of a control. For example you may have two list views on a form and you want to set up them with the same font.

' Somewhere the font is created
AddObject "NSBasic.comctl.NSFont","MyFont"

' The font is changed/initialized - for example you may provide the user with a font selection dialog
' for the sake of the example lets do something simple:
MyFont.Size = 8
MyFont = "Tahoma"
MyFont.Italic = True

' Then assign the same font to the two list views on the form:
Set NSListView1.Font = MyFont
Set NSListView2.Font = MyFont

This enables the developer to choose how to work with the fonts - think of them as of a grouped font related properties - all accessible as objet.Font.<font_property> or construct font setting separately and then assign them to the controls that need them.

2. Members reference

NSFont object

For example the object can be accessed like this:

Set fnt = NSListView1.Font
or
AddObject "NSBasic.comctl.Font","NSFont"
or manipulated as par of the object to which it applies
object.Font.Bold = True

Members reference

Name Syntax Description
 
Bold object.Bold = b
b = object.Bold 
 
Charset object.Charset = v
v = object.Charset 
 
Italic object.Italic = b
b = object.Italic
 
Name object.Name = fontname
fname = object.Name
 
Size object.Size = v
v = object.Size 
 
Strikethru object.Strikethru = b
b = object.Strikethru
 
Underline object.Underline = b
b = object.Underline