home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
PMFONT.ZIP
/
FONTS.C
< prev
next >
Wrap
Text File
|
1991-06-27
|
3KB
|
102 lines
#define INCL_WIN
#include <os2.h>
#include <string.h>
#define INIT_W 450
#define INIT_H 250
SHORT cdecl main(VOID);
extern VOID EXPENTRY FntQueryList(HWND);
MRESULT EXPENTRY FontsWinProc(HWND, USHORT, MPARAM, MPARAM);
HAB hab;
HWND hwFr, hwCl, hwList, hwClList;
SHORT cdecl main()
{
HMQ hmq;
QMSG qmsg;
ULONG flCr = FCF_STANDARD & ~(FCF_ACCELTABLE | FCF_MENU);
PSZ szClass = "Fonts";
hab = WinInitialize(0);
hmq = WinCreateMsgQueue(hab, 0);
WinRegisterClass(hab, szClass, FontsWinProc,
CS_CLIPCHILDREN | CS_SIZEREDRAW, 0 );
hwFr = WinCreateStdWindow(HWND_DESKTOP, FS_SHELLPOSITION | FS_TASKLIST,
&flCr, szClass, "", WS_VISIBLE,
(HMODULE)0, 256, &hwCl );
WinSetWindowPos(hwFr, HWND_TOP, 150, 150, INIT_W, INIT_H,
SWP_ACTIVATE | SWP_MOVE | SWP_SIZE | SWP_SHOW );
WinSetWindowText(hwFr, "Font List for Presentation Parameters");
while (WinGetMsg(hab, &qmsg, (HWND)0, 0, 0))
WinDispatchMsg(hab, &qmsg);
WinDestroyMsgQueue(hmq);
WinTerminate(hab);
return 0;
}
MRESULT EXPENTRY FontsWinProc(hwnd, msg, mp1, mp2)
HWND hwnd;
USHORT msg;
MPARAM mp1;
MPARAM mp2;
{
HPS hps;
RECTL rcl;
SHORT i;
switch (msg) {
case WM_CREATE:
hwList = WinCreateWindow(hwnd, WC_LISTBOX, "",
LS_NOADJUSTPOS | WS_VISIBLE,
4, 4, INIT_W - 8, INIT_H - 8,
hwnd, HWND_TOP, 257, (PVOID)0, (PVOID)0 );
FntQueryList(hwList);
WinSetPresParam(hwList, PP_FONTNAMESIZE, 11L, "10.Courier\0");
if (i = (SHORT)WinSendMsg(hwList, LM_SEARCHSTRING,
MPFROM2SHORT(LSS_CASESENSITIVE | LSS_PREFIX,
LIT_FIRST ),
MPFROMP("10.Courier") ) )
WinSendMsg(hwList, LM_SELECTITEM, MPFROMSHORT(i), MPFROMSHORT(TRUE));
break;
case WM_CONTROL:
if (SHORT2FROMMP(mp1) == LN_SELECT) {
CHAR pch[64];
PSZ psz;
i = (USHORT)WinSendMsg(HWNDFROMMP(mp2), LM_QUERYSELECTION,
MPFROMSHORT(LIT_FIRST), (MPARAM)0 );
WinSendMsg(HWNDFROMMP(mp2), LM_QUERYITEMTEXT,
MPFROM2SHORT(i, 64), MPFROMP(pch) );
psz = (PSZ)((pch[0] == ' ') ? pch + 1 : pch);
WinSetPresParam(hwList, PP_FONTNAMESIZE,
(ULONG)strlen(psz) + 1L, psz );
}
break;
case WM_PAINT:
hps = WinBeginPaint(hwnd, (HPS)0, &rcl);
WinFillRect(hps, &rcl, CLR_BLUE);
WinQueryWindowRect(hwnd, &rcl);
WinSetWindowPos(hwList, HWND_TOP,
4L, 4L, (SHORT)rcl.xRight - 8, (SHORT)rcl.yTop - 8,
SWP_MOVE | SWP_SIZE | SWP_ZORDER );
WinEndPaint(hps);
return MRFROMSHORT(FALSE);
break;
}
return WinDefWindowProc(hwnd, msg, mp1, mp2);
}