|
|
1.1 root 1: /*-------------------------------------------------
2: RESOURCE.C -- Uses an Icon and Pointer Resource
3: -------------------------------------------------*/
4:
5: #define INCL_WIN
6: #define INCL_GPI
7:
8: #include <os2.h>
9: #include <stddef.h>
10: #include "resource.h"
11:
12: MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
13:
14: int main (void)
15: {
16: static CHAR szClientClass [] = "Resource" ;
17: HAB hab ;
18: HMQ hmq ;
19: HWND hwndFrame, hwndClient ;
20: QMSG qmsg ;
21: ULONG flFrameFlags = FCF_STANDARD & ~FCF_MENU ;
22: ULONG flFrameStyle = WS_VISIBLE | FS_ICON ;
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, flFrameStyle,
30: &flFrameFlags, szClientClass,
31: "Icon and Pointer Resources",
32: 0L, NULL, ID_RESOURCE, &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:
41: return 0 ;
42: }
43:
44: MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
45: {
46: static HPOINTER hIcon, hPtr ;
47: static SHORT cxClient, cyClient, xIcon, yIcon ;
48: HPS hps ;
49: RECTL rcl ;
50:
51: switch (msg)
52: {
53: case WM_CREATE:
54: hIcon = WinLoadPointer (HWND_DESKTOP, NULL, ID_RESOURCE) ;
55: hPtr = WinLoadPointer (HWND_DESKTOP, NULL, IDP_CIRCLE) ;
56:
57: xIcon = (SHORT) WinQuerySysValue (HWND_DESKTOP, SV_CXICON) ;
58: yIcon = (SHORT) WinQuerySysValue (HWND_DESKTOP, SV_CYICON) ;
59: return 0 ;
60:
61: case WM_SIZE:
62: cxClient = SHORT1FROMMP (mp2) ;
63: cyClient = SHORT2FROMMP (mp2) ;
64: return 0 ;
65:
66: case WM_MOUSEMOVE:
67: WinSetPointer (HWND_DESKTOP, hPtr) ;
68: return 1 ;
69:
70: case WM_PAINT:
71: hps = WinBeginPaint (hwnd, NULL, NULL) ;
72:
73: WinQueryWindowRect (hwnd, &rcl) ;
74: WinFillRect (hps, &rcl, CLR_CYAN) ;
75:
76: WinDrawPointer (hps, 0, 0, hIcon, DP_NORMAL) ;
77: WinDrawPointer (hps, 0, cyClient - yIcon, hIcon, DP_NORMAL) ;
78: WinDrawPointer (hps, cxClient - yIcon, 0, hIcon, DP_NORMAL) ;
79: WinDrawPointer (hps, cxClient - xIcon, cyClient - yIcon, hIcon,
80: DP_NORMAL) ;
81:
82: WinDrawPointer (hps, cxClient / 3, cyClient / 2, hIcon,
83: DP_HALFTONED) ;
84: WinDrawPointer (hps, 2 * cxClient / 3, cyClient / 2, hIcon,
85: DP_INVERTED) ;
86: WinEndPaint (hps) ;
87: return 0 ;
88:
89: case WM_DESTROY:
90: WinDestroyPointer (hIcon) ;
91: WinDestroyPointer (hPtr) ;
92: return 0 ;
93:
94: default:
95: return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
96: }
97: return 0 ;
98: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.