Vote for this Product at ClarionShop
 
Buy now at ClarionShop
Version Gold

www.capesoft.com
Updated
Wednesday 28 May 2008
c3pa approved
     

Contents

Introduction
Installation
JumpStart
Example
Programmer's Guide
FAQ
Support
Purchasing AnyFont
Distribution

Relationship with other 3rdParty products

The Global AnyFont Extension
Global General Tab
Global Multi-DLL Tab
Global Default Font Tab
Global Save & Load Tab
The Local AnyFont Extension
Local General Tab
Local Classes Tab

Class Method Reference
Class Properties and Global Variable Reference
Properties
Global Variables

Embeds

Version History
License & Copyright


Introduction

Introduction
 

 
  

CapeSoft AnyFont extension allows you to change different properties of your application font at run-time. Settings can be saved using an .INI file or the registry.
 
The great thing about AnyFont is that it resizes the window to accommodate the different font sizes, as well as moving the window controls proportionally.
 
If you don't want AnyFont to be quite so clever, you can disable certain features so that you can use other moving and sizing programs. You can even control the behaviour of individual window controls.
 
Using AnyFont you can change the application's font name, size, colour, style and character set.
 
AnyFont supports Clarion 5.5 and later, both ABC and Legacy. Clarion 5 is not supported.
 
 
     



Installation

Run the supplied installation file. CapeSoft AnyFont adheres to the standards layed out by by the C3PA (Clarion 3rd Party Association) for 3rd party Accessory installation:

Template (anyfont.tpl and anyfont1.tpw) - Clarion\3rdparty\template\
Source code (anyfont.clw and anyfont.inc) - Clarion\3rdparty\libsrc\
Examples - Clarion\3rdParty\Examples\AnyFont\



This jumpstart shows you how to add font resizing to your application. You won't even have to type a single line of code.

Adding AnyFont to your Application.
To add the AnyFont template to your program, do the following:

This will add the global extension to you application. It will also add local extensions to each of your windows. No parameters need to be changed in order to get AnyFont working.

Changing your Application's Default Font
This can be done in the Global Default Font tab.

Adding the Embedded Code to Change the Font.
This is normally done via a menu command using the FontDialog procedure. To make your life easier, embedded code has already been written for you.

  1. Create a "Change Font..." menu item in your application's menu editor.
  2. Go to the Embeds section in the Actions tab.
  3. Expand the whole tree and double-click on the "Accepted | Generated Code" item. 
  4. Select "AnyFontDialog - Call FontDialog to set Font parameters". The name of the Change Font window is editable, but the default has already been added for you.

Your application is now ready for use!

Example

There is an example in your \Clarion\3rdParty\Examples\AnyFont\Demo directory. The example shows a simple application that allows storage of names and addresses. An example screen is shown below.

 

Programmer's Guide

Writing Code for AnyFont
Normally, the only code you will have to add is the FontDialog embed point. This is called "AnyFontDialog - Call FontDialog to set Font parameters". The Jump Start guide shows how to add this embed point.

If you want to be more adventurous and not use the font dialog, the AnyFont global variables are just what you need. To change the font parameters, follow these steps.

Setting the font manually, along with window-resizing templates
If you set the font using the AnyFont dialog box, no extra code needs to be written. However, if you change the font size manually you will have to insert some code if you are using a window-resizing template. 

NOTE: In all the following examples, the parameters shown by (...) must be supplied as specified in this document.

Listbox Style Behaviours for Different Clarion Versions
Certain versions of Clarion do not read listbox styles correctly. These are Clarion 5.5 up to Clarion 6.1, RC5.

FAQ

I get a template Assert requiring me to modify my existing legacy templates. What must I do?

I lost my settings after upgrading AnyFont.

1. Why don't all my open windows' fonts update immediately?
2. Why don't my listbox styles update correctly?
3. When I change the font properties, why does moving and resizing of the controls not work properly?
4. When I increase the font size so that the window is too large for the screen, some controls disappear when I decrease the font size. How do I fix this?
5. AnyFont doesn't remember my window's position correctly.
6. The controls on my MDI child window don't resize.
7. How do I disable AnyFont dynamically?
8. My windows flicker a lot when I open/resize them.
9. I'm using C55 and when I change the Font color, my XP theme gets lost on my buttons.
10. I get a template Assert requiring me to modify my existing legacy templates. What must I do?
11. How do I restrict my users to select a certain range of font settings?
12. My decimal fields are not correctly justified when using a larger font.

1. Why don't all my open windows' fonts update immediately?

Answer:  All windows, except the window in which the font was changed, will display their new font only when they are newly opened. To update all the windows' fonts, close the application and re-open it.

