Category : Windows 3.X Files
Archive   : SHOWFONT.ZIP
Filename : SHOWFONT.C
#include
#include
#include
#include "showfont.h"
#include "fontsel.h" /* import fontsel module */
#define export
#define import extern
#define local static
local HANDLE hInst; /* Instance handle */
local LOGFONT font;
local char FaceName [30] = "SYSTEM";
local char szAppName[] = "showfont";
local char szAbout[] = "About ...";
local char szWindowTitle[] = "Show Fonts";
local void ShowSampleString(HDC hDC )
{
short YCoord = 10;
char szLine[257];
int i;
HANDLE hLogFont;
HANDLE hLogFontOld;
int Height;
local TEXTMETRIC TM;
/* create the sample string with all characters in it */
for (i = 0; i < 256; i++)
szLine[i] = (char)i;
/* create new font but keep the old one */
hLogFont = (HANDLE)CreateFontIndirect((LPLOGFONT)&font);
hLogFontOld = SelectObject(hDC,hLogFont);
/* get font parameters */
GetTextFace(hDC,29,(LPSTR)FaceName);
GetTextMetrics(hDC,(LPTEXTMETRIC)&TM );
Height = TM.tmHeight + TM.tmExternalLeading;
TextOut( hDC, 0, YCoord, (LPSTR)FaceName,(short)lstrlen((LPSTR)FaceName));
for (i = 0; i < 256;i += 64)
TextOut(hDC,0,(YCoord += Height),(LPSTR)&szLine[i],64);
YCoord += Height;
/* clean-up */
SelectObject( hDC, hLogFontOld );
DeleteObject( hLogFont );
} /* ShowSample String() */
local void FontsCommand(HWND hWnd,WORD command )
{
static HDC hdc;
switch (command) {
case FONT_CHANGE:
InvalidateRect(hWnd,NULL,TRUE);
UpdateWindow(hWnd);
break;
case IDMCRT:
hdc = GetDC(hWnd);
SelectFont(hWnd,hdc,FIXED_PITCH | VARIABLE_PITCH,(LPLOGFONT)&font,FONT_CHANGE);
ReleaseDC(hWnd,hdc);
break;
}
}
export long FAR PASCAL
WndProc(HWND hWnd,unsigned message,WORD wParam,LONG lParam )
{
PAINTSTRUCT ps;
switch (message) {
case WM_DESTROY:
PostQuitMessage( 0 );
break;
case WM_COMMAND:
FontsCommand(hWnd,wParam);
break;
case WM_PAINT:
BeginPaint(hWnd,(LPPAINTSTRUCT) &ps);
ShowSampleString(ps.hdc);
EndPaint(hWnd,(LPPAINTSTRUCT) &ps);
default:
return DefWindowProc(hWnd,message,wParam,lParam );
break;
}
return 0L;
}
local BOOL init(HANDLE hInstance )
{
WNDCLASS TemplateClass;
TemplateClass.hCursor = LoadCursor(NULL, IDC_ARROW);
TemplateClass.hIcon = LoadIcon(hInstance,(LPSTR)"mainIcon");
TemplateClass.cbClsExtra = 0;
TemplateClass.cbWndExtra = 0;
TemplateClass.lpszMenuName = (LPSTR)"mainMenu";
TemplateClass.lpszClassName = (LPSTR)szAppName;
TemplateClass.hbrBackground = (HBRUSH)GetStockObject (WHITE_BRUSH);
TemplateClass.hInstance = hInstance;
TemplateClass.lpfnWndProc = WndProc;
TemplateClass.style = CS_VREDRAW | CS_HREDRAW;
if (!RegisterClass((LPWNDCLASS)&TemplateClass))
return FALSE;
return TRUE;
}
export int PASCAL
WinMain(HANDLE hInstance,HANDLE hPrev,LPSTR lpszCmdLine,int cmdShow)
{
MSG msg;
HWND hWnd;
WORD i;
/* register window class and load accelerators */
if (hPrev == NULL)
if (!init(hInstance))
return FALSE;
/* set-up initial font to SYSTEM */
font.lfHeight = 0;
font.lfWidth = 0;
font.lfOrientation = 0;
font.lfEscapement = 0;
font.lfWeight = FW_NORMAL;
font.lfItalic = 0;
font.lfUnderline = 0;
font.lfStrikeOut = 0;
font.lfCharSet = 0;
font.lfOutPrecision = OUT_DEFAULT_PRECIS;
font.lfClipPrecision = CLIP_DEFAULT_PRECIS;
font.lfQuality = DEFAULT_QUALITY;
font.lfPitchAndFamily = FF_DONTCARE | DEFAULT_PITCH;
strcpy(font.lfFaceName,"System");
hWnd = CreateWindow( (LPSTR)szAppName,
(LPSTR)szWindowTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
(HWND)NULL,
(HMENU)NULL,
(HANDLE)hInstance,
(LPSTR)NULL
);
ShowWindow( hWnd, cmdShow );
UpdateWindow( hWnd );
while (GetMessage((LPMSG)&msg, NULL, 0, 0)) {
TranslateMessage((LPMSG)&msg);
DispatchMessage((LPMSG)&msg);
}
return (int)msg.wParam;
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/