Annotation of mstools/samples/ntfonts/dialogs.c, revision 1.1

1.1     ! root        1: /**************************************************************************\
        !             2: *  dialogs.c -- module for the two dialogs (LOGFONT & TEXTMETRIC)
        !             3: *   Includes the window procedure and an initialization routine.
        !             4: *   (Both routines serve for both of the dialog windows.)
        !             5: *
        !             6: \**************************************************************************/
        !             7: 
        !             8: #include <windows.h>
        !             9: #include <string.h>
        !            10: #include "ntfonts.h"
        !            11: 
        !            12: 
        !            13: 
        !            14: int initDlg(HWND hwndMain)
        !            15: {
        !            16:   hwndDlgTM = CreateDialog (hInst, "textmetricDlg", hwndMain,
        !            17:                (DLGPROC)LogFontWndProc);
        !            18:   if (hwndDlgTM == NULL) return FALSE;
        !            19: 
        !            20:   SetWindowPos (hwndDlgTM, NULL,
        !            21:                 CHILDLEFT(0), CHILDTOP,
        !            22:                 0,0, SWP_NOZORDER | SWP_NOSIZE);
        !            23: 
        !            24: 
        !            25: 
        !            26:   hwndDlgLF = CreateDialog (hInst, "logfontDlg", hwndMain,
        !            27:                (DLGPROC)LogFontWndProc);
        !            28:   if (hwndDlgLF == NULL) return FALSE;
        !            29: 
        !            30:   SetWindowPos (hwndDlgLF, NULL,
        !            31:                 CHILDLEFT(1), CHILDTOP,
        !            32:                 0,0, SWP_NOZORDER | SWP_NOSIZE);
        !            33: 
        !            34:   SetClassLong (hwndDlgLF, GCL_HICON, (LONG)LoadIcon(hInst, "ntfontsIcon"));
        !            35: 
        !            36: 
        !            37:   return TRUE;
        !            38: }
        !            39: 
        !            40: 
        !            41: 
        !            42: /**************************************************************************\
        !            43: *
        !            44: *  function:  LogFontWndProc
        !            45: *
        !            46: *  input parameters:  normal window procedure parameters.
        !            47: *  global variables:
        !            48: *
        !            49: * This window procedure is used for two completely different dialog boxes.
        !            50: \**************************************************************************/
        !            51: LRESULT LogFontWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
        !            52: {
        !            53: static LPLOGFONT    lplf;
        !            54: static LPTEXTMETRIC lptm;
        !            55: 
        !            56:   switch (message) {
        !            57: 
        !            58: 
        !            59:     /**********************************************************************\
        !            60:     *  WMU_DEMOTOLF
        !            61:     *
        !            62:     *  lParam - pointer to LOGFONT structure.
        !            63:     *
        !            64:     * User message.  Take the input LOGFONT and fill the edit fields of the
        !            65:     *  dialog box.
        !            66:     \**********************************************************************/
        !            67:     case WMU_DEMOTOLF: {
        !            68:       lplf = (LPLOGFONT) lParam;
        !            69: 
        !            70:       SetDlgItemInt (hwnd, DIDHEIGHT , lplf->lfHeight,        FALSE);
        !            71:       SetDlgItemInt (hwnd, DIDHEIGHT , lplf->lfHeight,        FALSE);
        !            72:       SetDlgItemInt (hwnd, DIDWIDTH  , lplf->lfWidth,         FALSE);
        !            73:       SetDlgItemInt (hwnd, DIDESCAPE , lplf->lfEscapement,    FALSE);
        !            74:       SetDlgItemInt (hwnd, DIDORIENT , lplf->lfOrientation,   FALSE);
        !            75:       SetDlgItemInt (hwnd, DIDWEIGHT , lplf->lfWeight,        FALSE);
        !            76:       SetDlgItemInt (hwnd, DIDITALIC , lplf->lfItalic,        FALSE);
        !            77:       SetDlgItemInt (hwnd, DIDUNDERL , lplf->lfUnderline,     FALSE);
        !            78:       SetDlgItemInt (hwnd, DIDSTRIKE , lplf->lfStrikeOut,     FALSE);
        !            79:       SetDlgItemInt (hwnd, DIDCHARSE , lplf->lfCharSet,       FALSE);
        !            80:       SetDlgItemInt (hwnd, DIDOUTPRE , lplf->lfOutPrecision,  FALSE);
        !            81:       SetDlgItemInt (hwnd, DIDCLIPPR , lplf->lfClipPrecision, FALSE);
        !            82:       SetDlgItemInt (hwnd, DIDQUALIT , lplf->lfQuality,       FALSE);
        !            83:       SetDlgItemInt (hwnd, DIDPITCHA , lplf->lfPitchAndFamily,FALSE);
        !            84:       SetDlgItemText (hwnd, DIDFACENA, lplf->lfFaceName);
        !            85: 
        !            86:     } break;
        !            87: 
        !            88: 
        !            89:     /**********************************************************************\
        !            90:     *  WMU_LFTODEMO
        !            91:     *
        !            92:     *  lParam - pointer to LOGFONT structure.
        !            93:     *
        !            94:     * User message.  Fill the input LOGFONT with the contents of the
        !            95:     *  edit fields of dialog box.
        !            96:     \**********************************************************************/
        !            97:     case WMU_LFTODEMO: {
        !            98:       BOOL  success;
        !            99:       lplf = (LPLOGFONT) lParam;
        !           100: 
        !           101: 
        !           102:       lplf->lfHeight =        GetDlgItemInt (hwnd, DIDHEIGHT, &success , FALSE);
        !           103:       lplf->lfHeight =        GetDlgItemInt (hwnd, DIDHEIGHT, &success , FALSE);
        !           104:       lplf->lfWidth  =        GetDlgItemInt (hwnd, DIDWIDTH , &success , FALSE);
        !           105:       lplf->lfEscapement =    GetDlgItemInt (hwnd, DIDESCAPE, &success , FALSE);
        !           106:       lplf->lfOrientation =   GetDlgItemInt (hwnd, DIDORIENT, &success , FALSE);
        !           107:       lplf->lfWeight =        GetDlgItemInt (hwnd, DIDWEIGHT, &success , FALSE);
        !           108:       lplf->lfItalic =        (BYTE) GetDlgItemInt (hwnd, DIDITALIC, &success , FALSE);
        !           109:       lplf->lfUnderline =     (BYTE) GetDlgItemInt (hwnd, DIDUNDERL, &success , FALSE);
        !           110:       lplf->lfStrikeOut =     (BYTE) GetDlgItemInt (hwnd, DIDSTRIKE, &success , FALSE);
        !           111:       lplf->lfCharSet =       (BYTE) GetDlgItemInt (hwnd, DIDCHARSE, &success , FALSE);
        !           112:       lplf->lfOutPrecision =  (BYTE) GetDlgItemInt (hwnd, DIDOUTPRE, &success , FALSE);
        !           113:       lplf->lfClipPrecision = (BYTE) GetDlgItemInt (hwnd, DIDCLIPPR, &success , FALSE);
        !           114:       lplf->lfQuality =       (BYTE) GetDlgItemInt (hwnd, DIDQUALIT, &success , FALSE);
        !           115:       lplf->lfPitchAndFamily =(BYTE) GetDlgItemInt (hwnd, DIDPITCHA, &success , FALSE);
        !           116:       GetDlgItemText (hwnd, DIDFACENA, lplf->lfFaceName, LF_FACESIZE);
        !           117: 
        !           118:     } break;
        !           119: 
        !           120: 
        !           121: 
        !           122:     /**********************************************************************\
        !           123:     *  WMU_DEMOTOTM
        !           124:     *
        !           125:     *  lParam - pointer to TEXTMETRIC structure.
        !           126:     *
        !           127:     * User message.  Take the input LOGFONT and fill the list box with
        !           128:     *  strings.  Turn off update before hand, then reenable when complete.
        !           129:     \**********************************************************************/
        !           130:     case WMU_DEMOTOTM: {
        !           131:       char buffer[100];
        !           132: //      WORD tabs;
        !           133: 
        !           134:       lptm = (LPTEXTMETRIC) lParam;
        !           135: 
        !           136:       SendDlgItemMessage (hwnd, DID_LISTBOX, WM_SETREDRAW, FALSE, 0);
        !           137:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_RESETCONTENT, 0, 0);
        !           138: //      tabs = sizeof("tmDigitizedAspectY") *4;
        !           139: //      SendDlgItemMessage (hwnd, DID_LISTBOX, LB_SETTABSTOPS, 1, (LONG)&tabs);
        !           140: 
        !           141:       wsprintf (buffer, "tmHeight        \t%d",(int) lptm->tmHeight           );
        !           142:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
        !           143:       wsprintf (buffer, "tmAscent        \t%d",(int) lptm->tmAscent           );
        !           144:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
        !           145:       wsprintf (buffer, "tmDescent       \t%d",(int) lptm->tmDescent          );
        !           146:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
        !           147:       wsprintf (buffer, "tmInternalLeading\t%d",(int) lptm->tmInternalLeading  );
        !           148:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
        !           149:       wsprintf (buffer, "tmExternalLeading\t%d",(int) lptm->tmExternalLeading  );
        !           150:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
        !           151:       wsprintf (buffer, "tmAveCharWidth  \t%d",(int) lptm->tmAveCharWidth     );
        !           152:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
        !           153:       wsprintf (buffer, "tmMaxCharWidth  \t%d",(int) lptm->tmMaxCharWidth     );
        !           154:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
        !           155:       wsprintf (buffer, "tmWeight        \t%d",(int) lptm->tmWeight           );
        !           156:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
        !           157:       wsprintf (buffer, "tmOverhang      \t%d",(int) lptm->tmOverhang         );
        !           158:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
        !           159:       wsprintf (buffer, "tmDigitizedAspectX\t%d",(int) lptm->tmDigitizedAspectX );
        !           160:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
        !           161:       wsprintf (buffer, "tmDigitizedAspectY\t%d",(int) lptm->tmDigitizedAspectY );
        !           162:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
        !           163:       wsprintf (buffer, "tmItalic        \t%d",(int) lptm->tmItalic           );
        !           164:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
        !           165:       wsprintf (buffer, "tmUnderlined    \t%d",(int) lptm->tmUnderlined       );
        !           166:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
        !           167:       wsprintf (buffer, "tmStruckOut     \t%d",(int) lptm->tmStruckOut        );
        !           168:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
        !           169:       wsprintf (buffer, "tmFirstChar     \t%d",(int) lptm->tmFirstChar        );
        !           170:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
        !           171:       wsprintf (buffer, "tmLastChar      \t%d",(int) lptm->tmLastChar         );
        !           172:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
        !           173:       wsprintf (buffer, "tmDefaultChar   \t%d",(int) lptm->tmDefaultChar      );
        !           174:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
        !           175:       wsprintf (buffer, "tmBreakChar     \t%d",(int) lptm->tmBreakChar        );
        !           176:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
        !           177:       wsprintf (buffer, "tmPitchAndFamily\t%d",(int) lptm->tmPitchAndFamily   );
        !           178:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
        !           179:       wsprintf (buffer, "tmCharSet       \t%d",(int) lptm->tmCharSet          );
        !           180:       SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
        !           181: 
        !           182:       SendDlgItemMessage (hwnd, DID_LISTBOX, WM_SETREDRAW, TRUE, 0);
        !           183:       InvalidateRect (hwnd, NULL, TRUE);
        !           184:       UpdateWindow (hwnd);
        !           185: 
        !           186:     } break;
        !           187: 
        !           188: 
        !           189:   } /* end switch */
        !           190:   return (NULL);
        !           191: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.