2. Why don't my listbox styles update correctly?

Answer: You are probably using Clarion 5.5 or 6.0. These versions of Clarion do not read the proplist styles correctly.

3. When I change the font properties, why does moving and resizing of the controls not work properly?

Answer: You're probably using a move-and-resize template that isn't supported yet. At the moment the resizers that AnyFont supports are the standard WindowResize template and IngaSoft's EasyResizeAndSplit v2.07. However, support for more resizers is on the way. In the meantime, there are a few ways to fix this.

  1. Override the way these templates handle moving and sizing.
  2. Disable AnyFont's moving and sizing using the local window template and handle these functions either manually or using one of the 3rd-party templates.
  3. Change to a supported resizer template.

4. When I increase the font size so that the window is too large for the screen, some controls disappear when I decrease the font size. How do I fix this?

When the window becomes too large for the screen, the size of the window (in Clarion units) decreases even though the actual size, in pixels, increases. Here are two ways to fix this.

  1. Put in a valid value for the window's minimum size. This will stop the window shrinking.
  2. Add one of the supported resizer templates to your window (see FAQ number 3). This won't stop the window shrinking but the window controls will adjust their size and positions accordingly.

5. AnyFont doesn't remember my window's position correctly.

This may be caused by other code that executes after AnyFont.SetWindow has been called, such as the INI manager or a resizer template. To find out if AnyFont is the culprit, insert the following lines after the call to SetWindow:

    display()
    stop('SetWindow called')

If the window displays in the wrong place, then AnyFont is indeed causing the problem. Please call support if this the case.

6. The controls on my MDI child window don't resize.

This is probably caused by setting the font directly in the child window. The correct way of setting the font in an MDI application is to do it in the MDI menu.

7. How do I disable AnyFont dynamically?

To disable AnyFont globally, set the global variable AnyFont:Disable to true. To disable AnyFont in a single window, set the ThisAnyFont.AFdisable variable to true, or call ThisAnyFont.Disable().

8. My windows flicker a lot when I open/resize them.

Answer 1: To use the buffer attribute in a window, you can turn on prop:buffer (in the window.init method after opening the window).

0{prop:Buffer} = 1

This does adversely affect some 3rdparty tools - so this may not be an option in all situations.

Answer 2: There's a problem in one of the ABC methods. For a workaround:

1. Open your ABTOOLBA.clw file in a text editor.
2. Search for ToolbarUpdateClass.DisplayButtons PROCEDURE
3. Go to the last line of the procedure:

      DISPLAY(Toolbar:First,Toolbar:Last)

and comment it out (probably line 240 of ABTOOLBA.clw):

      !DISPLAY(Toolbar:First,Toolbar:Last)

4. Save and exit.

9. I'm using C55 and when I change the Font color, my XP theme gets lost on my buttons.

Answer: C55 does not support Font colorisation and XP theme. If you change the font color manually (in a non-AnyFont app) you will see the effect. The only solution is to upgrade to Clarion6.

10. I get a template Assert requiring me to modify my existing legacy templates. What must I do?

You need to add an extra embed point into the Standard.tpw file (which is located in your Clarionx\template directory).

Open the file in a text editor, and search for the following text:

