Annotation of pmsdk/samples/petzold/chap05/imagecat.c, revision 1.1.1.1

1.1       root        1: /*----------------------------------------
                      2:    IMAGECAT.C -- Cat drawn using GpiImage
                      3:   ----------------------------------------*/
                      4: 
                      5: #define INCL_WIN
                      6: #define INCL_GPI
                      7: #include <os2.h>
                      8: #include <stdlib.h>
                      9: 
                     10: MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
                     11: 
                     12: int main (void)
                     13:      {
                     14:      static CHAR  szClientClass [] = "ImageCat" ;
                     15:      static ULONG flFrameFlags = FCF_TITLEBAR      | FCF_SYSMENU |
                     16:                                  FCF_SIZEBORDER    | FCF_MINMAX  |
                     17:                                  FCF_SHELLPOSITION | FCF_TASKLIST ;
                     18:      HAB          hab ;
                     19:      HMQ          hmq ;
                     20:      HWND         hwndFrame, hwndClient ;
                     21:      QMSG         qmsg ;
                     22: 
                     23:      hab = WinInitialize (0) ;
                     24:      hmq = WinCreateMsgQueue (hab, 0) ;
                     25: 
                     26:      WinRegisterClass (hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0) ;
                     27: 
                     28:      hwndFrame = WinCreateStdWindow (HWND_DESKTOP, WS_VISIBLE,
                     29:                                      &flFrameFlags, szClientClass, NULL,
                     30:                                      0L, NULL, 0, &hwndClient) ;
                     31: 
                     32:      while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
                     33:           WinDispatchMsg (hab, &qmsg) ;
                     34: 
                     35:      WinDestroyWindow (hwndFrame) ;
                     36:      WinDestroyMsgQueue (hmq) ;
                     37:      WinTerminate (hab) ;
                     38:      return 0 ;
                     39:      }
                     40: 
                     41: MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
                     42:      {
                     43:      static BYTE  abCat [] = { 
                     44:                              0x01, 0xF8, 0x1F, 0x80, 0x01, 0x04, 0x20, 0x80, 
                     45:                              0x00, 0x8F, 0xF1, 0x00, 0x00, 0x48, 0x12, 0x00, 
                     46:                              0x00, 0x28, 0x14, 0x00, 0x00, 0x1A, 0x58, 0x00, 
                     47:                              0x00, 0x08, 0x10, 0x00, 0x00, 0xFC, 0x3F, 0x00, 
                     48:                              0x00, 0x09, 0x90, 0x00, 0x00, 0xFC, 0x3F, 0x00, 
                     49:                              0x00, 0x08, 0x10, 0x00, 0x00, 0x07, 0xE0, 0x00, 
                     50:                              0x00, 0x08, 0x10, 0x00, 0x00, 0x08, 0x10, 0xC0, 
                     51:                              0x00, 0x08, 0x10, 0x20, 0x00, 0x10, 0x08, 0x10,
                     52:                              0x00, 0x10, 0x08, 0x08, 0x00, 0x10, 0x08, 0x04,
                     53:                              0x00, 0x20, 0x04, 0x04, 0x00, 0x20, 0x04, 0x04, 
                     54:                              0x00, 0x20, 0x04, 0x04, 0x00, 0x40, 0x02, 0x04, 
                     55:                              0x00, 0x40, 0x02, 0x04, 0x00, 0x40, 0x02, 0x04, 
                     56:                              0x00, 0xC0, 0x03, 0x04, 0x00, 0x9C, 0x39, 0x08, 
                     57:                              0x00, 0xA2, 0x45, 0x08, 0x00, 0xA2, 0x45, 0x10, 
                     58:                              0x00, 0xA2, 0x45, 0xE0, 0x00, 0xA2, 0x45, 0x00, 
                     59:                              0x00, 0xA2, 0x45, 0x00, 0x00, 0xFF, 0xFF, 0x00 } ;
                     60:      static SHORT cxClient, cyClient ;
                     61:      HPS          hps ;
                     62:      POINTL       ptl ;
                     63:      SIZEL        sizl ;
                     64: 
                     65:      switch (msg)
                     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:                GpiErase (hps) ;
                     75: 
                     76:                ptl.x = cxClient / 2 - 16 ;
                     77:                ptl.y = cyClient / 2 + 16 ;
                     78:                GpiMove (hps, &ptl) ;
                     79: 
                     80:                sizl.cx = 32 ;
                     81:                sizl.cy = 32 ;
                     82:                GpiImage (hps, 0L, &sizl, (LONG) sizeof abCat, abCat) ;
                     83: 
                     84:                WinEndPaint (hps) ;
                     85:                return 0 ;
                     86:           }
                     87:      return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
                     88:      }
                     89: 

unix.superglobalmegacorp.com

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