home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / BITCAT.ZIP / BITCAT2.C < prev    next >
C/C++ Source or Header  |  1990-11-26  |  4KB  |  146 lines

  1. #define INCL_WIN
  2. #define INCL_GPI
  3.  
  4. #include <os2.h>
  5.  
  6. #include <stdlib.h>
  7. #include "BitCat.h"
  8.  
  9.  
  10. MRESULT EXPENTRY ClientWndProc(HWND, USHORT, MPARAM, MPARAM);
  11.  
  12. HAB                     hab;
  13.  
  14.  
  15.  
  16.  
  17. int main(void)
  18.    {
  19.       static CHAR       szClientClass[] = "BitCat2";
  20.       static ULONG      flFrameFlags = FCF_TITLEBAR      | FCF_SYSMENU  |
  21.                                        FCF_SIZEBORDER    | FCF_MINMAX   |
  22.                                        FCF_SHELLPOSITION | FCF_TASKLIST;
  23.  
  24.  
  25.       HMQ               hmq;
  26.       HWND              hwndFrame,
  27.                         hwndClient;
  28.  
  29.       QMSG              qmsg;
  30.  
  31.  
  32.  
  33.       hab = WinInitialize(0);
  34.       hmq = WinCreateMsgQueue(hab, 0);
  35.  
  36.       WinRegisterClass(hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0);
  37.  
  38.       hwndFrame = WinCreateStdWindow(HWND_DESKTOP, WS_VISIBLE,
  39.                                      &flFrameFlags, szClientClass, NULL,
  40.                                      0L, NULL, 0, &hwndClient);
  41.  
  42.       while ( WinGetMsg(hab, &qmsg, NULL, 0, 0) )
  43.             WinDispatchMsg(hab, &qmsg);
  44.  
  45.       WinDestroyWindow(hwndFrame);
  46.       WinDestroyMsgQueue(hmq);
  47.       WinTerminate(hab);
  48.       return(0);
  49.    }
  50.  
  51.  
  52. MRESULT EXPENTRY ClientWndProc(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
  53.    {
  54.       static HBITMAP    hbm;
  55.       static HDC        hdcMemory;
  56.       static HPS        hpsMemory;
  57.       static SHORT      cxClient,
  58.                         cyClient;
  59.       BITMAPINFO        *pbmi;
  60.       BITMAPINFOHEADER  bmp;
  61.       HPS               hps;
  62.       POINTL            aptl[4];
  63.       SIZEL             sizl;
  64.  
  65.  
  66.  
  67.       switch(msg)
  68.          {
  69.             case WM_CREATE:
  70.                   hdcMemory = DevOpenDC(hab, OD_MEMORY, "*", 0L, NULL, NULL);
  71.  
  72.                   sizl.cx = 0;
  73.                   sizl.cy = 0;
  74.  
  75.                   hpsMemory = GpiCreatePS(hab, hdcMemory, &sizl,
  76.                                           PU_PELS     | GPIF_DEFAULT |
  77.                                           GPIT_MICRO  | GPIA_ASSOC);
  78.  
  79.                   bmp.cbFix      = sizeof(bmp);
  80.                   bmp.cx         = 32;
  81.                   bmp.cy         = 32;
  82.                   bmp.cPlanes    = 1;
  83.                   bmp.cBitCount  = 1;
  84.  
  85.                   hbm = GpiCreateBitmap(hpsMemory, &bmp, 0L, NULL, NULL);
  86.  
  87.                   GpiSetBitmap(hpsMemory, hbm);
  88.  
  89.                   pbmi = malloc(sizeof(BITMAPINFO) + sizeof(RGB));
  90.                   pbmi->cbFix       = sizeof(bmp);
  91.                   pbmi->cy          = 32;
  92.                   pbmi->cx          = 32;
  93.                   pbmi->cPlanes     = 1;
  94.                   pbmi->cBitCount   = 1;
  95.  
  96.                   pbmi->argbColor[0].bBlue   = 0;
  97.                   pbmi->argbColor[0].bGreen  = 0;
  98.                   pbmi->argbColor[0].bRed    = 0;
  99.                   pbmi->argbColor[1].bBlue   = 0xff;
  100.                   pbmi->argbColor[1].bGreen  = 0xff;
  101.                   pbmi->argbColor[1].bRed    = 0xff;
  102.  
  103.                   GpiSetBitmapBits(hpsMemory, 0L, 32L, abBitCat, pbmi);
  104.  
  105.                   free(pbmi);
  106.                   return(0);
  107.  
  108.             case WM_SIZE:
  109.                   cxClient = SHORT1FROMMP(mp2);
  110.                   cyClient = SHORT2FROMMP(mp2);
  111.                   return(0);
  112.  
  113.             case WM_PAINT:
  114.                   hps = WinBeginPaint(hwnd, NULL, NULL);
  115.  
  116.                   aptl[0].x = 0;
  117.                   aptl[0].y = 0;
  118.  
  119.                   aptl[1].x = cxClient;
  120.                   aptl[1].y = cyClient;
  121.  
  122.                   aptl[2].x = 0;
  123.                   aptl[2].y = 0;
  124.  
  125.                   aptl[3].x = 32;
  126.                   aptl[3].y = 32;
  127.  
  128.                   GpiBitBlt(hps, hpsMemory, 4L, aptl, ROP_SRCCOPY, BBO_AND);
  129.  
  130.                   aptl[1] = aptl[3];
  131.  
  132.                   GpiBitBlt(hps, hpsMemory, 3L, aptl, ROP_SRCCOPY, BBO_AND);
  133.  
  134.                   WinEndPaint(hps);
  135.                   return(0);
  136.  
  137.             case WM_DESTROY:
  138.                   GpiDestroyPS(hpsMemory);
  139.                   DevCloseDC(hdcMemory);
  140.                   GpiDeleteBitmap(hbm);
  141.                   return(0);
  142.          }
  143.       return(WinDefWindowProc(hwnd, msg, mp1, mp2));
  144.    }
  145.  
  146.