|
|
1.1 ! root 1: /*------------------------------------------ ! 2: BITCAT1.C -- Bitmap Creation and Display ! 3: ------------------------------------------*/ ! 4: ! 5: #define INCL_WIN ! 6: #define INCL_GPI ! 7: #include <os2.h> ! 8: #include <stdlib.h> ! 9: #include "bitcat.h" ! 10: ! 11: MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ; ! 12: ! 13: int main (void) ! 14: { ! 15: static CHAR szClientClass [] = "BitCat1" ; ! 16: static ULONG flFrameFlags = FCF_TITLEBAR | FCF_SYSMENU | ! 17: FCF_SIZEBORDER | FCF_MINMAX | ! 18: FCF_SHELLPOSITION | FCF_TASKLIST ; ! 19: HAB hab ; ! 20: HMQ hmq ; ! 21: HWND hwndFrame, hwndClient ; ! 22: QMSG qmsg ; ! 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, WS_VISIBLE, ! 30: &flFrameFlags, szClientClass, NULL, ! 31: 0L, NULL, 0, &hwndClient) ; ! 32: ! 33: while (WinGetMsg (hab, &qmsg, NULL, 0, 0)) ! 34: WinDispatchMsg (hab, &qmsg) ; ! 35: ! 36: WinDestroyWindow (hwndFrame) ; ! 37: WinDestroyMsgQueue (hmq) ; ! 38: WinTerminate (hab) ; ! 39: return 0 ; ! 40: } ! 41: ! 42: MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2) ! 43: { ! 44: static HBITMAP hbm ; ! 45: BITMAPINFO *pbmi ; ! 46: BITMAPINFOHEADER bmp ; ! 47: HPS hps ; ! 48: RECTL rcl ; ! 49: ! 50: switch (msg) ! 51: { ! 52: case WM_CREATE: ! 53: ! 54: /*----------------------------------- ! 55: Create 32-by-32 monochrome bitmap ! 56: -----------------------------------*/ ! 57: ! 58: bmp.cbFix = sizeof bmp ; ! 59: bmp.cx = 32 ; ! 60: bmp.cy = 32 ; ! 61: bmp.cPlanes = 1 ; ! 62: bmp.cBitCount = 1 ; ! 63: ! 64: pbmi = malloc (sizeof (BITMAPINFO) + sizeof (RGB)) ; ! 65: ! 66: pbmi->cbFix = sizeof bmp ; ! 67: pbmi->cx = 32 ; ! 68: pbmi->cy = 32 ; ! 69: pbmi->cPlanes = 1 ; ! 70: pbmi->cBitCount = 1; ! 71: ! 72: pbmi->argbColor[0].bBlue = 0 ; ! 73: pbmi->argbColor[0].bGreen = 0 ; ! 74: pbmi->argbColor[0].bRed = 0 ; ! 75: pbmi->argbColor[1].bBlue = 0xFF ; ! 76: pbmi->argbColor[1].bGreen = 0xFF ; ! 77: pbmi->argbColor[1].bRed = 0xFF ; ! 78: ! 79: hps = WinGetPS (hwnd) ; ! 80: hbm = GpiCreateBitmap (hps, &bmp, CBM_INIT, abBitCat, pbmi) ; ! 81: ! 82: WinReleasePS (hps) ; ! 83: free (pbmi) ; ! 84: return 0 ; ! 85: ! 86: case WM_PAINT: ! 87: hps = WinBeginPaint (hwnd, NULL, NULL) ; ! 88: ! 89: WinQueryWindowRect (hwnd, &rcl) ; ! 90: ! 91: WinDrawBitmap (hps, hbm, NULL, (PPOINTL) &rcl, ! 92: CLR_NEUTRAL, CLR_BACKGROUND, DBM_STRETCH) ; ! 93: ! 94: WinDrawBitmap (hps, hbm, NULL, (PPOINTL) &rcl, ! 95: CLR_NEUTRAL, CLR_BACKGROUND, DBM_NORMAL) ; ! 96: ! 97: WinEndPaint (hps) ; ! 98: return 0 ; ! 99: ! 100: case WM_DESTROY: ! 101: GpiDeleteBitmap (hbm) ; ! 102: return 0 ; ! 103: } ! 104: return WinDefWindowProc (hwnd, msg, mp1, mp2) ; ! 105: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.