home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PhotoFinish 4.0 (French)
/
Photofinish-v4-FrenchVersion-Win31.iso
/
instft16.rul
< prev
next >
Wrap
Text File
|
1996-11-29
|
9KB
|
314 lines
/*---------------------------------------------------------------------------*\
*
* Program: InstallFonts16
*
* Purpose: This is a general purpose font installing program for 16-bit win3.1
*
*
*
* Comments:
\*---------------------------------------------------------------------------*/
declare
#include "ErrMsg.h"
#include "StrFmPrf.h"
#include "SdDialog.h"
prototype BOOL GDI.CreateScalableFontResource( LONG, STRING, STRING, STRING );
prototype INT GDI.AddFontResource( STRING );
prototype InstallFonts( STRING );
prototype GetFontDir( BYREF STRING );
prototype SafeFontCopyInstall( STRING, STRING );
prototype FindFont( STRING, STRING, STRING );
prototype EnableFont( STRING, STRING, STRING );
prototype EarlyCancel();
#define HWND_BROADCAST 0xFFFF
#define WM_FONTCHANGE 0x001D
#define INSTALL_NEW_FONT 0
#define INSTALL_OVER_FONT 1
#define DONT_REPLACE_FONT 2
STRING PRODUCT_NAME;
STRING BACKGROUND_CAPTION;
STRING BACKGROUND_TITLE;
#define SD_SINGLE_DIALOGS 1
#define SD_DISPLAYTOPICS 1
program
start:
//Original SRCDIR gets passed in in CMDLINE
SRCDIR = CMDLINE;
AppStrFromProfile( "BackgroundCaption", BACKGROUND_CAPTION );
AppStrFromProfile( "BackgroundTitle", BACKGROUND_TITLE );
SetTitle( BACKGROUND_CAPTION, 24, WHITE );
SetTitle( BACKGROUND_TITLE, 0, BACKGROUNDCAPTION ); // Caption bar text.
AppStrFromProfile( "ProductName", PRODUCT_NAME );
VarSave( SRCTARGETDIR );
Disable( LOGGING );
Handler( EXIT, OnCancel );
InstallFonts( SRCDIR ^ "fonts" );
AfterInstall:
Handler( EXIT, -1 );
VarRestore( SRCTARGETDIR );
Enable( LOGGING );
exit;
OnCancel:
EndDialog( SD_DLG_DISPLAYTOPICS );
goto AfterInstall;
return;
/*---------------------------------------------------------------------------*\
*
* Function: InstallFonts
*
* Purpose: This is a general purpose font installing function
*
* Input: Path to the fonts on source
*
* Returns:
*
* Comments: The calling function should surround this call with
* VarSave and VarRestore. If you don't want fonts to be
* uninstallable, diable logging befopre call.
* Also the source directory should contain
* a text file containing a list of the fonts, one per line, in fonts.txt.
\*---------------------------------------------------------------------------*/
function InstallFonts( szSource )
STRING szTarget, svDlgTitle, svDlgMsg, svAddStr, szSourceFile, szFileCaption;
STRING szTargetFile, szResult, szHeaderFile;
LIST listTopics, listDetails, listFonts;
NUMBER nFilePercent, nTotalPercent, nFileFound, nEndOfList;
begin
//Set up Dialog to ask
DlgStrFromProfile( "FontDlgTitle", svDlgTitle );
DlgStrFromProfile( "FontDlgMessage", svDlgMsg );
listTopics = ListCreate( STRINGLIST );
listDetails = ListCreate( STRINGLIST );
DlgStrFromProfile( "FontDlgTopic", svAddStr );
ListAddString( listTopics, svAddStr, AFTER );
DlgStrFromProfile( "FontDlgDetail", svAddStr );
ListAddString( listDetails, svAddStr, AFTER );
ListAddString( listTopics, "", AFTER );
ListAddString( listDetails, "", AFTER );
ListAddString( listTopics, "", AFTER );
ListAddString( listDetails, "", AFTER );
Disable( BACKBUTTON );
if( SdDisplayTopics( svDlgTitle, svDlgMsg, listTopics, listDetails, 0 ) = NEXT ) then
//See where the fonts go.
if !( GetFontDir( szTarget ) ) then
return;
endif;
//Make list of fonts from txt file.
listFonts = ListCreate( STRINGLIST );
szSourceFile = szSource ^ "fonts.txt";
ListReadFromFile( listFonts, szSourceFile );
nFilePercent = ListCount( listFonts );
nFilePercent = 100 / nFilePercent;
nTotalPercent = 0;
//Enable progress bar
PlaceWindow( STATUS, CENTERED, CENTERED, CENTERED );
Enable( STATUS );
Enable( INDVFILESTATUS );
DlgStrFromProfile( "InstallingFonts", szFileCaption );
//SetStatusForFirstFile
SetStatusWindow( nTotalPercent, szFileCaption );
nTotalPercent = nFilePercent;
StatusUpdate( ON, nTotalPercent );
//SetDirectories
TARGETDIR = szTarget;
SRCDIR = szSource;
//Start Copying
nEndOfList = ListGetFirstString( listFonts, szSourceFile );
while( nEndOfList = 0 );
//See if its already there
SafeFontCopyInstall( szTarget, szSourceFile );
nEndOfList = ListGetNextString( listFonts, szSourceFile );
nTotalPercent = nTotalPercent + nFilePercent;
StatusUpdate( ON, nTotalPercent );
endwhile;
Disable( INDVFILESTATUS );
Disable( STATUS );
endif;
Enable( BACKBUTTON );
end;
/*---------------------------------------------------------------------------*\
*
* Function: GetFontDir
*
* Purpose: This Function determines the correct Font directory
*
* Input:
*
* Returns: Path in string passedin BYREF
*
* Comments:
\*---------------------------------------------------------------------------*/
function GetFontDir( szTarget )
BOOL bShared;
STRING svResult;
begin
//Fonts go in sysdir unless its a shared network version, then windir
bShared = Is( WINDOWS_SHARED, svResult );
if( bShared ) then
szTarget = WINDIR;
else
szTarget = WINSYSDIR;
endif;
return TRUE;
end;
/*---------------------------------------------------------------------------*\
*
* Function: SafeFontCopyInstall
*
* Purpose: This function looks for anexeisting font of the same name,
* Querys whether to replace it if found, copies it, and
* Enables it in the system.
*
* Input: Source file and Target path. SRCDIR and TARGETDIR already set.
*
* Returns:
*
* Comments: Calls FindFont, and EnableFont
*
\*---------------------------------------------------------------------------*/
function SafeFontCopyInstall( szTarget, szSourceFile )
BOOL nInstall;
STRING szDllName, svTypeFaceName;
NUMBER nTypeFaceSize;
LIST listFontNames;
begin
//GetFile name and typeface name out of string;
listFontNames = ListCreate( STRINGLIST );
StrGetTokens( listFontNames, szSourceFile, "|" );
ListGetFirstString( listFontNames, szSourceFile );
ListGetNextString( listFontNames, svTypeFaceName );
ListDestroy( listFontNames );
nInstall = FindFont( szTarget, szSourceFile, svTypeFaceName );
if( nInstall != DONT_REPLACE_FONT ) then
//Copy 'er on over
XCopyFile( szSourceFile, "*.*", EXCLUDE_SUBDIR | LOCKEDFILE );
EnableFont( szSourceFile, szTarget, svTypeFaceName );
endif;
end;
/*---------------------------------------------------------------------------*\
*
* Function: FindFont
*
* Purpose: This Function determines if a font is installed,
* and Queries whether to replace it.
*
* Input: Target Path and FontName
*
* Returns: True if we're going to install it, false if user chooses not to.
*
* Comments:
\*---------------------------------------------------------------------------*/
function FindFont( szTarget, szSourceFile, svTypeFaceName )
STRING szResult, szTargetFile;
NUMBER nFileFound;
begin
nFileFound = FindFile( szTarget, szSourceFile, szResult );
//if nFile Found not = 0 its not there so we can install it.
if( nFileFound != 0 ) then
return INSTALL_NEW_FONT;
elseif ( _AskYesNoFmt( "OldFont", svTypeFaceName ) = YES ) then
//Make sure we can get rid of it.
szTargetFile = szTarget ^ szSourceFile;
SetFileInfo( szTargetFile, FILE_ATTRIBUTE, FILE_ATTR_NORMAL, szResult );
return INSTALL_OVER_FONT;
else
return DONT_REPLACE_FONT;
endif;
end;
/*---------------------------------------------------------------------------*\
*
* Function: EnableFont
*
* Purpose: Loads font into font table, and registers it with windows
*
* Input: Source file and Target path and typefacename
*
* Returns:
*
* Comments: Platform independent, works with WinNT,Win95 and 32s
\*---------------------------------------------------------------------------*/
function EnableFont( szSourceFile, szTarget, szTypeFaceName )
STRING szHeaderFile, szWinIni, szKey;
begin
//Create resource file
ParsePath( szHeaderFile, szSourceFile, FILENAME_ONLY );
szHeaderFile = szHeaderFile + ".FOT";
CreateScalableFontResource( 0, WINSYSDIR ^ szHeaderFile, szSourceFile, WINSYSDIR );
szSourceFile = szHeaderFile;
//add the font to the table, and let everyone know.
AddFontResource( szSourceFile );
SendMessage( HWND_BROADCAST, WM_FONTCHANGE, 0, 0 );
//do proper registration
//add font to the WIN.INI
szWinIni = WINDIR ^ "win.ini";
WriteProfString( szWinIni, "fonts", szTypeFaceName, szSourceFile );
end;
/*---------------------------------------------------------------------------*\
*
* Function: EarlyCancel
*
* Purpose: Perform some registry cleanup if the user quits, or gets kicked out
*
* Input:
*
* Returns:
*
* Comments: Exit routine, calle in _ErrMsg funcs
*
\*---------------------------------------------------------------------------*/
function EarlyCancel()
STRING szFullKey, szCompanyName;
begin
AppStrFromProfile( "CompanyName", szCompanyName );
szFullKey = "Software\\" + szCompanyName + "\\" + PRODUCT_NAME;
RegDBSetDefaultRoot( HKEY_LOCAL_MACHINE );
RegDBDeleteKey( szFullKey );
exit;
end;
#include "ErrMsg.rul"
#include "StrFmPrf.rul"
#include "SdDialog.rul"