home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / PMFONT.ZIP / FONTS.C < prev    next >
Text File  |  1991-06-27  |  3KB  |  102 lines

  1. #define INCL_WIN
  2. #include <os2.h>
  3. #include <string.h>
  4.  
  5. #define INIT_W  450
  6. #define INIT_H  250
  7.  
  8. SHORT cdecl main(VOID);
  9. extern VOID EXPENTRY FntQueryList(HWND);
  10. MRESULT EXPENTRY FontsWinProc(HWND, USHORT, MPARAM, MPARAM);
  11.  
  12. HAB   hab;
  13. HWND hwFr, hwCl, hwList, hwClList;
  14.  
  15. SHORT cdecl main()
  16.   {
  17.   HMQ   hmq;
  18.   QMSG  qmsg;
  19.   ULONG flCr    = FCF_STANDARD & ~(FCF_ACCELTABLE | FCF_MENU);
  20.   PSZ   szClass = "Fonts";
  21.  
  22.   hab = WinInitialize(0);
  23.   hmq = WinCreateMsgQueue(hab, 0);
  24.  
  25.   WinRegisterClass(hab, szClass, FontsWinProc,
  26.                    CS_CLIPCHILDREN | CS_SIZEREDRAW, 0 );
  27.  
  28.   hwFr = WinCreateStdWindow(HWND_DESKTOP, FS_SHELLPOSITION | FS_TASKLIST,
  29.                             &flCr, szClass, "", WS_VISIBLE,
  30.                             (HMODULE)0, 256, &hwCl );
  31.  
  32.   WinSetWindowPos(hwFr, HWND_TOP, 150, 150, INIT_W, INIT_H,
  33.                   SWP_ACTIVATE | SWP_MOVE | SWP_SIZE | SWP_SHOW );
  34.  
  35.   WinSetWindowText(hwFr, "Font List for Presentation Parameters");
  36.  
  37.   while (WinGetMsg(hab, &qmsg, (HWND)0, 0, 0))
  38.     WinDispatchMsg(hab, &qmsg);
  39.  
  40.   WinDestroyMsgQueue(hmq);
  41.   WinTerminate(hab);
  42.   return 0;
  43.   }
  44.  
  45.  
  46. MRESULT EXPENTRY FontsWinProc(hwnd, msg, mp1, mp2)
  47. HWND   hwnd;
  48. USHORT msg;
  49. MPARAM mp1;
  50. MPARAM mp2;
  51.   {
  52.   HPS   hps;
  53.   RECTL rcl;
  54.   SHORT i;
  55.  
  56.   switch (msg) {
  57.  
  58.     case WM_CREATE:
  59.       hwList = WinCreateWindow(hwnd, WC_LISTBOX, "",
  60.                                LS_NOADJUSTPOS | WS_VISIBLE,
  61.                                4, 4, INIT_W - 8, INIT_H - 8,
  62.                                hwnd, HWND_TOP, 257, (PVOID)0, (PVOID)0 );
  63.       FntQueryList(hwList);
  64.       WinSetPresParam(hwList, PP_FONTNAMESIZE, 11L, "10.Courier\0");
  65.       if (i = (SHORT)WinSendMsg(hwList, LM_SEARCHSTRING,
  66.                                 MPFROM2SHORT(LSS_CASESENSITIVE | LSS_PREFIX,
  67.                                              LIT_FIRST ),
  68.                                 MPFROMP("10.Courier") ) )
  69.         WinSendMsg(hwList, LM_SELECTITEM, MPFROMSHORT(i), MPFROMSHORT(TRUE));
  70.       break;
  71.  
  72.     case WM_CONTROL:
  73.       if (SHORT2FROMMP(mp1) == LN_SELECT) {
  74.         CHAR pch[64];
  75.         PSZ  psz;
  76.  
  77.         i = (USHORT)WinSendMsg(HWNDFROMMP(mp2), LM_QUERYSELECTION,
  78.                                MPFROMSHORT(LIT_FIRST), (MPARAM)0 );
  79.         WinSendMsg(HWNDFROMMP(mp2), LM_QUERYITEMTEXT,
  80.                    MPFROM2SHORT(i, 64), MPFROMP(pch) );
  81.         psz = (PSZ)((pch[0] == ' ') ? pch + 1 : pch);
  82.         WinSetPresParam(hwList, PP_FONTNAMESIZE,
  83.                         (ULONG)strlen(psz) + 1L, psz );
  84.         }
  85.       break;
  86.  
  87.     case WM_PAINT:
  88.       hps = WinBeginPaint(hwnd, (HPS)0, &rcl);
  89.       WinFillRect(hps, &rcl, CLR_BLUE);
  90.       WinQueryWindowRect(hwnd, &rcl);
  91.       WinSetWindowPos(hwList, HWND_TOP,
  92.                       4L, 4L, (SHORT)rcl.xRight - 8, (SHORT)rcl.yTop - 8,
  93.                       SWP_MOVE | SWP_SIZE | SWP_ZORDER );
  94.       WinEndPaint(hps);
  95.       return MRFROMSHORT(FALSE);
  96.       break;
  97.  
  98.     }
  99.  
  100.   return WinDefWindowProc(hwnd, msg, mp1, mp2);
  101.   }  
  102.