+----------------------------------------------------------------------+
|                      I * C * E * T * I * P * S                       |
|                                                                      |
|                        Nr 5,  March 15th 1995                        |
|                                                                      |
|                         Presented to you by                          |
|                      Arnor Baldvinsson, ICELAND                      |
+----------------------------------------------------------------------+

One of the things we are used to be able to do in Windows is all kind of
customization of our applications.  One of the things we can change is
the fonts of all sorts of things.  Windows itself can be customized to
use different fonts for just about anything it displays on the screen.

The users of our application may be using very different screen resolution,
from 640*480 up to 1280*1024 or even more.  If we use 640*480 when designing
our applications and use 10pt Arial or even 8pt Arial our users would need a 
good magnifying glass to read the text if they were using a 15" screen with 
1280*1024 resolution.  Somehow we must provide our users with means to change
the fonts on certain things on the screen.  We have the SetFont procedure 
to change the fonts for controls.  The documentation states that we can use
0 as the screen control it will change the font for all controls on the window
but that did not work in CW 1.000 so you had to specify each control.  In fact 
this is probably what we would use generally, because we may not want to change
fonts for certain controls like buttons or we would have to change the size as 
well and making even more changes.  

My solution for tables or browse windows is to have a seperate menu where the 
user can select directly to Add, Change, Delete, Select and Close the window as 
well as change the fonts.  This allows the user to use the menu instead of the 
buttons if he so chooses.  The menu items simply calls the button controls which
does the job.  In the Action for the "&Add" menu item - Embeds - 
Control Event handling - After generated Code - Accepted 
you put the following SOURCE:

!------------------------------------------------------------------------------
POST(EVENT:Accepted,?Insert)
!------------------------------------------------------------------------------

This posts the Accepted event to the Insert button which then calls the Update 
procedure etc.  This allows the user to use the menus, which in some cases are
more logical than the buttons.  If the Windows is a MDI this menu will merge
into the Menu bar of the AppFrame window.

Now onto the fonts...

We have to write some code: First to retrive the fonts from the Application.INI
file and secondly to write changes to fonts back to the .INI file.

In the Embeds - After Opening the Window, put the following code:

!------------------------------------------------------------------------------
G_TypeFace  = GetIni('FontsClientWindow','TypeFace','Arial','MYAPP.INI')
G_FontSize  = GetIni('FontsClientWindow','FontSize','10','MYAPP.INI')
G_FontColor = GetIni('FontsClientWindow','FontColor',,'MYAPP.INI')
G_FontStyle = GetIni('FontsClientWindow','FontStyle','MYAPP.INI')

IF CLIP(G_TypeFace) <> '' THEN
  SETFONT(?LIST,G_TypeFace,G_FontSize,G_FontColor,G_FontStyle)
  SETFONT(?KUN:NAFN,G_TypeFace,G_FontSize,G_FontColor,G_FontStyle)
  SETFONT(?KUN:NAFN:PROMPT,G_TypeFace,G_FontSize,G_FontColor,FONT:Bold)
END
!------------------------------------------------------------------------------

KUN:NAFN is a locator entry field and KUN:NAFN:PROMPT is the prompt for the
locator field.  G_TypeFace and the other G_ variables are global (G_) variables
only used for this purpose.  If the GetIni can't find the entries in the
MYAPP.INI it will default to 10pt Arial.

Now you need a button or a menu item to change the fonts.  What ever method you
choose you need the following code for the Embedes - Control - Accepted:

!------------------------------------------------------------------------------
IF FONTDIALOG('Select fonts for Client
table',G_TypeFace,G_FontSize,G_FontColor,G_FontStyle)
  SetFont(?LIST,G_TypeFace,G_FontSize,G_FontColor,G_FontStyle)
  SETFONT(?KUN:NAFN,G_TypeFace,G_FontSize,G_FontColor,G_FontStyle)
  SETFONT(?KUN:NAFN:PROMPT,G_TypeFace,G_FontSize,G_FontColor,FONT:bold)
END

PutIni('FontsClientWindow','TypeFace',G_TypeFace,'MYAPP.INI')
PutIni('FontsClientWindow','FontSize',G_FontSize,'MYAPP.INI')
PutIni('FontsClientWindow','FontColor',G_FontColor,'MYAPP.INI')
PutIni('FontsClientWindow','FontStyle',G_FontStyle,'MYAPP.INI')
!------------------------------------------------------------------------------

You pass the Global variables to the FontDialog and use these to set the fonts
for the controls when you return with a value.  Arguably I should have put the
PutIni calls within the IF ... END it's up to you.

You may want to make some or all of the fields in the browse box (?LIST) as
resizable
but unfortunately you can't save the size of the fields in the INI file as
well.  If you
have only a few fields in a table you may want to have it "spacy" so even if
you change 
from 10 to 12pt Arial all the data will still fit.  Note that 12pt Times New
Roman is
about the same size on screen and printer as 10pt Arial.

I find that when working with tables you should not change the fonts for the
buttons,
just the browse boxes and the locator field if used.  


Small TIP:
----------

When writing embeded code you can see the first line you write in the embeds
tree.  
This is not always very intuitive so I always start my embeds with a comment 
like this:

!***  Change tablefonts   ***

This makes browsing for certain embeds a great deal easier.


Finally here is a small API tip.  You may need to store files someplace on your
client computer where you must be able to access them without having the user
look for them and they must be shared with other applications.  The easiest way
is to store such files in either the Windows or System directories.  You can
call Windows API to find out the path used for Windows and System directories.
As usual you need to include the WINDOWS.LIB in the project file and you must
prototype the procedures as follows (Best done in the 
Global - Embeds - Inside the Global Map)


MODULE('WINDOWS.LIB')
  GetSystemDirectory(*CSTRING,USHORT),RAW, PASCAL   ! USHORT must be at
least 144
  GetWindowsDirectory(*CSTRING,USHORT),RAW, PASCAL  ! USHORT must be at
least 144
END

You can now call these two procedures to retrieve the path to these locations.


***** COMING UP NEXT on ICETIPS:  *****

Change the PRORGAM template to create a .BAT file you can use to copy your
application to a diskette.

