|
|
1.1 root 1: /*--------------------------------------------
2: BRICKS.C -- Customized Pattern from Bitmap
3: --------------------------------------------*/
4:
5: #define INCL_WIN
6: #define INCL_GPI
7: #include <os2.h>
8: #include <stdlib.h>
9:
10: #define LCID_BRICKS_BITMAP 1L
11:
12: MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
13:
14: int main (void)
15: {
16: static CHAR szClientClass [] = "Bricks" ;
17: static ULONG flFrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
18: FCF_SIZEBORDER | FCF_MINMAX |
19: FCF_SHELLPOSITION | FCF_TASKLIST ;
20: HAB hab ;
21: HMQ hmq ;
22: HWND hwndFrame, hwndClient ;
23: QMSG qmsg ;
24:
25: hab = WinInitialize (0) ;
26: hmq = WinCreateMsgQueue (hab, 0) ;
27:
28: WinRegisterClass (hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0) ;
29:
30: hwndFrame = WinCreateStdWindow (HWND_DESKTOP, WS_VISIBLE,
31: &flFrameFlags, szClientClass, NULL,
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: return 0 ;
41: }
42:
43: MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
44: {
45: static BYTE abBrick [] = {
46: 0x00, 0x00, 0x00, 0x00,
47: 0xF3, 0x00, 0x00, 0x00,
48: 0xF3, 0x00, 0x00, 0x00,
49: 0xF3, 0x00, 0x00, 0x00,
50: 0x00, 0x00, 0x00, 0x00,
51: 0x3F, 0x00, 0x00, 0x00,
52: 0x3F, 0x00, 0x00, 0x00,
53: 0x3F, 0x00, 0x00, 0x00
54: } ;
55: static HBITMAP hbm ;
56: static POINTL aptl [2] ;
57: BITMAPINFO *pbmi ;
58: BITMAPINFOHEADER bmp ;
59: HPS hps ;
60:
61: switch (msg)
62: {
63: case WM_CREATE:
64: /*----------------------
65: Create 8 by 8 bitmap
66: ----------------------*/
67:
68: bmp.cbFix = sizeof bmp ;
69: bmp.cx = 8 ;
70: bmp.cy = 8 ;
71: bmp.cPlanes = 1 ;
72: bmp.cBitCount = 1 ;
73:
74: pbmi = malloc (sizeof (BITMAPINFO) + sizeof (RGB)) ;
75:
76: pbmi->cbFix = sizeof bmp ;
77: pbmi->cx = 8 ;
78: pbmi->cy = 8 ;
79: pbmi->cPlanes = 1 ;
80: pbmi->cBitCount = 1 ;
81:
82: pbmi->argbColor[0].bBlue = 0 ;
83: pbmi->argbColor[0].bGreen = 0 ;
84: pbmi->argbColor[0].bRed = 0 ;
85: pbmi->argbColor[1].bBlue = 0xFF ;
86: pbmi->argbColor[1].bGreen = 0xFF ;
87: pbmi->argbColor[1].bRed = 0xFF ;
88:
89: hps = WinGetPS (hwnd) ;
90: hbm = GpiCreateBitmap (hps, &bmp, CBM_INIT, abBrick, pbmi) ;
91:
92: WinReleasePS (hps) ;
93: free (pbmi) ;
94: return 0 ;
95:
96: case WM_SIZE:
97: aptl[1].x = SHORT1FROMMP (mp2) ;
98: aptl[1].y = SHORT2FROMMP (mp2) ;
99: return 0 ;
100:
101: case WM_PAINT:
102: hps = WinBeginPaint (hwnd, NULL, NULL) ;
103:
104: GpiSetBitmapId (hps, hbm, LCID_BRICKS_BITMAP) ;
105: GpiSetPatternSet (hps, LCID_BRICKS_BITMAP) ;
106:
107: GpiBitBlt (hps, NULL, 2L, aptl, ROP_PATCOPY, BBO_AND) ;
108:
109: GpiSetPatternSet (hps, LCID_DEFAULT) ;
110: GpiDeleteSetId (hps, LCID_BRICKS_BITMAP) ;
111:
112: WinEndPaint (hps) ;
113: return 0 ;
114:
115: case WM_DESTROY:
116: GpiDeleteBitmap (hbm) ;
117: return 0 ;
118: }
119: return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
120: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.