home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.funduc.com
/
2014.08.ftp.funduc.com.tar
/
ftp.funduc.com
/
WiseFontDLL.zip
/
Wisefont.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2002-07-25
|
4KB
|
124 lines
// mksht.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <tchar.h>
#include <shlobj.h>
#include <stdio.h>
#include "wisedll.h"
#define WISEFONTFACE _T("WISEFONTFACE")
#define WISEFONTPOINTS _T("WISEFONTPOINTS")
#define WISEFONTITA _T("WISEFONTITALIC")
#define WISEFONTWEIGHT _T("WISEFONTWEIGHT")
#define WISEFONTUNDER _T("WISEFONTUNDER")
#define WISEFONTSTRIKE _T("WISEFONTSTRIKE")
void GetVariable(LPDLLCALLPARAMS lpDllParams,char *szVariable,char *szValue);
void SetVariable(LPDLLCALLPARAMS lpDllParams,char *szVariable,char *szValue);
__declspec(dllexport) BOOL CALLBACK GetFontInfo(LPDLLCALLPARAMS lpDllParams)
{
if ((lpDllParams->lpszParam) && SUCCEEDED(CoInitialize(NULL)))
{
int nPointSize;
TCHAR szFontFace[MAX_PATH + 1], szFontSize[MAX_PATH + 1];
LOGFONT lf = {0};
CHOOSEFONT cf = {0};
GetVariable(lpDllParams, WISEFONTFACE, szFontFace);
GetVariable(lpDllParams, WISEFONTPOINTS, szFontSize);
nPointSize = atol(szFontSize);
GetVariable(lpDllParams, WISEFONTITA, szFontSize);
lf.lfItalic = (UCHAR)atol(szFontSize);
GetVariable(lpDllParams, WISEFONTWEIGHT, szFontSize);
lf.lfWeight = atol(szFontSize);
GetVariable(lpDllParams, WISEFONTUNDER, szFontSize);
lf.lfUnderline = (UCHAR)atol(szFontSize);
GetVariable(lpDllParams, WISEFONTSTRIKE, szFontSize);
lf.lfStrikeOut = (UCHAR)atol(szFontSize);
cf.lStructSize = sizeof(CHOOSEFONT);
cf.hwndOwner = (HWND)lpDllParams->hWnd;
cf.lpLogFont = &lf;
cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
cf.nFontType = SCREEN_FONTTYPE;
if (nPointSize)
{
HDC hdc = GetDC(NULL);
lf.lfHeight = -MulDiv(nPointSize, GetDeviceCaps(hdc, LOGPIXELSY), 72);
ReleaseDC(NULL, hdc);
strcpy(lf.lfFaceName, szFontFace);
}
if (ChooseFont(&cf) == 0)
return FALSE;
strcpy(szFontFace, lf.lfFaceName);
nPointSize = cf.iPointSize / 10;
SetVariable(lpDllParams, WISEFONTFACE, szFontFace);
sprintf(szFontSize, "%d", nPointSize);
SetVariable(lpDllParams, WISEFONTPOINTS, szFontSize);
sprintf(szFontSize, "%d", lf.lfItalic);
SetVariable(lpDllParams, WISEFONTITA, szFontSize);
sprintf(szFontSize, "%d", lf.lfWeight);
SetVariable(lpDllParams, WISEFONTWEIGHT, szFontSize);
sprintf(szFontSize, "%d", lf.lfUnderline);
SetVariable(lpDllParams, WISEFONTUNDER, szFontSize);
sprintf(szFontSize, "%d", lf.lfStrikeOut);
SetVariable(lpDllParams, WISEFONTSTRIKE, szFontSize);
return TRUE;
}
return FALSE;
}
int CALLBACK LibMain(HINSTANCE hInst, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine)
{
return(1);
}
// GetVariable: Returns the value of a variable.
//
// lpDllParams Parameter structure passed from Wise Installation
// szVariable Name of the variable (without %'s) to get value for
// szValue String that will hold the variables value
void GetVariable(LPDLLCALLPARAMS lpDllParams,char *szVariable,char *szValue)
{
WORD i;
char szVar[32];
*szVar = '%';
lstrcpy(&szVar[1],szVariable);
lstrcat(szVar,"%");
for (i = 0 ; (i < lpDllParams->wCurrReps) &&
(lstrcmp(&lpDllParams->lpszRepName[i * lpDllParams->wRepNameWidth],szVar) != 0) ; i++) ;
if (i < lpDllParams->wCurrReps) {
lstrcpy(szValue,&lpDllParams->lpszRepStr[i * lpDllParams->wRepStrWidth]);
} else *szValue = '\0';
}
// SetVariable: Sets/Creates a variable.
//
// lpDllParams Parameter structure passed from Wise Installation
// szVariable Name of the variable (without %'s) to set value for
// szValue String that contains the variables new value
void SetVariable(LPDLLCALLPARAMS lpDllParams,char *szVariable,char *szValue)
{
WORD i;
char szVar[32];
*szVar = '%';
lstrcpy(&szVar[1],szVariable);
lstrcat(szVar,"%");
for (i = 0 ; (i < lpDllParams->wCurrReps) &&
(lstrcmp(&lpDllParams->lpszRepName[i * lpDllParams->wRepNameWidth],szVar) != 0) ; i++) ;
if (i >= lpDllParams->wCurrReps) {
if (i >= lpDllParams->wMaxReplaces) return; // Too many variables
lstrcpy(&lpDllParams->lpszRepName[i * lpDllParams->wRepNameWidth],szVar);
lpDllParams->wCurrReps++;
}
lstrcpy(&lpDllParams->lpszRepStr[i * lpDllParams->wRepStrWidth],szValue);
}