Annotation of pmsdk/samples/petzold/chap07/avio2.c, revision 1.1

1.1     ! root        1: /*-----------------------------------------
        !             2:    AVIO2.C -- Advanced VIO Display of Text
        !             3:   -----------------------------------------*/
        !             4: 
        !             5: #define INCL_WIN
        !             6: #define INCL_VIO
        !             7: #define INCL_AVIO
        !             8: #include <os2.h>
        !             9: 
        !            10: #define VIDEOWIDTH 40
        !            11: 
        !            12: typedef struct
        !            13:      {
        !            14:      CHAR ch ;
        !            15:      CHAR attr ;
        !            16:      }
        !            17:      VIDEO [][VIDEOWIDTH] ;
        !            18: 
        !            19: typedef VIDEO FAR *PVIDEO ;
        !            20: 
        !            21: MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
        !            22: 
        !            23: HAB  hab ;
        !            24: 
        !            25: int main (void)
        !            26:      {
        !            27:      static CHAR    szClientClass [] = "Avio2" ;
        !            28:      static ULONG   flFrameFlags = FCF_TITLEBAR      | FCF_SYSMENU |
        !            29:                                    FCF_SIZEBORDER    | FCF_MINMAX  |
        !            30:                                    FCF_SHELLPOSITION | FCF_TASKLIST ;
        !            31:      HMQ            hmq ;
        !            32:      HWND           hwndFrame, hwndClient ;
        !            33:      QMSG           qmsg ;
        !            34: 
        !            35:      hab = WinInitialize (0) ;
        !            36:      hmq = WinCreateMsgQueue (hab, 0) ;
        !            37: 
        !            38:      WinRegisterClass (hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0) ;
        !            39: 
        !            40:      hwndFrame = WinCreateStdWindow (HWND_DESKTOP, WS_VISIBLE,
        !            41:                                      &flFrameFlags, szClientClass, NULL,
        !            42:                                      0L, NULL, 0, &hwndClient) ;
        !            43: 
        !            44:      WinSendMsg (hwndFrame, WM_SETICON,
        !            45:                  WinQuerySysPointer (HWND_DESKTOP, SPTR_APPICON, FALSE),
        !            46:                  NULL) ;
        !            47: 
        !            48:      while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
        !            49:           WinDispatchMsg (hab, &qmsg) ;
        !            50: 
        !            51:      WinDestroyWindow (hwndFrame) ;
        !            52:      WinDestroyMsgQueue (hmq) ;
        !            53:      WinTerminate (hab) ;
        !            54:      return 0 ;
        !            55:      }
        !            56: 
        !            57: MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
        !            58:      {
        !            59:      static CHAR  *aszAlice [] = {
        !            60:                                  "Alice was beginning to get very tired of",
        !            61:                                  "sitting by her sister on the bank and of",
        !            62:                                  "having nothing to do: once or twice she",
        !            63:                                  "had peeped into the book her sister was",
        !            64:                                  "reading, but it had no pictures or",
        !            65:                                  "conversations in it, \"and what is the",
        !            66:                                  "use of a book,\" thought Alice, \"without",
        !            67:                                  "pictures or conversations?\""
        !            68:                                  } ;
        !            69:      static HPS    hps ;
        !            70:      static HVPS   hvps ;
        !            71:      static PVIDEO pvideo ;
        !            72:      static SHORT  sNumLines = sizeof aszAlice / sizeof aszAlice[0] ;
        !            73:      static USHORT usVideoLength ;
        !            74:      HDC           hdc ;
        !            75:      RECTL         rcl ;
        !            76:      SHORT         sRow, sCol ;
        !            77:      SIZEL         sizl ;
        !            78:      ULONG         ulVideoBuffer ;
        !            79: 
        !            80:      switch (msg)
        !            81:           {
        !            82:           case WM_CREATE:
        !            83:                hdc = WinOpenWindowDC (hwnd) ;
        !            84: 
        !            85:                sizl.cx = sizl.cy = 0 ;
        !            86:                hps = GpiCreatePS (hab, hdc, &sizl, PU_PELS    | GPIF_DEFAULT |
        !            87:                                                    GPIT_MICRO | GPIA_ASSOC) ;
        !            88: 
        !            89:                VioCreatePS (&hvps, sNumLines, VIDEOWIDTH, 0, 1, NULL) ;
        !            90:                VioAssociate (hdc, hvps) ;
        !            91: 
        !            92:                VioGetBuf (&ulVideoBuffer, &usVideoLength, hvps) ;
        !            93:                pvideo = (PVIDEO) ulVideoBuffer ;
        !            94: 
        !            95:                for (sRow = 0 ; sRow < sNumLines ; sRow++)
        !            96:                     for (sCol = 0 ; sCol < VIDEOWIDTH ; sCol++)
        !            97:                          (*pvideo) [sRow][sCol].attr = '\x1E' ;
        !            98: 
        !            99:                for (sRow = 0 ; sRow < sNumLines ; sRow++)
        !           100:                     for (sCol = 0 ; aszAlice [sRow][sCol] ; sCol++)
        !           101:                          (*pvideo) [sRow][sCol].ch = aszAlice [sRow][sCol] ;
        !           102: 
        !           103:                return 0 ;
        !           104: 
        !           105:           case WM_SIZE:
        !           106:                WinDefAVioWindowProc (hwnd, msg, mp1, mp2) ;
        !           107:                return 0 ;
        !           108: 
        !           109:           case WM_PAINT:
        !           110:                WinBeginPaint (hwnd, hps, NULL) ;
        !           111: 
        !           112:                WinQueryWindowRect (hwnd, &rcl) ;
        !           113:                WinFillRect (hps, &rcl, CLR_DARKBLUE) ;
        !           114: 
        !           115:                VioShowBuf (0, usVideoLength, hvps) ;
        !           116: 
        !           117:                WinEndPaint (hps) ;
        !           118:                return 0 ;
        !           119: 
        !           120:           case WM_DESTROY:
        !           121:                VioAssociate (NULL, hvps) ;
        !           122:                VioDestroyPS (hvps) ;
        !           123:                GpiDestroyPS (hps) ;
        !           124:                return 0 ;
        !           125:           }
        !           126:      return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
        !           127:      }

unix.superglobalmegacorp.com

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