home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / graphics / gdi / fonts / ttfonts / dialogs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-10-07  |  21.6 KB  |  493 lines

  1.  
  2. /******************************************************************************\
  3. *       This is a part of the Microsoft Source Code Samples. 
  4. *       Copyright (C) 1992-1997 Microsoft Corporation.
  5. *       All rights reserved. 
  6. *       This source code is only intended as a supplement to 
  7. *       Microsoft Development Tools and/or WinHelp documentation.
  8. *       See these sources for detailed information regarding the 
  9. *       Microsoft samples programs.
  10. \******************************************************************************/
  11.  
  12. /**************************************************************************\
  13. *  dialogs.c -- module for the two dialogs (LOGFONT & TEXTMETRIC)
  14. *   Includes the window procedure and an initialization routine.
  15. *  the LogFontWndProc is actually used for multiple dialogs.
  16. \**************************************************************************/
  17.  
  18. #include <windows.h>
  19. #include <string.h>
  20. #include <stdio.h>
  21. #include "ttfonts.h"
  22.  
  23.  
  24.  
  25. int initDlg(HWND hwndMain)
  26. {
  27.   /*  load three dialogs and position them. Set the minimize icon for
  28.    *   this CLASS and it affects all dialog windows.
  29.    */
  30.  
  31.   hwndDlgLF = CreateDialog (hInst, TEXT("logfontDlg"), hwndMain,
  32.                 (DLGPROC)LogFontWndProc);
  33.   if (hwndDlgLF == NULL) return FALSE;
  34.  
  35.   SetWindowPos (hwndDlgLF, NULL,
  36.                 CHILDLEFT(1), CHILDTOP,
  37.                 0,0, SWP_NOZORDER | SWP_NOSIZE);
  38.  
  39.  
  40.   hwndDlgTM = CreateDialog (hInst, TEXT("textmetricDlg"), hwndMain,
  41.                 (DLGPROC)LogFontWndProc);
  42.   if (hwndDlgTM == NULL) return FALSE;
  43.  
  44.   SetWindowPos (hwndDlgTM, NULL,
  45.                 CHILDLEFT(0), CHILDTOP,
  46.                 0,0, SWP_NOZORDER | SWP_NOSIZE);
  47.  
  48.  
  49.  
  50.   hwndDlgOLTM = CreateDialog (hInst, TEXT("oltextmetricDlg"), hwndMain,
  51.                 (DLGPROC)LogFontWndProc);
  52.   if (hwndDlgOLTM == NULL) return FALSE;
  53.   ShowWindow (hwndDlgOLTM, SW_MINIMIZE);
  54.  
  55.  
  56.  
  57.  
  58.   hwndDlgFD = CreateDialog (hInst, TEXT("getfontdataDlg"), hwndMain,
  59.                 (DLGPROC)FontDataWndProc);
  60.   if (hwndDlgFD == NULL) return FALSE;
  61.   ShowWindow (hwndDlgFD, SW_MINIMIZE);
  62.   SetWindowPos (hwndDlgFD, HWND_TOP,
  63.                 0, 0,
  64.                 0,0, SWP_NOSIZE );
  65.  
  66.  
  67.  
  68.   SetClassLong (hwndDlgLF, GCL_HICON, (LONG)LoadIcon(hInst, TEXT("ttfontsIcon")));
  69.  
  70.  
  71.   return TRUE;
  72. }
  73.  
  74.  
  75. /* first and last string IDs from string table in RC file */
  76. #define FIRSTSTRING 1
  77. #define LASTSTRING  20
  78.  
  79.  
  80.  
  81. /**************************************************************************\
  82. *
  83. *  function:  FontDataWndProc
  84. *
  85. *  input parameters:  normal window procedure parameters.
  86. *
  87. *  Allow the user to select a table, an offset, and a byte count.
  88. *   on command message, post self a user message (allows the user
  89. *   message to come in from other sources too).  On the user message,
  90. *   just call GetFontData and display the results.
  91. *
  92. *
  93.   // UNICODE NOTICE
  94.   //  Parts of this are held as ANSI because the dwTable
  95.   //  in the fontdata is stored with four 8 bit chars.
  96.   //  And because there is not yet a wide char version of sscanf().
  97. *
  98. *
  99. \**************************************************************************/
  100. LRESULT CALLBACK FontDataWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  101. {
  102. #define NCHAR 255
  103. TCHAR buffer[NCHAR];
  104. HDC hdc;
  105. int nBytes, nStrings, i;
  106.  
  107.  
  108.   switch (message) {
  109.  
  110.     /* fill combo box w/ table names, and
  111.      *  entry fields w/ meaningful initial values.
  112.      */
  113.     case WM_INITDIALOG:
  114.       SetDlgItemInt (hwnd, DID_DWOFFSET, 0, TRUE);
  115.       SetDlgItemInt (hwnd, DID_CBDATA, 50, TRUE);
  116.       for (i = FIRSTSTRING; i<= LASTSTRING; i++) {
  117.         LoadString (GetModuleHandle (NULL), i, buffer, NCHAR);
  118.         SendDlgItemMessage (hwnd, DID_DWTABLE, CB_ADDSTRING, 0, (LPARAM)buffer);
  119.       }
  120.  
  121.     return TRUE;
  122.  
  123.     /* If the user hits the DOIT button, post message back to the
  124.      *  main window.  It will get an HDC and then post us the proper
  125.      *  user message.
  126.      */
  127.     case WM_COMMAND:
  128.       if (wParam == DID_DOIT)
  129.         PostMessage (hwndMain, WM_COMMAND, TBID_GETFONTDATA, 0);
  130.     break;  /* end WM_COMMAND */
  131.  
  132.  
  133.  
  134.     /**********************************************************************\
  135.     *  WMU_GETFONTDATA
  136.     *
  137.     *  lParam - HDC.
  138.     *
  139.     * User message.  Parse the contents of the entry fields, and make the
  140.     *  GetFontData() call.  Put results in the listbox.
  141.     \**********************************************************************/
  142.     case WMU_GETFONTDATA: {
  143.         DWORD dwTable, dwOffset, cbData;
  144.         LPBYTE   lpDataBuffer;
  145.         DWORD dwNBytes;
  146.  
  147.         hdc = (HDC) lParam;
  148.         SendDlgItemMessage (hwnd, DID_LISTBOX, LB_RESETCONTENT, 0, 0);
  149.  
  150.  
  151.         {
  152.           // UNICODE NOTICE.  GetDlgItemTextA returns ANSI strings.
  153.           //  we are doing manipulation on a byte by byte basis
  154.  
  155.           CHAR  fourbytes[5];
  156.           CHAR  sbBuffer[NCHAR];
  157.  
  158.           nBytes = GetDlgItemTextA (hwnd, DID_DWTABLE, fourbytes, 5);
  159.           if (nBytes == 0) {
  160.             dwTable = 0;
  161.           } else {
  162.             dwTable = (DWORD) ((fourbytes[3] << 24)
  163.                             +  (fourbytes[2] << 16)
  164.                             +  (fourbytes[1] <<  8)
  165.                             +  (fourbytes[0]));
  166.           }
  167.  
  168.  
  169.           // UNICODE NOTICE.  GetDlgItemTextA returns ANSI strings.
  170.           //  sscanf expects single byte strings.
  171.  
  172.           GetDlgItemTextA (hwnd, DID_DWOFFSET, sbBuffer, NCHAR);
  173.           sscanf (sbBuffer, "%x", &dwOffset);
  174.           GetDlgItemTextA (hwnd, DID_CBDATA  , sbBuffer, NCHAR);
  175.           sscanf (sbBuffer, "%x", &cbData);
  176.         }
  177.  
  178.  
  179.         lpDataBuffer = (LPBYTE) LocalAlloc (LPTR, cbData);
  180.         if (lpDataBuffer == NULL) {
  181.           MessageBox (NULL, szAllocFailed, szMBERROR, MBERRORFLAGS);
  182.           return 0;
  183.         }
  184.  
  185.         dwNBytes = GetFontData (hdc, dwTable, dwOffset, (LPVOID) lpDataBuffer, cbData);
  186.  
  187.         if (dwNBytes == -1) {
  188.           MessageBox (NULL, szFontDataErr, szMBERROR, MBERRORFLAGS);
  189.         } else {
  190.  
  191.           nStrings = dwNBytes / 16;
  192.           for (i = 0; i< nStrings; i++) {
  193.             wsprintf (buffer,
  194.                       TEXT("%02x%02x %02x%02x  %02x%02x %02x%02x  %02x%02x %02x%02x  %02x%02x %02x%02x"),
  195.                       (int)lpDataBuffer[i*16+0],
  196.                       (int)lpDataBuffer[i*16+1],
  197.                       (int)lpDataBuffer[i*16+2],
  198.                       (int)lpDataBuffer[i*16+3],
  199.                       (int)lpDataBuffer[i*16+4],
  200.                       (int)lpDataBuffer[i*16+5],
  201.                       (int)lpDataBuffer[i*16+6],
  202.                       (int)lpDataBuffer[i*16+7],
  203.                       (int)lpDataBuffer[i*16+8],
  204.                       (int)lpDataBuffer[i*16+9],
  205.                       (int)lpDataBuffer[i*16+10],
  206.                       (int)lpDataBuffer[i*16+11],
  207.                       (int)lpDataBuffer[i*16+12],
  208.                       (int)lpDataBuffer[i*16+13],
  209.                       (int)lpDataBuffer[i*16+14],
  210.                       (int)lpDataBuffer[i*16+15]);
  211.             SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
  212.           }
  213.         }
  214.  
  215.         LocalFree ( LocalHandle ((LPVOID)lpDataBuffer));
  216.     } return TRUE;  /* end WMU_GETFONTDATA */
  217.  
  218.   } /* end switch */
  219.   return 0;
  220. }
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227. /**************************************************************************\
  228. *
  229. *  function:  LogFontWndProc
  230. *
  231. *  input parameters:  normal window procedure parameters.
  232. *  global variables:
  233. *
  234. * This window procedure is used for two completely different dialog boxes.
  235. \**************************************************************************/
  236. LRESULT CALLBACK LogFontWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  237. {
  238. static LPLOGFONT    lplf;
  239. static LPTEXTMETRIC lptm;
  240.  
  241.   switch (message) {
  242.  
  243.  
  244.     /**********************************************************************\
  245.     *  WMU_DEMOTOLF
  246.     *
  247.     *  lParam - pointer to LOGFONT structure.
  248.     *
  249.     * User message.  Take the input LOGFONT and fill the edit fields of the
  250.     *  dialog box.
  251.     \**********************************************************************/
  252.     case WMU_DEMOTOLF: {
  253.       lplf = (LPLOGFONT) lParam;
  254.  
  255.       SetDlgItemInt (hwnd, DIDHEIGHT , lplf->lfHeight,        TRUE);
  256.       SetDlgItemInt (hwnd, DIDWIDTH  , lplf->lfWidth,         TRUE);
  257.       SetDlgItemInt (hwnd, DIDESCAPE , lplf->lfEscapement,    TRUE);
  258.       SetDlgItemInt (hwnd, DIDORIENT , lplf->lfOrientation,   TRUE);
  259.       SetDlgItemInt (hwnd, DIDWEIGHT , lplf->lfWeight,        TRUE);
  260.       SetDlgItemInt (hwnd, DIDITALIC , lplf->lfItalic,        FALSE);
  261.       SetDlgItemInt (hwnd, DIDUNDERL , lplf->lfUnderline,     FALSE);
  262.       SetDlgItemInt (hwnd, DIDSTRIKE , lplf->lfStrikeOut,     FALSE);
  263.       SetDlgItemInt (hwnd, DIDCHARSE , lplf->lfCharSet,       FALSE);
  264.       SetDlgItemInt (hwnd, DIDOUTPRE , lplf->lfOutPrecision,  FALSE);
  265.       SetDlgItemInt (hwnd, DIDCLIPPR , lplf->lfClipPrecision, FALSE);
  266.       SetDlgItemInt (hwnd, DIDQUALIT , lplf->lfQuality,       FALSE);
  267.       SetDlgItemInt (hwnd, DIDPITCHA , lplf->lfPitchAndFamily,FALSE);
  268.       SetDlgItemText (hwnd, DIDFACENA, lplf->lfFaceName);
  269.  
  270.     } break;
  271.  
  272.  
  273.     /**********************************************************************\
  274.     *  WMU_LFTODEMO
  275.     *
  276.     *  lParam - pointer to LOGFONT structure.
  277.     *
  278.     * User message.  Fill the input LOGFONT with the contents of the
  279.     *  edit fields of dialog box.
  280.     \**********************************************************************/
  281.     case WMU_LFTODEMO: {
  282.       BOOL  success;
  283.       lplf = (LPLOGFONT) lParam;
  284.  
  285.  
  286.       lplf->lfHeight =        GetDlgItemInt (hwnd, DIDHEIGHT, &success , TRUE);
  287.       lplf->lfWidth  =        GetDlgItemInt (hwnd, DIDWIDTH , &success , TRUE);
  288.       lplf->lfEscapement =    GetDlgItemInt (hwnd, DIDESCAPE, &success , TRUE);
  289.       lplf->lfOrientation =   GetDlgItemInt (hwnd, DIDORIENT, &success , TRUE);
  290.       lplf->lfWeight =        GetDlgItemInt (hwnd, DIDWEIGHT, &success , TRUE);
  291.       lplf->lfItalic =        (BYTE) GetDlgItemInt (hwnd, DIDITALIC, &success , FALSE);
  292.       lplf->lfUnderline =     (BYTE) GetDlgItemInt (hwnd, DIDUNDERL, &success , FALSE);
  293.       lplf->lfStrikeOut =     (BYTE) GetDlgItemInt (hwnd, DIDSTRIKE, &success , FALSE);
  294.       lplf->lfCharSet =       (BYTE) GetDlgItemInt (hwnd, DIDCHARSE, &success , FALSE);
  295.       lplf->lfOutPrecision =  (BYTE) GetDlgItemInt (hwnd, DIDOUTPRE, &success , FALSE);
  296.       lplf->lfClipPrecision = (BYTE) GetDlgItemInt (hwnd, DIDCLIPPR, &success , FALSE);
  297.       lplf->lfQuality =       (BYTE) GetDlgItemInt (hwnd, DIDQUALIT, &success , FALSE);
  298.       lplf->lfPitchAndFamily =(BYTE) GetDlgItemInt (hwnd, DIDPITCHA, &success , FALSE);
  299.       GetDlgItemText (hwnd, DIDFACENA, lplf->lfFaceName, LF_FACESIZE);
  300.  
  301.     } break;
  302.  
  303.  
  304.  
  305.     /**********************************************************************\
  306.     *  WMU_DEMOTOTM
  307.     *
  308.     *  lParam - pointer to TEXTMETRIC structure.
  309.     *
  310.     * User message.  Take the input LOGFONT and fill the list box with
  311.     *  strings.  Turn off update before hand, then reenable when complete.
  312.     \**********************************************************************/
  313.     case WMU_DEMOTOTM: {
  314.       TCHAR buffer[100];
  315.  
  316.       lptm = (LPTEXTMETRIC) lParam;
  317.  
  318.       SendDlgItemMessage (hwnd, DID_LISTBOX, WM_SETREDRAW, FALSE, 0);
  319.       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_RESETCONTENT, 0, 0);
  320.  
  321. #define LBPUT SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
  322.  
  323.       wsprintf (buffer, TEXT("tmHeight        \t%d")  ,(int) lptm->tmHeight           ); LBPUT
  324.       wsprintf (buffer, TEXT("tmAscent        \t%d")  ,(int) lptm->tmAscent           ); LBPUT
  325.       wsprintf (buffer, TEXT("tmDescent       \t%d")  ,(int) lptm->tmDescent          ); LBPUT
  326.       wsprintf (buffer, TEXT("tmInternalLeading\t%d") ,(int) lptm->tmInternalLeading  ); LBPUT
  327.       wsprintf (buffer, TEXT("tmExternalLeading\t%d") ,(int) lptm->tmExternalLeading  ); LBPUT
  328.       wsprintf (buffer, TEXT("tmAveCharWidth  \t%d")  ,(int) lptm->tmAveCharWidth     ); LBPUT
  329.       wsprintf (buffer, TEXT("tmMaxCharWidth  \t%d")  ,(int) lptm->tmMaxCharWidth     ); LBPUT
  330.       wsprintf (buffer, TEXT("tmWeight        \t%d")  ,(int) lptm->tmWeight           ); LBPUT
  331.       wsprintf (buffer, TEXT("tmOverhang      \t%d")  ,(int) lptm->tmOverhang         ); LBPUT
  332.       wsprintf (buffer, TEXT("tmDigitizedAspectX\t%d"),(int) lptm->tmDigitizedAspectX ); LBPUT
  333.       wsprintf (buffer, TEXT("tmDigitizedAspectY\t%d"),(int) lptm->tmDigitizedAspectY ); LBPUT
  334.       wsprintf (buffer, TEXT("tmItalic        \t%d")  ,(int) lptm->tmItalic           ); LBPUT
  335.       wsprintf (buffer, TEXT("tmUnderlined    \t%d")  ,(int) lptm->tmUnderlined       ); LBPUT
  336.       wsprintf (buffer, TEXT("tmStruckOut     \t%d")  ,(int) lptm->tmStruckOut        ); LBPUT
  337.       wsprintf (buffer, TEXT("tmFirstChar     \t%d")  ,(int) lptm->tmFirstChar        ); LBPUT
  338.       wsprintf (buffer, TEXT("tmLastChar      \t%d")  ,(int) lptm->tmLastChar         ); LBPUT
  339.       wsprintf (buffer, TEXT("tmDefaultChar   \t%d")  ,(int) lptm->tmDefaultChar      ); LBPUT
  340.       wsprintf (buffer, TEXT("tmBreakChar     \t%d")  ,(int) lptm->tmBreakChar        ); LBPUT
  341.       wsprintf (buffer, TEXT("tmPitchAndFamily\t%d")  ,(int) lptm->tmPitchAndFamily   ); LBPUT
  342.       wsprintf (buffer, TEXT("tmCharSet       \t%d")  ,(int) lptm->tmCharSet          ); LBPUT
  343.  
  344.       SendDlgItemMessage (hwnd, DID_LISTBOX, WM_SETREDRAW, TRUE, 0);
  345.       InvalidateRect (hwnd, NULL, TRUE);
  346.       UpdateWindow (hwnd);
  347.  
  348.     } break;
  349.  
  350.  
  351.     /**********************************************************************\
  352.     *  WMU_DEMOTOOLTM
  353.     *
  354.     *  lParam - HDC.
  355.     *
  356.     * User message.  With the input HDC, allocate space for OUTLINETEXTMETRIC
  357.     *  structure, query it from the HDC, and fill the listbox.  (Allocate the
  358.     *  OUTLINETEXTMETRIC structure dynamically since it is variable size.)
  359.     \**********************************************************************/
  360.     case WMU_DEMOTOOLTM: {
  361.       HDC hdc;
  362.       TCHAR buffer[100];
  363.       UINT cbData;
  364.       LPOUTLINETEXTMETRIC lpoltm;
  365.       LPBYTE lptStr;
  366.  
  367.       hdc = (HDC) lParam;
  368.  
  369.  
  370.       /* figure out how large the structure is, alloc, and re-query
  371.        *  unless cbData ==0, then post no-op string and exit.
  372.        */
  373.       cbData = GetOutlineTextMetrics (hdc, 0, NULL);
  374.       if (cbData == 0) {
  375.         SendDlgItemMessage (hwnd, DID_LISTBOX, LB_RESETCONTENT, 0, 0);
  376.         wsprintf (buffer, TEXT("cbData == 0")); LBPUT
  377.         return 0;
  378.       }
  379.       lpoltm = (LPOUTLINETEXTMETRIC)LocalAlloc (LPTR, cbData);
  380.       GetOutlineTextMetrics (hdc, cbData, lpoltm);
  381.  
  382.  
  383.       /* freeze redraw of listbox, and clear contents. */
  384.       SendDlgItemMessage (hwnd, DID_LISTBOX, WM_SETREDRAW, FALSE, 0);
  385.       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_RESETCONTENT, 0, 0);
  386.  
  387.  
  388.       wsprintf (buffer, TEXT("otmSize                \t%d"),(int) lpoltm->otmSize               );            LBPUT
  389.       wsprintf (buffer, TEXT("otmTextMetrics { }"));                                                      LBPUT
  390.       wsprintf (buffer, TEXT("otmFiller              \t%d"),(int)(BYTE) lpoltm->otmFiller             );      LBPUT
  391.  
  392.       wsprintf (buffer, TEXT("otmPanoseNumber           "));                                                  LBPUT
  393. // removed for beta 2.      wsprintf (buffer, TEXT("\t ulCulture        \t%d"),   (int) lpoltm->otmPanoseNumber.ulCulture        ); LBPUT
  394.       wsprintf (buffer, TEXT("\t bFamilyType      \t0x%lx"),(int) lpoltm->otmPanoseNumber.bFamilyType      ); LBPUT
  395.       wsprintf (buffer, TEXT("\t bSerifStyle      \t0x%lx"),(int) lpoltm->otmPanoseNumber.bSerifStyle      ); LBPUT
  396.       wsprintf (buffer, TEXT("\t bWeight          \t0x%lx"),(int) lpoltm->otmPanoseNumber.bWeight          ); LBPUT
  397.       wsprintf (buffer, TEXT("\t bProportion      \t0x%lx"),(int) lpoltm->otmPanoseNumber.bProportion      ); LBPUT
  398.       wsprintf (buffer, TEXT("\t bContrast        \t0x%lx"),(int) lpoltm->otmPanoseNumber.bContrast        ); LBPUT
  399.       wsprintf (buffer, TEXT("\t bStrokeVariation \t0x%lx"),(int) lpoltm->otmPanoseNumber.bStrokeVariation ); LBPUT
  400.       wsprintf (buffer, TEXT("\t bArmStyle        \t0x%lx"),(int) lpoltm->otmPanoseNumber.bArmStyle        ); LBPUT
  401.       wsprintf (buffer, TEXT("\t bLetterform      \t0x%lx"),(int) lpoltm->otmPanoseNumber.bLetterform      ); LBPUT
  402.       wsprintf (buffer, TEXT("\t bMidline         \t0x%lx"),(int) lpoltm->otmPanoseNumber.bMidline         ); LBPUT
  403.       wsprintf (buffer, TEXT("\t bXHeight         \t0x%lx"),(int) lpoltm->otmPanoseNumber.bXHeight         ); LBPUT
  404.  
  405.  
  406.       wsprintf (buffer, TEXT("otmfsSelection         \t%d"),(UINT) lpoltm->otmfsSelection        ); LBPUT
  407.       wsprintf (buffer, TEXT("otmfsType              \t%d"),(UINT) lpoltm->otmfsType             ); LBPUT
  408.       wsprintf (buffer, TEXT("otmsCharSlopeRise      \t%d"),(UINT) lpoltm->otmsCharSlopeRise     ); LBPUT
  409.       wsprintf (buffer, TEXT("otmsCharSlopeRun       \t%d"),(UINT) lpoltm->otmsCharSlopeRun      ); LBPUT
  410.       wsprintf (buffer, TEXT("otmItalicAngle         \t%d"),(UINT) lpoltm->otmItalicAngle        ); LBPUT
  411.       wsprintf (buffer, TEXT("otmEMSquare            \t%d"),(UINT) lpoltm->otmEMSquare           ); LBPUT
  412.       wsprintf (buffer, TEXT("otmAscent              \t%d"),(UINT) lpoltm->otmAscent             ); LBPUT
  413.       wsprintf (buffer, TEXT("otmDescent             \t%d"),(int) lpoltm->otmDescent             ); LBPUT
  414.       wsprintf (buffer, TEXT("otmLineGap             \t%d"),(int) lpoltm->otmLineGap             ); LBPUT
  415.       wsprintf (buffer, TEXT("otmsCapEmHeight        \t%d"),(UINT) lpoltm->otmsCapEmHeight        ); LBPUT
  416.       wsprintf (buffer, TEXT("otmsXHeight            \t%d"),(UINT) lpoltm->otmsXHeight            ); LBPUT
  417.       wsprintf (buffer, TEXT("otmrcFontBox           \t (%d, %d, %d, %d)"),
  418.                                                       (int) lpoltm->otmrcFontBox.left,
  419.                                                       (int) lpoltm->otmrcFontBox.top,
  420.                                                       (int) lpoltm->otmrcFontBox.right,
  421.                                                       (int) lpoltm->otmrcFontBox.bottom   ); LBPUT
  422.       wsprintf (buffer, TEXT("otmMacAscent           \t%d"),(int) lpoltm->otmMacAscent          ); LBPUT
  423.       wsprintf (buffer, TEXT("otmMacDescent          \t%d"),(int) lpoltm->otmMacDescent         ); LBPUT
  424.       wsprintf (buffer, TEXT("otmMacLineGap          \t%d"),(UINT) lpoltm->otmMacLineGap         ); LBPUT
  425.       wsprintf (buffer, TEXT("otmusMinimumPPEM       \t%d"),(UINT) lpoltm->otmusMinimumPPEM      ); LBPUT
  426.  
  427.       wsprintf (buffer, TEXT("otmptSubscriptSize     \t(%d, %d)"),
  428.                                                       (int) lpoltm->otmptSubscriptSize.x,
  429.                                                       (int) lpoltm->otmptSubscriptSize.y    ); LBPUT
  430.       wsprintf (buffer, TEXT("otmptSubscriptOffset   \t(%d, %d)"),
  431.                                                       (int) lpoltm->otmptSubscriptOffset.x,
  432.                                                       (int) lpoltm->otmptSubscriptOffset.y  ); LBPUT
  433.       wsprintf (buffer, TEXT("otmptSuperscriptSize   \t(%d, %d)"),
  434.                                                       (int) lpoltm->otmptSuperscriptSize.x,
  435.                                                       (int) lpoltm->otmptSuperscriptSize.y  ); LBPUT
  436.       wsprintf (buffer, TEXT("otmptSuperscriptOffset \t(%d, %d)"),
  437.                                                       (int) lpoltm->otmptSuperscriptOffset.x,
  438.                                                       (int) lpoltm->otmptSuperscriptOffset.y); LBPUT
  439.  
  440.       wsprintf (buffer, TEXT("otmsStrikeoutSize      \t%d"),(UINT) lpoltm->otmsStrikeoutSize     ); LBPUT
  441.       wsprintf (buffer, TEXT("otmsStrikeoutPosition  \t%d"),(int) lpoltm->otmsStrikeoutPosition );  LBPUT
  442.       wsprintf (buffer, TEXT("otmsUnderscoreSize     \t%d"),(int) lpoltm->otmsUnderscoreSize    );  LBPUT
  443.       wsprintf (buffer, TEXT("otmsUnderscorePosition \t%d"),(UINT) lpoltm->otmsUnderscorePosition); LBPUT
  444.  
  445.       /* the last 4 fields are incorrectly typed as PSTR,
  446.        *  they are in fact offsets from the top of the
  447.        *  OUTLINETEXTMETRIC structure, to the location of the string.
  448.        */
  449.       lptStr = (LPBYTE)lpoltm;
  450.       lptStr += (UINT) (PBYTE) lpoltm->otmpFamilyName;
  451.       wsprintf (buffer, TEXT("otmpFamilyName:   %s"),lptStr); LBPUT
  452.  
  453.       lptStr = (LPBYTE)lpoltm;
  454.       lptStr += (UINT) (PBYTE) lpoltm->otmpFaceName;
  455.       wsprintf (buffer, TEXT("otmpFaceName:   %s"),lptStr);   LBPUT
  456.  
  457.       lptStr = (LPBYTE)lpoltm;
  458.       lptStr += (UINT) (PBYTE) lpoltm->otmpStyleName;
  459.       wsprintf (buffer, TEXT("otmpStyleName:   %s"),lptStr);  LBPUT
  460.  
  461.       wsprintf (buffer, TEXT("otmpFullName:"));               LBPUT
  462.       lptStr = (LPBYTE)lpoltm;
  463.       lptStr += (UINT) (PBYTE) lpoltm->otmpFullName;
  464.       wsprintf (buffer, TEXT("  %s"),lptStr);                 LBPUT
  465.  
  466.  
  467.       SendDlgItemMessage (hwnd, DID_LISTBOX, WM_SETREDRAW, TRUE, 0);
  468.       InvalidateRect (hwnd, NULL, TRUE);
  469.       UpdateWindow (hwnd);
  470.  
  471.       /* balance LocalAlloc(), release memory. */
  472.       LocalFree (LocalHandle (lpoltm));
  473.  
  474.     } break;
  475.  
  476.  
  477.  
  478.     /**********************************************************************\
  479.     *  WM_CHILDACTIVATE
  480.     *
  481.     *  In order for these MDI child windows (dialogs) to be activated
  482.     *   correctly, the dialog procedure here must call the Win32 API
  483.     *   DefMDIChildProc ().
  484.     \**********************************************************************/
  485.     case WM_CHILDACTIVATE:
  486.       DefMDIChildProc(hwnd, message, wParam, lParam);
  487.       return TRUE;
  488.     break;
  489.  
  490.   } /* end switch */
  491.   return 0;
  492. }
  493.