Annotation of pmsdk/samples/petzold/chap04/sysvals1.c, revision 1.1.1.2

1.1.1.2 ! root        1: /*---------------------------------------------------
        !             2:    SYSVALS1.C -- System Values Display Program No. 1
        !             3:   ---------------------------------------------------*/
        !             4: 
        !             5: #define INCL_WIN
        !             6: #define INCL_GPI
        !             7: #include <os2.h>
        !             8: #include <stdlib.h>
        !             9: #include <string.h>
        !            10: #include "sysvals.h"
        !            11: 
        !            12: MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
        !            13: 
        !            14: int main (void)
        !            15:      {
        !            16:      static CHAR  szClientClass [] = "SysVals1" ;
        !            17:      static ULONG flFrameFlags = FCF_TITLEBAR      | FCF_SYSMENU |
        !            18:                                  FCF_SIZEBORDER    | FCF_MINMAX  |
        !            19:                                  FCF_SHELLPOSITION | FCF_TASKLIST ;
        !            20:      HAB          hab ;
        !            21:      HMQ          hmq ;
        !            22:      HWND         hwndFrame, hwndClient ;
        !            23:      QMSG         qmsg ;
        !            24: 
        !            25:      hab = WinInitialize (0) ;
        !            26:      hmq = WinCreateMsgQueue (hab, 0) ;
        !            27: 
        !            28:      WinRegisterClass (hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0) ;
        !            29: 
        !            30:      hwndFrame = WinCreateStdWindow (HWND_DESKTOP, WS_VISIBLE,
        !            31:                                      &flFrameFlags, szClientClass, NULL,
        !            32:                                      0L, NULL, 0, &hwndClient) ;
        !            33: 
        !            34:      WinSendMsg (hwndFrame, WM_SETICON,
        !            35:                       WinQuerySysPointer (HWND_DESKTOP, SPTR_APPICON, FALSE),
        !            36:                       NULL) ;
        !            37: 
        !            38:      while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
        !            39:           WinDispatchMsg (hab, &qmsg) ;
        !            40: 
        !            41:      WinDestroyWindow (hwndFrame) ;
        !            42:      WinDestroyMsgQueue (hmq) ;
        !            43:      WinTerminate (hab) ;
        !            44:      return 0 ;
        !            45:      }
        !            46: 
        !            47: MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
        !            48:      {
        !            49:      static SHORT cxChar, cxCaps, cyChar, cyDesc, cxClient, cyClient ;
        !            50:      CHAR         szBuffer [10] ;
        !            51:      FONTMETRICS  fm ;
        !            52:      HPS          hps ;
        !            53:      POINTL       ptl ;
        !            54:      SHORT        sLine ;
        !            55: 
        !            56:      switch (msg)
        !            57:           {
        !            58:           case WM_CREATE:
        !            59:                hps = WinGetPS (hwnd) ;
        !            60:                GpiQueryFontMetrics (hps, (LONG) sizeof fm, &fm) ;
        !            61: 
        !            62:                cxChar = (SHORT) fm.lAveCharWidth ;
        !            63:                cxCaps = (SHORT) fm.lEmInc ;
        !            64:                cyChar = (SHORT) fm.lMaxBaselineExt ;
        !            65:                cyDesc = (SHORT) fm.lMaxDescender ;
        !            66: 
        !            67:                WinReleasePS (hps) ;
        !            68:                return 0 ;
        !            69: 
        !            70:           case WM_SIZE:
        !            71:                cxClient = SHORT1FROMMP (mp2) ;
        !            72:                cyClient = SHORT2FROMMP (mp2) ;
        !            73:                return 0 ;
        !            74: 
        !            75:           case WM_PAINT:
        !            76:                hps = WinBeginPaint (hwnd, NULL, NULL) ;
        !            77:                GpiErase (hps) ;
        !            78: 
        !            79:                for (sLine = 0 ; sLine < NUMLINES ; sLine++)
        !            80:                     {
        !            81:                     ptl.x = cxCaps ;
        !            82:                     ptl.y = cyClient - cyChar * (sLine + 1) + cyDesc ;
        !            83: 
        !            84:                     GpiCharStringAt (hps, &ptl,
        !            85:                               (LONG) strlen (sysvals[sLine].szIdentifier),
        !            86:                               sysvals[sLine].szIdentifier) ;
        !            87: 
        !            88:                     ptl.x += 20 * cxCaps ;
        !            89:                     GpiCharStringAt (hps, &ptl,
        !            90:                               (LONG) strlen (sysvals[sLine].szDescription),
        !            91:                               sysvals[sLine].szDescription) ;
        !            92: 
        !            93:                     ltoa (WinQuerySysValue (HWND_DESKTOP,
        !            94:                                sysvals[sLine].sIndex), szBuffer, 10) ;
        !            95: 
        !            96:                     ptl.x += 38 * cxChar ;
        !            97:                     GpiCharStringAt (hps, &ptl, (LONG) strlen (szBuffer),
        !            98:                                      szBuffer) ;
        !            99:                     }
        !           100:                WinEndPaint (hps) ;
        !           101:                return 0 ;
        !           102:           }
        !           103:      return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
        !           104:      }
        !           105: 
        !           106: 

unix.superglobalmegacorp.com

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