INISaveWindow(

Immediately after this line, insert a new line with the following code (which you can copy and paste from this document):

#EMBED(%BeforeWindowClosingAfterSaveINI,'Before Closing the Window - After Saving INI')

Close your application and re-open it (you may need to re-register your Clarion templates if your IDE is not set to re-register templates on update), then recompile and run it.

11. How do I restrict my users to select a certain range of font settings?

Answer: You can quite easily reject the settings if the font settings fall outside the parameters that you require.

You'll need to handcode before the template generated code (in the Validate User Font Selection embed):

if ValidateFontSettings() = false  !This is a function you create to return whether the font settings are valid or not
  message('Warn user he has selected the incorrect font settings')
  cycle
end
ThisAnyFont.SetWindow(AnyFont:FontName,AnyFont:FontSize,AnyFont:FontColor,AnyFont:FontStyle,AnyFont:FontCharset,0) !Template generated code

12. My decimal fields are not correctly justified when using a larger font.

Answer: You will need to Right-justify decimal settings as the RTL does not position a font adjustment decimal justification after the control is created.

I lost my settings after upgrading AnyFont.

Vista (operating under UAC) does not allow programs to write to the Local Machine section of the registry settings. In version 1.51, AnyFont now supports storing the AnyFont settings in the Current User section of the registry by default. you can revert back to using the Local Machine section of the registry (a setting in theGlobal Save & Load Tab), which will maintain your current settings, but will make your program Vista unfriendly.


Support

Your questions, comments and suggestions are welcome. Check our web page (www.capesoft.com) for new versions. You can also contact us in one of the following ways:

CapeSoft Support
  Email support@capesoft.com
 
Telephone +27 21 715 4000
Fax +27 21 715 2535
Snail Mail PO Box 511, Plumstead, 7801, South Africa
     


Purchasing AnyFont

AnyFont is now Gold. It is on sale for $49.00.

Buy Online
 

Purchase CapeSoft AnyFont for $49 from:

Buy now at ClarionShop
www.clarionshop.com 
 
     

CapeSoft Sales
  Web www.capesoft.com  
Email sales@capesoft.com
Telephone +27 21 715 4000
Fax +27 21 715 2535
Snail Mail PO Box 511, Plumstead, 7801, South Africa
     

Distribution

No additional files are required for shipping. 



The Global AnyFont Extension

See the Jump Start for information on how to add the Global Extension. The global extension allows you to set the default font for your application, as well as allowing you to save your font settings in a .INI file.

Global General Tab
Global Default Font Tab
Global Multi-DLL Tab
Global Save & Load Tab

Global General Tab
 

Disable All AnyFont features
Disables all AnyFont code, useful for debugging to find out whether a problem is being caused by AnyFont.

 
     

 

Global Default Font Tab
 

Font Parameters
These parameters override the application font settings. 

All the fields can accept either literal values or program variables. To enter a variable, check the 'Var' button next to the relevant field.

Font Name
The application font name. This can be any supported windows font. If the default application font is the same as the window font, leave the field empty. 
NOTE: The font name can be entered with or without quote marks.

Font Size
The application font size in points. See the note at the end of this section. For default size, set the value to -1.

Font Colour
Choose a colour from the colour box or enter the value manually. You can use either a colour definition (e.g. color:black) or an RGB value. For default colour, set the value to -1 (color:none).

Font Style
Choose a font style from the drop-down list. The default is 'None', which equates to -1.

Font Charset
Choose a font character set from the drop-down list. The default is 'None', which equates to -1.

Change Font...
This is an alternative method to set the font parameters. NOTE: This button is not available in C55.

Support ClearType
If you're using ClearType fonts, checking this option will change the font of all your Entries, Spin Buttons and Combos into MS Sans Serif.

 
     

 

Global Multi-DLL Tab
 

This is part of a Multi-DLL program
Check this box if the program has multiple DLLs. If the program is a DLL this will be ticked as the default.

This is the Root DLL
Check this box if this program is the root DLL of a multiple-DLL application.

This option is activated if the Multi-DLL checkbox is ticked. 

NOTE: the Default and Load & Save tabs are not available if the program is a DLL.

 
     

 

Global Save & Load Tab
 

Save Settings
Check this box if you want to save the font settings.

Which Storage Method?
Choose to save the settings in either an INI file or the system registry.

 

Save in Program's INI
Check this box if you want to store the settings in the program's INI file.

INI File Name
If you want to store the settings in another INI file, enter its name here.

 

 

 

Registry Folder
The settings are saved in either the Local Machine\Software or the Current User section of the Windows Registry. Choose one of the three options to save the settings. If Other is checked, the registry entry must not be blank. This entry may be a variable or a literal string, as shown in the figure.    

 
 
     

 


The Local AnyFont Extension

This allows you to control how AnyFont will behave for each window in your application. 

NOTE: If the extension is in a report or source template, then AnyFont will be automatically disabled.

Local General Tab
Local Classes Tab
Local Tab (disabled)

Local General Tab
 

Disable AnyFont in this Procedure
Disables all AnyFont code in this procedure. This is useful for debugging.

Disable Moving and Sizing of Controls
Stops AnyFont from changing the position and size of the window controls. This is useful when you want other code to do the moving and sizing instead.

Override Individual Control Behaviour
You can set individual controls so that AnyFont doesn't resize it or change its font. The options window is shown in Local Control Options.

 
     

 

Local Control Options Tab
 

Window Control:
The name of the desired control.

Disable Resize
Tick to disable resizing of the control.

Disable Font Change
Tick to leave the control font alone.

 
     

 

Local Classes Tab
 

Object:
The name of the AnyFont instance used in the window. ThisAnyFont is used by default.

Class:
You can specify your own class to use. AnyFont is used by default.

 
     

 

Local Tab (disabled)
 

This local extension is shown when the local template is a Report or a Source template.

 
     


Relationship with other 3rdParty products

PowerToolbar

Most of the time your PowerToolbar will reside on the frame of your application together with your AnyFont code templates. The best solution is to partially disable AnyFont locally on the Frame. You do this by going to the AnyFont Local Extension prompts on the frame and checking the Disable AnyFont in this Procedure checkbox. You can leave the Disable Change Font dialog code and/or the Disable AnyFont Disable code checkboxes unchecked here to still use this functionality for your application.

Class Methods

SetWindow
SetControlFont
SetControlTypeFont
Disable
Enable

SetWindow (<string p_FontName>, long p_FontSize= -1, long p_Fontcolor= -1, long p_FontStyle= -1, long p_FontCharset= -1, byte p_NoMoveSize=0)

Sets the font of the current window.

Parameters:
p_FontName: Name of the new font required. This can either be a variable name or a literal font name, e.g. 'Arial'.

p_FontSize: Size of the new font.

p_Fontcolor: The new font's colour.

p_FontStyle: The style of the new font (bold, italic, etc.)

p_FontCharset: The character set of the new font. The character set values are listed in the global template in the Default Font tab.

p_NoMoveSize: Set to 1 if the window controls are not to be moved or sized. 

Return value: none.

Example:
If the font is to be set for the entire application, do this (AnyFont does this automatically). Moving and sizing is enabled in this example.

    Anyfont:Fontname = 'Tahoma' 
    Anyfont:Fontsize = 8
    Anyfont:Fontcolor = color:red
    Anyfont:Fontstyle = style:bold
    Anyfont:FontCharset = charset:ansi
    thisAnyFont.SetWindow (Anyfont:Fontname, Anyfont:Fontsize, Anyfont:Fontcolor, |
                          
Anyfont:Fontstyle, Anyfont:FontCharset, false)

The font can be set for only one window, in which case don't use the global variables in the font setting. Here is an example, with moving and sizing disabled:

    thisAnyFont.SetWindow ('Tahoma', 8, color:red, style:bold, charset:ansi, true)

SetControlFont (long p_Ctrl, <string p_FontName>, long p_FontSize= -1, long p_Fontcolor= -1, long p_FontStyle= -1, long p_FontCharset= -1)

Sets the font of the selected window control. If this control is the window, then resizing also takes place.

Parameters:
p_Ctrl: Handle of the control whose font is to be changed.

p_FontName: Name of the new font required. This can either be a variable name or a literal font name, e.g. 'Arial'.

p_FontSize: Size of the new font.

p_Fontcolor: The new font's colour.

p_FontStyle: The style of the new font (bold, italic, etc.)

p_FontCharset: The character set of the new font. The character set values are listed in the global template in the Default Font tab.

Return value: none.

Example:
    thisAnyFont.SetControlFont (?Listbox, 'Tahoma', 8, color:red, style:bold, |
                                charset:ansi)

SetControlTypeFont (long p_CtrlType, <string p_FontName>, long p_FontSize= -1, long p_Fontcolor= -1, long p_FontStyle= -1, long p_FontCharset= -1)

Sets the font of all the window controls of the specified type. For example, use this method if you want to change all your entry fields' fonts.

Parameters:
p_CtrlType: Type of control whose font is to be changed. A list of all control types can be found in EQUATES.CLW.

p_FontName: Name of the new font required. This can either be a variable name or a literal font name, e.g. 'Arial'.

p_FontSize: Size of the new font.

p_Fontcolor: The new font's colour.

p_FontStyle: The style of the new font (bold, italic, etc.)

p_FontCharset: The character set of the new font. The character set values are listed in the global template in the Default Font tab.

Return value: none.

Example:
    thisAnyFont.SetControlTypeFont (create:button, 'MS Sans Serif', 8, color:red, |
                                    style:bold, charset:ansi)

Disable()

Allows dynamic disabling of AnyFont. Sets the AnyFont property AFDisable to true. This must be called before the call to ThisAnyFont.SetWindow().

Parameters: none.

Return value: none.

Example:
    thisAnyFont.Disable()


Enable()

Enables AnyFont after Disable() has been called. Sets the AnyFont property AFDisable to false. This is its default value.

Parameters: none.

Return value: none.

Example:
    thisAnyFont.Enable()



Class Properties and Global Variable Reference

Properties

OldFont
NewFont
RegistryFolder
AFdisable

OldFont          group(FontParams)
                 end

The font attributes used by the program on startup. The initial values of the group are taken from the global variables. 

The FontParams group is defined as follows. The elements of the group are self-explanatory.

FontParams       group
Name              
string
Size              
long
Color             
long
Style             
long
Charset            long

                 end

NewFont         group(FontParams)           group(FontParams)
                 end

The new font attributes changed by the user.

RegistryFolder   string(255)

This variable contains the folder in the registry where the AnyFont settings will be kept. The folder will be in the HKEY_LOCAL_MACHINE\Software folder.

AFdisable        bool

This is the variable changed by the methods AnyFont.Disable() and AnyFont.Enable(). It is used to disable AnyFont in a single window and is normally set to false. To disable AnyFont, set this variable to true just before the initial call to ThisAnyFont.SetWindow().

Global Variables

AnyFont:Fontname        string(31)
AnyFont:FontSize        long(-1)
AnyFont:FontColor       long(-1)
AnyFont:FontStyle       long(-1)
AnyFont:FontCharset     long(-1)

These are used to store the current application font and correspond to the variables in the FontParams group. They can be set before the AnyFont.Init procedure is called in order to determine the default application font.

AnyFont:Disable         bool(false)

This is used to disable AnyFont globally at runtime and is normally set to false. To disable AnyFont, set this global variable to true. This can be done anywhere in your code. Disabling AnyFont causes all windows to revert to the default system font. If they are already open, no change will occur. See FAQ 1.

Using the embed described below will help you when you want the user to be able to change the value of AnyFont:Disable.

Changing the value of AnyFont:Disable does not affect the value of the local AnyFont.AFdisable properties.


Embeds

Call FontDialog to set Font Parameters
Save the AnyFont global Disable Variable

Call FontDialog to set Font Parameters

Insert this embed in order to change the application's font. It opens the font dialog window and saves the results to the place you have chosen in the global extension (.INI file or registry).

Save the AnyFont Global Disable Variable

Insert this embed where you want to change the state of the AnyFont global disable variable, for example in a menu item. It toggles the value of AnyFont:Disable and saves the value to the place you have chosen in the global extension (.INI file or registry). 

This embed also allows you to insert code to change any text in the control used. For example, if you have used a menu item labeled 'Disable AnyFont', you can change the text to 'Enable AnyFont' inside the embed when AnyFont is disabled.


 Version History

Version 1.53 Gold (September 3, 2007)

Version 1.52 Gold(August 29, 2007)

Version 1.51 Gold (July 24, 2007)

Version 1.50 Gold (November 13, 2006)

Version 1.49 Gold (November 1, 2006)

Version 1.48 Gold (October 4, 2006)

Version 1.47 Gold (July 28, 2006)

Version 1.46 Gold (July 25, 2006)

Version 1.45 Gold (July 21, 2006)

Version 1.44 Gold (July 10, 2006)

Version 1.43 Gold (July 7, 2006)

Version 1.42 Gold (June 27, 2006)

Version 1.41 Gold (June 12, 2006)

Version 1.40 Gold (June 12, 2006)

Version 1.39 Gold (June 6, 2006)

Version 1.38 Gold (June 5, 2006)

Version 1.37 Gold (12 April 2006)

Version 1.36 Gold (2 February 2006)

Version 1.35 Gold (1 February 2006)

Version 1.34 Gold (23 January 2006)

Version 1.33 Gold (23 December 2005)

Version 1.32 Gold (29 July 2005)

Version 1.31 Gold (21 June 2005)

Version 1.30 Gold (20 June 2005)

Version 1.29 Gold (25 May 2005)

Version 1.28 Gold (19 May 2005)

Version 1.27 Gold (12 May 2005)

Version 1.26 Gold (6 May 2005)

Version 1.25 Gold (28 April 2005)

Version 1.24 Gold (6 April 2005)

Version 1.23 Gold (1 April 2005)

Version 1.22 Gold (29 March 2005)

Version 1.21 Gold (16 March 2005)

Version 1.20 Gold (8 March 2005)

Version 1.11 Beta (25 February 2005)

Version 1.10 Beta (21 February 2005)

Version 1.09 Beta (19 January 2005)

Version 1.08 Beta (11 January 2005)

Version 1.07 Beta (6 January 2005)

Version 1.06 Beta (31 December 2004)

Version 1.05 Beta (17 December 2004)

Version 1.04 Beta (14 December 2004)

Version 1.03 Beta (12 November 2004)

Version 1.02 Beta (25 October 2004)

Version 1.01 Beta (21 October 2004)

Version 1.00 Beta (10 September 2004)




License & Copyright

This template is copyright 2008 by CapeSoft Software Ltd. None of the included files may be distributed. Your programs which use AnyFont can be distributed without any royalties.

This product is provided as-is. Use it entirely at your own risk. Use of this product implies your acceptance of this, along with the recognition of the copyright stated above. In no way will CapeSoft Software Ltd; their employees or affiliates be liable in any way for any damages or losses you may incur as a direct or indirect result of using this product.