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

1.1       root        1: /*---------------------------------------------------
                      2:    SYSVALS1.C -- System Values Display Program No. 1
                      3:   ---------------------------------------------------*/
                      4: 
                      5: #define INCL_WIN
                      6: #define INCL_GPI
                      7: 
                      8: #include <os2.h>
                      9: #include <stdio.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:      HAB         hab ;
                     18:      HMQ         hmq ;
                     19:      HWND        hwndClient, hwndFrame ;
                     20:      QMSG        qmsg ;
                     21:      ULONG       flFrameFlags = FCF_STANDARD & ~FCF_MENU ;
                     22:      ULONG       flFrameStyle = WS_VISIBLE ;
                     23: 
                     24:      hab = WinInitialize (0) ;
                     25:      hmq = WinCreateMsgQueue (hab, 0) ;
                     26: 
                     27:      WinRegisterClass (hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0) ;
                     28: 
                     29:      hwndFrame = WinCreateStdWindow (HWND_DESKTOP, flFrameStyle,
                     30:                                      &flFrameFlags, szClientClass,
                     31:                                      "Presentation Manager System Values",
                     32:                                      0L, NULL, 0, &hwndClient) ;
                     33: 
                     34:      while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
                     35:           WinDispatchMsg (hab, &qmsg) ;
                     36: 
                     37:      WinDestroyWindow (hwndFrame) ;
                     38:      WinDestroyMsgQueue (hmq) ;
                     39:      WinTerminate (hab) ;
                     40: 
                     41:      return 0 ;
                     42:      }
                     43: 
                     44: MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
                     45:      {
                     46:      static SHORT cxChar, cyChar, cyDesc, cxClient, cyClient ;
                     47:      CHAR         szBuffer [80] ;
                     48:      FONTMETRICS  fm ;
                     49:      HPS          hps ;
                     50:      POINTL       ptl ;
                     51:      SHORT        sLine ;
                     52: 
                     53:      switch (msg)
                     54:           {
                     55:           case WM_CREATE:
                     56:                hps = WinGetPS (hwnd) ;
                     57:      
                     58:                GpiQueryFontMetrics (hps, (LONG) sizeof fm, &fm) ;
                     59: 
                     60:                cxChar = (SHORT) fm.lAveCharWidth ;
                     61:                cyChar = (SHORT) fm.lMaxBaselineExt ;
                     62:                cyDesc = (SHORT) fm.lMaxDescender ;
                     63: 
                     64:                WinReleasePS (hps) ;
                     65:                return 0 ;
                     66: 
                     67:           case WM_SIZE:
                     68:                cxClient = SHORT1FROMMP (mp2) ;
                     69:                cyClient = SHORT2FROMMP (mp2) ;
                     70:                return 0 ;
                     71: 
                     72:           case WM_PAINT:
                     73:                hps = WinBeginPaint (hwnd, NULL, NULL) ;
                     74: 
                     75:                GpiErase (hps) ;
                     76: 
                     77:                for (sLine = 0 ; sLine < NUMLINES ; sLine++)
                     78:                     {
                     79:                     ptl.x = cxChar ;
                     80:                     ptl.y = cyClient - cyChar * (sLine + 1) + cyDesc ;
                     81: 
                     82:                     GpiCharStringAt (hps, &ptl,
                     83:                          (LONG) sprintf (szBuffer, "%-20s%-34s%6ld",
                     84:                                    sysvals[sLine].szIdentifier,
                     85:                                    sysvals[sLine].szDescription,
                     86:                               WinQuerySysValue (HWND_DESKTOP,
                     87:                                                 sysvals[sLine].sIndex)),
                     88:                          szBuffer) ;
                     89:                     }
                     90:                WinEndPaint (hps) ;
                     91:                return 0 ;
                     92:           }
                     93:      return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
                     94:      }

unix.superglobalmegacorp.com

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