1 /* Copyright 1998 DJ Delorie <dj@delorie.com>
2 Distributed under the terms of the GNU GPL
3 http://www.delorie.com/store/hcalc/
9 #define WIN32_LEAN_AND_MEAN
20 static char szAppName
[16];
21 static char szTitle
[80];
22 static HINSTANCE hInst
;
23 static HBITMAP face
, chars
, bits
;
25 static int r
=0, g
=0, b
=0;
28 static char shown_offsets
[15];
29 static int shown_bitmask
;
38 char charmap
[] = " 0123456789ABCDEF-x,.ro+";
42 paint_bits(HDC dc
, HDC bdc
)
45 SelectObject(bdc
, bits
);
48 int b
= (shown_bitmask
>> i
) & 1;
49 BitBlt(dc
, BITS_RIGHT
-2*i
-3*(i
/4), BITS_TOP
, 1, 7,
56 paint_chars(HDC dc
, HDC bdc
)
59 SelectObject(bdc
, chars
);
62 BitBlt(dc
, CHARS_LEFT
+6*i
, CHARS_TOP
, 5, 7,
63 bdc
, shown_offsets
[i
], 0, SRCCOPY
);
70 PAINTSTRUCT paintstruct
;
71 HDC dc
= BeginPaint(window
, &paintstruct
);
72 HDC bdc
= CreateCompatibleDC(dc
);
73 SelectObject(bdc
, face
);
74 BitBlt(dc
, 0, 0, WIDTH
, HEIGHT
, bdc
, 0, 0, SRCCOPY
);
82 EndPaint(window
, &paintstruct
);
94 InvalidateRect(window
, &r
, FALSE
);
110 sprintf(tmp
, "%15.15s", s
);
112 shown_offsets
[i
] = char_to_x
[tmp
[i
]];
118 static char tmp
[100];
119 static char ctmp
[20] = " ";
131 WndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
134 // int lw = LOWORD(wParam);
135 // int hw = HIWORD(wParam);
136 // HWND w = (HWND)lParam;
152 wsprintf(tmp
, "%3d %3d", LOWORD(lParam
), HIWORD(lParam
));
155 button(1, LOWORD(lParam
), HIWORD(lParam
));
164 button(2, LOWORD(lParam
), HIWORD(lParam
));
183 } /* switch message */
185 return DefWindowProc (hWnd
, message
, wParam
, lParam
);
192 InitApplication(HINSTANCE hInstance
, int nCmdShow
)
199 LoadString(hInstance
, IDS_APPNAME
, szAppName
, sizeof(szAppName
));
200 LoadString(hInstance
, IDS_DESCRIPTION
, szTitle
, sizeof(szTitle
));
204 wc
.style
= CS_HREDRAW
| CS_VREDRAW
;
205 wc
.lpfnWndProc
= (WNDPROC
)WndProc
;
208 wc
.hInstance
= hInstance
;
209 wc
.hIcon
= LoadIcon(NULL
, IDI_APPLICATION
);
210 wc
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
211 wc
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
212 wc
.lpszMenuName
= NULL
;
213 wc
.lpszClassName
= szAppName
;
215 if (RegisterClass(&wc
) == 0)
218 style
= WS_OVERLAPPED
|WS_CAPTION
|WS_SYSMENU
|WS_MINIMIZEBOX
;
222 size
.right
= WIDTH
-3;
223 size
.bottom
= HEIGHT
-3;
224 AdjustWindowRect(&size
, style
, 0);
226 hWnd
= CreateWindowEx(WS_EX_TOPMOST
,
231 size
.right
-size
.left
, size
.bottom
-size
.top
,
241 face
= LoadBitmap(hInstance
, MAKEINTRESOURCE(IDB_FACE
));
242 chars
= LoadBitmap(hInstance
, MAKEINTRESOURCE(IDB_CHARS
));
243 bits
= LoadBitmap(hInstance
, MAKEINTRESOURCE(IDB_BITS
));
245 for (i
=0; i
<256; i
++)
247 for (i
=0; charmap
[i
]; i
++)
248 char_to_x
[charmap
[i
]] = i
*6;
252 ShowWindow(hWnd
, nCmdShow
);
262 WinMain(HINSTANCE hInstance
,
263 HINSTANCE hPrevInstance
,
270 if (!InitApplication(hInstance
, nCmdShow
))
273 hAccelTable
= LoadAccelerators(hInstance
, szAppName
);
275 while( GetMessage(&msg
, NULL
, 0, 0))
276 if (!TranslateAccelerator (msg
.hwnd
, hAccelTable
, &msg
))
278 TranslateMessage(&msg
);
279 DispatchMessage(&msg
);