Annotation of pmsdk/samples/fonttest/fonttest.c, revision 1.1

1.1     ! root        1: /****************************** Module Header ******************************\
        !             2: * Module Name: FONTTEST.C
        !             3: *
        !             4: * Example of a simple OS/2 Presentation Manager application
        !             5: *
        !             6: * Created by Microsoft Corp., 1988
        !             7: *
        !             8: \***************************************************************************/
        !             9: 
        !            10: #define INCL_GPI
        !            11: #define INCL_WIN
        !            12: #define INCL_WINCOMMON
        !            13: #define INCL_WINMESSAGEMGR
        !            14: 
        !            15: #include <os2.h>
        !            16: #include <pmfont.h>
        !            17: #include "fonttest.h"
        !            18: #define LINT_ARGS
        !            19: #include "string.h"
        !            20: 
        !            21: typedef BOOL FAR * LPBOOL;
        !            22: 
        !            23: HAB     vhab;
        !            24: HWND    vhwndFTClient;
        !            25: HWND    vhwndFTFrame;
        !            26: SHORT   vcch;
        !            27: 
        !            28: FATTRS        vfat;
        !            29: FONTMETRICS   vfm;
        !            30: 
        !            31: CHAR          szAlphabet[CCHMAX];
        !            32: CHAR          szAppName[8];
        !            33: 
        !            34: typedef struct _FONTDATA {
        !            35:   LONG xShear;
        !            36:   LONG yShear;
        !            37:   LONG xAngle;
        !            38:   LONG yAngle;
        !            39: } FONTDATA;
        !            40: 
        !            41: FATTRS        DisplayList[MAXLINES];
        !            42: FONTDATA      DisplayData[MAXLINES];
        !            43: SHORT         BottomLine  = 0;
        !            44: SHORT         TopLine     = 0;
        !            45: SHORT         FontDesired = 0;
        !            46: SHORT         FontInUse   = 0;
        !            47: LONG          FontsAvail  = FONTSAVAIL;
        !            48: FONTMETRICS   fm[FONTSAVAIL];
        !            49: 
        !            50: /***************************** Public  Function ****************************\
        !            51: *
        !            52: * Font Test Main procedure
        !            53: *
        !            54: * Effects: Set globals   - vhab        Handle to Application Anchor Block
        !            55: *
        !            56: * Warnings: None
        !            57: *
        !            58: \***************************************************************************/
        !            59: int cdecl main( )
        !            60: {
        !            61:     QMSG  qmsg;
        !            62:     HMQ   hmq;
        !            63:     CHAR  szTitle[21];
        !            64:     HPS   hps;
        !            65:     ULONG ctldata;
        !            66: 
        !            67:     vhab   = WinInitialize(NULL);
        !            68:     hmq = WinCreateMsgQueue( vhab, 0 );
        !            69: 
        !            70:     WinLoadString( vhab, NULL, IDS_NAME, sizeof(szAppName), szAppName );
        !            71: 
        !            72:     /*  Register Application Window Class.  Extra longword is used to
        !            73:         specify whether any string should be displayed and whether the
        !            74:         window should be redrawn.  */
        !            75: 
        !            76:     if ( !WinRegisterClass( vhab, szAppName, FonttestWndProc,
        !            77:                             0L, sizeof(ULONG)) )
        !            78:         return( FALSE );
        !            79: 
        !            80:     /* Create a window instance of class "FontTest" */
        !            81: 
        !            82:     WinLoadString( vhab, NULL, IDS_TITLE, sizeof(szTitle), szTitle );
        !            83: 
        !            84:     hps = WinGetPS(HWND_DESKTOP);
        !            85:     GpiQueryFontMetrics( hps, (LONG)sizeof(FONTMETRICS), &vfm );
        !            86:     WinReleasePS(hps);
        !            87: 
        !            88:     vfat.usRecordLength = sizeof(FATTRS);
        !            89:     vfat.fsSelection    = vfm.fsSelection;
        !            90:     vfat.lMatch         = 0L;
        !            91:     vfat.fsType = vfm.fsType;
        !            92:     strcpy(vfat.szFaceName, vfm.szFacename);
        !            93:     vfat.idRegistry = 0;
        !            94:     vfat.usCodePage = vfm.usCodePage;
        !            95:     vfat.lMaxBaselineExt = vfm.lMaxBaselineExt;
        !            96:     vfat.lAveCharWidth = vfm.lAveCharWidth;
        !            97:     vfat.sQuality      = FATTR_QUALITY_DEFAULT;
        !            98: 
        !            99:     ctldata = FCF_STANDARD;
        !           100: 
        !           101:     vhwndFTFrame = WinCreateStdWindow(
        !           102:         HWND_DESKTOP,     /* specify desktop as parent window       */
        !           103:                           /* window styles                          */
        !           104:         WS_VISIBLE | FS_ICON | FS_ACCELTABLE, 
        !           105:         &ctldata,         /* frame creation flags                   */ 
        !           106:         szAppName,        /* window class name                      */
        !           107:         szTitle,          /* name appearing in window caption       */
        !           108:         0L,               /* client styles                          */
        !           109:         NULL,             /*  use current executable module id      */
        !           110:         ID_FONTTEST,      /*  resource id                           */
        !           111:         &vhwndFTClient    /* window handle                          */
        !           112:         );
        !           113: 
        !           114:     vcch = WinLoadString( vhab, NULL, IDS_ALPHABET, CCHMAX, szAlphabet);
        !           115: 
        !           116:     while( WinGetMsg( vhab, &qmsg, NULL, 0, 0 ) )
        !           117:         WinDispatchMsg( vhab, &qmsg );
        !           118: 
        !           119:     WinDestroyWindow( vhwndFTFrame );
        !           120:     WinDestroyMsgQueue( hmq );
        !           121:     WinTerminate( vhab );
        !           122: }
        !           123: 
        !           124: 
        !           125: 
        !           126: /***************************** Public  Function ****************************\
        !           127: *
        !           128: * MRESULT EXPENTRY fnAboutDlg( hwndDlg, message, mp1, mp2     )
        !           129: * HWND   hwndDlg;
        !           130: * USHORT message;
        !           131: * ULONG  mp1;
        !           132: * ULONG  mp2;
        !           133: *
        !           134: * Effects: None
        !           135: *
        !           136: * Warnings: None
        !           137: *
        !           138: \***************************************************************************/
        !           139: 
        !           140: MRESULT EXPENTRY fnAboutDlg( hwndDlg, message, mp1, mp2     )
        !           141: HWND   hwndDlg;
        !           142: USHORT message;
        !           143: MPARAM mp1;
        !           144: MPARAM mp2;
        !           145: {
        !           146:     switch( message )
        !           147:     {
        !           148:       case WM_COMMAND:
        !           149:         switch( SHORT1FROMMP( mp1 ) )
        !           150:         {
        !           151:           case DID_OK:
        !           152:           case DID_CANCEL:
        !           153:             WinDismissDlg( hwndDlg, TRUE );
        !           154:             break;
        !           155: 
        !           156:           default:
        !           157:             return( (MRESULT)FALSE );
        !           158:         }
        !           159:       default:
        !           160:         return( WinDefDlgProc( hwndDlg, message, mp1, mp2 ) );
        !           161:     }
        !           162:     return( 0L );
        !           163: }
        !           164: 
        !           165:  
        !           166: /***************************** Private Function ****************************\
        !           167: *
        !           168: * VOID PASCAL RedrawScreen( hwnd, hps )
        !           169: * HWND hwnd;
        !           170: * HPS hps;
        !           171: *
        !           172: * Effects: None
        !           173: *
        !           174: * Warnings: None
        !           175: *
        !           176: \***************************************************************************/
        !           177: 
        !           178: 
        !           179: VOID PASCAL RedrawScreen ( hwnd, hps )
        !           180: HWND hwnd;
        !           181: HPS hps;
        !           182: {
        !           183:     POINTL ptl;
        !           184:     SHORT x;
        !           185:     CHARBUNDLE cb;
        !           186:     RECTL rcl;
        !           187:     SIZEF sizef;
        !           188:     POINTL pointl;
        !           189:     GRADIENTL gradientl;
        !           190: 
        !           191:     cb.lColor = SYSCLR_WINDOWTEXT;
        !           192:     GpiSetAttrs(hps, PRIM_CHAR, CBB_COLOR, 0L, (PBUNDLE)&cb );
        !           193:    
        !           194:     WinSetWindowULong ( hwnd, QWL_USER, 
        !           195:                         WinQueryWindowULong ( hwnd, QWL_USER ) & 
        !           196:                         (ULONG) ~ID_REDRAW );
        !           197: 
        !           198:     /* Special case for initial state. */
        !           199:     if ( (TopLine == BottomLine) &&
        !           200:          (WinQueryWindowULong (hwnd, QWL_USER) & ID_SHOW) )
        !           201:       {
        !           202:         ShowSampleString ( hwnd, hps );
        !           203:         return;
        !           204:       }
        !           205: 
        !           206:     ptl.x = 0L;
        !           207: 
        !           208:     x = TopLine;
        !           209:     while ( x != BottomLine )
        !           210:       {
        !           211:        x = (x + MAXLINES - 1) % MAXLINES;
        !           212:        sizef.cx = DisplayList[x].lAveCharWidth   * 65536;
        !           213:        sizef.cy = DisplayList[x].lMaxBaselineExt * 65536;
        !           214:        GpiSetCharBox ( hps, &sizef );
        !           215:        gradientl.x = DisplayData[x].xAngle;
        !           216:        gradientl.y = DisplayData[x].yAngle;
        !           217:        GpiSetCharAngle ( hps, &gradientl );
        !           218:        pointl.x = DisplayData[x].xShear;
        !           219:        pointl.y = DisplayData[x].yShear;
        !           220:        GpiSetCharShear ( hps, &pointl );
        !           221:        GpiCreateLogFont( hps, (PSTR8)szAppName, (LONG)ID_LCID, &DisplayList[x]);
        !           222:        GpiSetCharSet( hps, (LONG) ID_LCID );
        !           223:        GpiQueryFontMetrics( hps, (LONG)sizeof(FONTMETRICS), &vfm );
        !           224:        WinScrollWindow (hwnd, 0, (SHORT) vfm.lMaxBaselineExt, NULL, NULL, NULL,
        !           225:                         &rcl, 0);
        !           226:        WinFillRect (hps, &rcl, SYSCLR_WINDOW);
        !           227:        ptl.y = vfm.lMaxDescender + 1;
        !           228:        GpiCharStringAt( hps, &ptl, (long)vcch, szAlphabet );
        !           229:        GpiSetCharSet ( hps, 0L );
        !           230:        GpiDeleteSetId ( hps, (LONG) ID_LCID );
        !           231:       }
        !           232: 
        !           233: }
        !           234: 
        !           235: 
        !           236: /***************************** Private Function ****************************\
        !           237: *
        !           238: * VOID PASCAL ShowSampleString( hwnd, hps )
        !           239: * HWND hwnd;
        !           240: * HPS hps;
        !           241: *
        !           242: * Effects: None
        !           243: *
        !           244: * Warnings: None
        !           245: *
        !           246: \***************************************************************************/
        !           247: 
        !           248: 
        !           249: VOID PASCAL ShowSampleString( hwnd, hps )
        !           250: HWND hwnd;
        !           251: HPS hps;
        !           252: {
        !           253:     POINTL ptl;
        !           254:     CHARBUNDLE cb;
        !           255:     RECTL rcl;
        !           256:     SIZEF sizef;
        !           257:     GRADIENTL gradientl;
        !           258:     POINTL pointl;
        !           259: 
        !           260:     GpiLoadFonts( vhab, (PSZ) "fonts" );
        !           261: 
        !           262:     GpiQueryFonts ( hps, (ULONG) QUERY_PUBLIC_FONTS | QUERY_PRIVATE_FONTS, 
        !           263:        NULL, &FontsAvail, (LONG) sizeof(FONTMETRICS), fm);
        !           264: 
        !           265:     cb.lColor = SYSCLR_WINDOWTEXT;
        !           266:     GpiSetAttrs(hps, PRIM_CHAR, CBB_COLOR, 0L, (PBUNDLE)&cb );
        !           267: 
        !           268:     if ( (0 <= FontDesired) && (FontDesired < (SHORT) FontsAvail) )
        !           269:      {
        !           270:       vfat.lMatch = fm[FontDesired].lMatch;
        !           271:       FontInUse = FontDesired;
        !           272:      }
        !           273:     else
        !           274:      vfat.lMatch = fm[FontInUse].lMatch;
        !           275: 
        !           276:     sizef.cx = vfat.lAveCharWidth   * 65536;
        !           277:     sizef.cy = vfat.lMaxBaselineExt * 65536;
        !           278:     GpiSetCharBox ( hps, &sizef );
        !           279: 
        !           280:     gradientl.x = DisplayData[(BottomLine+MAXLINES-1)%MAXLINES].xAngle;
        !           281:     gradientl.y = DisplayData[(BottomLine+MAXLINES-1)%MAXLINES].yAngle;
        !           282:     GpiSetCharAngle ( hps, &gradientl );
        !           283:     
        !           284:     pointl.x = DisplayData[(BottomLine+MAXLINES-1)%MAXLINES].xShear;
        !           285:     pointl.y = DisplayData[(BottomLine+MAXLINES-1)%MAXLINES].yShear;
        !           286:     GpiSetCharShear ( hps, &pointl );
        !           287: 
        !           288:     GpiCreateLogFont( hps, (PSTR8) szAppName, (LONG) ID_LCID, &vfat );
        !           289: 
        !           290:     BottomLine = (BottomLine + MAXLINES - 1) % MAXLINES;
        !           291: 
        !           292:     /* Store the font attributes for the current line in the display list. */
        !           293:     DisplayList[BottomLine].usRecordLength   = vfat.usRecordLength;
        !           294:     DisplayList[BottomLine].fsSelection      = vfat.fsSelection;
        !           295:     DisplayList[BottomLine].lMatch           = vfat.lMatch;
        !           296:     DisplayList[BottomLine].fsType           = vfat.fsType;
        !           297:     DisplayList[BottomLine].idRegistry       = vfat.idRegistry;
        !           298:     DisplayList[BottomLine].usCodePage       = vfat.usCodePage;
        !           299:     DisplayList[BottomLine].lMaxBaselineExt  = vfat.lMaxBaselineExt;
        !           300:     DisplayList[BottomLine].lAveCharWidth    = vfat.lAveCharWidth;
        !           301:     DisplayList[BottomLine].sQuality         = vfat.sQuality;
        !           302:     DisplayList[BottomLine].fsFontUse        = vfat.fsFontUse;
        !           303:     strcpy ( DisplayList[BottomLine].szFaceName, vfat.szFaceName );
        !           304:  
        !           305:     if ( TopLine == BottomLine ) 
        !           306:        TopLine = (TopLine + MAXLINES - 1) % MAXLINES;
        !           307: 
        !           308:     GpiSetCharSet( hps, (LONG) ID_LCID );
        !           309:     GpiQueryFontMetrics( hps, (LONG)sizeof(FONTMETRICS), &vfm );
        !           310: 
        !           311:     WinScrollWindow (hwnd, 0, (SHORT) vfm.lMaxBaselineExt, NULL, NULL, NULL,
        !           312:                     &rcl, 0); 
        !           313:     WinFillRect (hps, &rcl, SYSCLR_WINDOW); 
        !           314: 
        !           315:     ptl.y = vfm.lMaxDescender + 1;
        !           316:     ptl.x = 0L;
        !           317:     GpiCharStringAt( hps, &ptl, (long)vcch, szAlphabet );
        !           318: 
        !           319:     GpiSetCharSet ( hps, 0L );
        !           320:     GpiDeleteSetId ( hps, (LONG) ID_LCID );
        !           321: 
        !           322: }
        !           323: 
        !           324: 
        !           325: /***************************** Private Function ****************************\
        !           326: *
        !           327: * VOID PASCAL InitDlg( hps, hwndDlg )
        !           328: * HPS  hps;
        !           329: * HWND hwndDlg;
        !           330: *
        !           331: * Effects: None
        !           332: *
        !           333: * Warnings: None
        !           334: *
        !           335: \***************************************************************************/
        !           336: 
        !           337: VOID PASCAL InitDlg( hdlg )
        !           338: HWND hdlg;
        !           339: {
        !           340:     if (vfat.fsSelection & FATTR_SEL_UNDERSCORE)
        !           341:         WinSendDlgItemMsg( hdlg, IDUNDERLINE, BM_SETCHECK,
        !           342:                 MPFROM2SHORT(TRUE, 0), 0L );
        !           343:     if (vfat.fsSelection & FATTR_SEL_STRIKEOUT)
        !           344:         WinSendDlgItemMsg( hdlg, IDSTRIKEOUT, BM_SETCHECK,
        !           345:                 MPFROM2SHORT(TRUE, 0), 0L );
        !           346:     if (vfat.fsSelection & FATTR_SEL_ITALIC)
        !           347:         WinSendDlgItemMsg( hdlg, IDITALIC, BM_SETCHECK,
        !           348:                 MPFROM2SHORT(TRUE, 0), 0L );
        !           349: 
        !           350:     if (vfat.fsType & FATTR_TYPE_FIXED)
        !           351:         WinSendDlgItemMsg( hdlg, IDPITCH, BM_SETCHECK,
        !           352:                 MPFROM2SHORT(TRUE, 0), 0L );
        !           353: 
        !           354:     WinSetDlgItemShort(hdlg, IDXSHEAR, 0, TRUE);
        !           355:     WinSetDlgItemShort(hdlg, IDYSHEAR, 1, TRUE);
        !           356:     WinSetDlgItemShort(hdlg, IDXANGLE, 1, TRUE);
        !           357:     WinSetDlgItemShort(hdlg, IDYANGLE, 0, TRUE);
        !           358:     WinSetDlgItemShort(hdlg, IDHEIGHT, (int)vfat.lMaxBaselineExt, TRUE);
        !           359:     WinSetDlgItemShort(hdlg, IDFMHEIGHT, (int)vfm.lEmHeight, TRUE);
        !           360:     WinSetDlgItemShort(hdlg, IDWIDTH, (int)vfat.lAveCharWidth, TRUE);
        !           361:     WinSetDlgItemShort(hdlg, IDFMWIDTH, (int)vfm.lAveCharWidth, TRUE);
        !           362:     WinSetDlgItemShort(hdlg, IDFMWEIGHT, (int)vfm.usWeightClass, TRUE);
        !           363:     WinSetDlgItemShort(hdlg, IDAVCHARWIDTH, (int)vfm.lAveCharWidth, TRUE);
        !           364:     WinSetDlgItemShort(hdlg, IDMAXCHARINC, (int)vfm.lMaxCharInc, TRUE);
        !           365:     WinSetDlgItemShort(hdlg, IDCODEPAGE, (int)vfat.usCodePage, TRUE);
        !           366:     WinSetDlgItemShort(hdlg, IDFMCODEPAGE, (int)vfm.usCodePage, TRUE);
        !           367:     WinSetDlgItemShort(hdlg, IDFONTDESIRED, FontDesired, TRUE);
        !           368:     WinSetDlgItemShort(hdlg, IDFONTINUSE, FontInUse, TRUE);
        !           369: }
        !           370: 
        !           371: 
        !           372: /***************************** Private Function ****************************\
        !           373: *
        !           374: * VOID PASCAL DlgCommand( hdlg, mp1 )
        !           375: * HWND  hdlg;
        !           376: * ULONG mp1;
        !           377: *
        !           378: * Effects: None
        !           379: *
        !           380: * Warnings: None
        !           381: *
        !           382: \***************************************************************************/
        !           383: 
        !           384: VOID PASCAL DlgCommand( hdlg, mp1 )
        !           385: HWND  hdlg;
        !           386: MPARAM mp1;
        !           387: {
        !           388:     SHORT sTmp;
        !           389: 
        !           390:     switch ( SHORT1FROMMP(mp1) )
        !           391:     {
        !           392:     case DID_OK:
        !           393: 
        !           394:         if (WinSendDlgItemMsg( hdlg, IDITALIC, BM_QUERYCHECK, 0L, 0L))
        !           395:             vfat.fsSelection |= FATTR_SEL_ITALIC;
        !           396:         else
        !           397:             vfat.fsSelection &= ~FATTR_SEL_ITALIC;
        !           398: 
        !           399:         if (WinSendDlgItemMsg( hdlg, IDUNDERLINE, BM_QUERYCHECK, 0L, 0L))
        !           400:             vfat.fsSelection |= FATTR_SEL_UNDERSCORE;
        !           401:         else
        !           402:             vfat.fsSelection &= ~FATTR_SEL_UNDERSCORE;
        !           403: 
        !           404:         if (WinSendDlgItemMsg( hdlg, IDSTRIKEOUT, BM_QUERYCHECK, 0L, 0L))
        !           405:             vfat.fsSelection |= FATTR_SEL_STRIKEOUT;
        !           406:         else
        !           407:             vfat.fsSelection &= ~FATTR_SEL_STRIKEOUT;
        !           408: 
        !           409:         WinQueryDlgItemShort(hdlg, IDWIDTH, &sTmp, TRUE);
        !           410:         vfat.lAveCharWidth = sTmp;
        !           411: 
        !           412:         WinQueryDlgItemShort(hdlg, IDHEIGHT, &sTmp, TRUE);
        !           413:         vfat.lMaxBaselineExt = sTmp;
        !           414: 
        !           415:         WinQueryDlgItemShort(hdlg, IDXSHEAR, &sTmp, TRUE);
        !           416:         DisplayData[(BottomLine+MAXLINES-1)%MAXLINES].xShear = (LONG) sTmp;
        !           417: 
        !           418:         WinQueryDlgItemShort(hdlg, IDYSHEAR, &sTmp, TRUE);
        !           419:         DisplayData[(BottomLine+MAXLINES-1)%MAXLINES].yShear = (LONG) sTmp;
        !           420:  
        !           421:         WinQueryDlgItemShort(hdlg, IDXANGLE, &sTmp, TRUE);
        !           422:         DisplayData[(BottomLine+MAXLINES-1)%MAXLINES].xAngle = (LONG) sTmp;
        !           423: 
        !           424:         WinQueryDlgItemShort(hdlg, IDYANGLE, &sTmp, TRUE);
        !           425:         DisplayData[(BottomLine+MAXLINES-1)%MAXLINES].yAngle = (LONG) sTmp;
        !           426: 
        !           427:         if (WinSendDlgItemMsg( hdlg, IDPITCH, BM_QUERYCHECK, 0L, 0L))
        !           428:             vfat.fsType = FATTR_TYPE_FIXED;
        !           429:         else
        !           430:             vfat.fsType = 0;
        !           431: 
        !           432:         WinQueryDlgItemShort(hdlg, IDCODEPAGE, &sTmp, TRUE);
        !           433:         vfat.usCodePage = sTmp;
        !           434: 
        !           435:         WinQueryDlgItemShort(hdlg, IDFONTDESIRED, &sTmp, TRUE);
        !           436:         FontDesired = sTmp;
        !           437: 
        !           438:         WinDismissDlg( hdlg, TRUE );
        !           439:         break;
        !           440: 
        !           441:     case DID_CANCEL:
        !           442:         WinDismissDlg( hdlg, TRUE );
        !           443:         break;
        !           444: 
        !           445:     default:
        !           446:         break;
        !           447:     }
        !           448: }
        !           449: 
        !           450: 
        !           451: /***************************** Public  Function ****************************\
        !           452: *
        !           453: * MRESULT EXPENTRY fnOptionsDlg( hdlg, message, mp1, mp2     )
        !           454: * HWND   hdlg;
        !           455: * USHORT message;
        !           456: * ULONG  mp1;
        !           457: * ULONG  mp2;
        !           458: *
        !           459: * Effects: None
        !           460: *
        !           461: * Warnings: None
        !           462: *
        !           463: \***************************************************************************/
        !           464: 
        !           465: MRESULT EXPENTRY fnOptionsDlg( hdlg, message, mp1, mp2 )
        !           466: HWND   hdlg;
        !           467: USHORT message;
        !           468: MPARAM mp1;
        !           469: MPARAM mp2;
        !           470: {
        !           471:     switch (message)
        !           472:     {
        !           473:     case WM_COMMAND:
        !           474:         DlgCommand( hdlg, mp1 );
        !           475:         break;
        !           476: 
        !           477:     case WM_INITDLG:
        !           478:         InitDlg( hdlg );
        !           479:         break;
        !           480: 
        !           481:     default:
        !           482:         return( WinDefDlgProc( hdlg, message, mp1, mp2     ) );
        !           483:     }
        !           484: 
        !           485:     return( 0L );
        !           486: }
        !           487: 
        !           488: 
        !           489: /***************************** Private Function ****************************\
        !           490: *
        !           491: * VOID PASCAL FonttestCommand( hwnd, id )
        !           492: * HWND   hwnd;
        !           493: * USHORT id;
        !           494: *
        !           495: * Effects: None
        !           496: *
        !           497: * Warnings: None
        !           498: *
        !           499: \***************************************************************************/
        !           500: 
        !           501: VOID PASCAL FonttestCommand( hwnd, id )
        !           502: HWND   hwnd;
        !           503: USHORT id;
        !           504: {
        !           505:     switch (id)
        !           506:     {
        !           507:     case IDM_SAMPLE:
        !           508:         /* Specify that the sample string should be displayed. */
        !           509:         WinSetWindowULong ( hwnd, QWL_USER, (ULONG) ID_SHOW);
        !           510:         WinInvalidateRect( hwnd, (PWRECT)NULL, TRUE );
        !           511:         WinUpdateWindow( hwnd );
        !           512:         break;
        !           513: 
        !           514:     case IDM_CLEAR:
        !           515:         /* Specify that the sample string should not be displayed. */
        !           516:         WinSetWindowULong ( hwnd, QWL_USER, (ULONG) ID_NOSHOW);
        !           517:         WinInvalidateRect( hwnd, (PWRECT)NULL, TRUE );
        !           518:         WinUpdateWindow( hwnd );
        !           519:         break;
        !           520: 
        !           521:     case IDM_OPTIONS:
        !           522:         WinDlgBox(HWND_DESKTOP, hwnd, fnOptionsDlg, NULL, IDD_OPTIONS, NULL);
        !           523:         break;
        !           524: 
        !           525:     case IDM_ABOUT:
        !           526:         WinDlgBox( HWND_DESKTOP, hwnd, fnAboutDlg, NULL, IDD_ABOUT, NULL );
        !           527:         break;
        !           528: 
        !           529:     default:
        !           530:         break;
        !           531:     }
        !           532: }
        !           533: 
        !           534: 
        !           535: /***************************** Public  Function ****************************\
        !           536: *
        !           537: * MRESULT EXPENTRY FonttestWndProc( hwnd, msg,  mp1, mp2     )
        !           538: * HWND   hwnd;
        !           539: * USHORT msg;
        !           540: * ULONG  mp1;
        !           541: * ULONG  mp2;
        !           542: *
        !           543: * Effects: None
        !           544: *
        !           545: * Warnings: None
        !           546: *
        !           547: \***************************************************************************/
        !           548: 
        !           549: MRESULT EXPENTRY FonttestWndProc( hwnd, msg, mp1, mp2 )
        !           550: HWND   hwnd;
        !           551: USHORT msg;
        !           552: MPARAM mp1;
        !           553: MPARAM mp2;
        !           554: {
        !           555:     HPS  hps;
        !           556:     RECTL rcl;
        !           557: 
        !           558:     switch (msg)
        !           559:     {
        !           560:     case WM_CREATE:
        !           561:         /* Specify that the sample string should be displayed. */
        !           562:         WinSetWindowULong ( hwnd, QWL_USER, (ULONG) ID_SHOW);
        !           563:         break;
        !           564: 
        !           565:     case WM_PAINT:
        !           566:         hps = WinBeginPaint( hwnd, NULL, &rcl );
        !           567:         if ( WinQueryWindowULong ( hwnd, QWL_USER ) & (ULONG) ID_REDRAW )
        !           568:           RedrawScreen ( hwnd, hps );
        !           569:         else 
        !           570:           if ( WinQueryWindowULong (hwnd, QWL_USER) & (ULONG) ID_SHOW )
        !           571:              ShowSampleString( hwnd, hps );
        !           572:           else
        !           573:            {
        !           574:              TopLine = BottomLine; 
        !           575:              WinFillRect (hps, &rcl, SYSCLR_WINDOW); 
        !           576:            }
        !           577:         WinEndPaint( hps );
        !           578:         break;
        !           579: 
        !           580:     case WM_CLOSE:
        !           581:         WinPostMsg( hwnd, WM_QUIT, 0L, 0L );;
        !           582:         break;
        !           583: 
        !           584:     case WM_COMMAND:
        !           585:         FonttestCommand( hwnd, SHORT1FROMMP(mp1) );
        !           586:         break;
        !           587: 
        !           588:     case WM_ERASEBACKGROUND:
        !           589:         WinSetWindowULong ( hwnd, QWL_USER, 
        !           590:                             WinQueryWindowULong( hwnd, QWL_USER ) | ID_REDRAW );
        !           591:         return (TRUE);    /* Let frame control erase background. */
        !           592:         break;
        !           593: 
        !           594:     default:
        !           595:         return (WinDefWindowProc( hwnd, msg, mp1, mp2 ) );
        !           596:         break;
        !           597:     }
        !           598:     return 0L;
        !           599: }

unix.superglobalmegacorp.com

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