1 | /*
|
---|
2 | * Native Font control
|
---|
3 | *
|
---|
4 | * Copyright 1998, 1999 Eric Kohl
|
---|
5 | *
|
---|
6 | * NOTES
|
---|
7 | * This is just a dummy control. An author is needed! Any volunteers?
|
---|
8 | * I will only improve this control once in a while.
|
---|
9 | * Eric <ekohl@abo.rhein-zeitung.de>
|
---|
10 | *
|
---|
11 | * TODO:
|
---|
12 | * - All messages.
|
---|
13 | * - All notifications.
|
---|
14 | */
|
---|
15 |
|
---|
16 | #include "winbase.h"
|
---|
17 | #include "commctrl.h"
|
---|
18 | #include "nativefont.h"
|
---|
19 |
|
---|
20 |
|
---|
21 |
|
---|
22 | #define NATIVEFONT_GetInfoPtr(hwnd) ((NATIVEFONT_INFO *)GetWindowLongA (hwnd, 0))
|
---|
23 |
|
---|
24 |
|
---|
25 |
|
---|
26 |
|
---|
27 | static LRESULT
|
---|
28 | NATIVEFONT_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
29 | {
|
---|
30 | NATIVEFONT_INFO *infoPtr;
|
---|
31 |
|
---|
32 | /* allocate memory for info structure */
|
---|
33 | infoPtr = (NATIVEFONT_INFO *)COMCTL32_Alloc (sizeof(NATIVEFONT_INFO));
|
---|
34 | SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
|
---|
35 |
|
---|
36 |
|
---|
37 | /* initialize info structure */
|
---|
38 |
|
---|
39 |
|
---|
40 | return 0;
|
---|
41 | }
|
---|
42 |
|
---|
43 |
|
---|
44 | static LRESULT
|
---|
45 | NATIVEFONT_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
46 | {
|
---|
47 | NATIVEFONT_INFO *infoPtr = NATIVEFONT_GetInfoPtr (hwnd);
|
---|
48 |
|
---|
49 |
|
---|
50 |
|
---|
51 |
|
---|
52 | /* free comboex info data */
|
---|
53 | COMCTL32_Free (infoPtr);
|
---|
54 |
|
---|
55 | return 0;
|
---|
56 | }
|
---|
57 |
|
---|
58 |
|
---|
59 |
|
---|
60 | LRESULT WINAPI
|
---|
61 | NATIVEFONT_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
---|
62 | {
|
---|
63 | switch (uMsg)
|
---|
64 | {
|
---|
65 |
|
---|
66 | case WM_CREATE:
|
---|
67 | return NATIVEFONT_Create (hwnd, wParam, lParam);
|
---|
68 |
|
---|
69 | case WM_DESTROY:
|
---|
70 | return NATIVEFONT_Destroy (hwnd, wParam, lParam);
|
---|
71 |
|
---|
72 | default:
|
---|
73 | // ERR (nativefont, "unknown msg %04x wp=%08x lp=%08lx\n",
|
---|
74 | // uMsg, wParam, lParam);
|
---|
75 | return DefWindowProcA (hwnd, uMsg, wParam, lParam);
|
---|
76 | }
|
---|
77 | return 0;
|
---|
78 | }
|
---|
79 |
|
---|
80 |
|
---|
81 | VOID
|
---|
82 | NATIVEFONT_Register (VOID)
|
---|
83 | {
|
---|
84 | WNDCLASSA wndClass;
|
---|
85 |
|
---|
86 | if (GlobalFindAtomA (WC_NATIVEFONTCTLA)) return;
|
---|
87 |
|
---|
88 | ZeroMemory (&wndClass, sizeof(WNDCLASSA));
|
---|
89 | wndClass.style = CS_GLOBALCLASS;
|
---|
90 | wndClass.lpfnWndProc = (WNDPROC)NATIVEFONT_WindowProc;
|
---|
91 | wndClass.cbClsExtra = 0;
|
---|
92 | wndClass.cbWndExtra = sizeof(NATIVEFONT_INFO *);
|
---|
93 | wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
|
---|
94 | wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
---|
95 | wndClass.lpszClassName = WC_NATIVEFONTCTLA;
|
---|
96 |
|
---|
97 | RegisterClassA (&wndClass);
|
---|
98 | }
|
---|
99 |
|
---|
100 |
|
---|
101 | VOID
|
---|
102 | NATIVEFONT_Unregister (VOID)
|
---|
103 | {
|
---|
104 | if (GlobalFindAtomA (WC_NATIVEFONTCTLA))
|
---|
105 | UnregisterClassA (WC_NATIVEFONTCTLA, (HINSTANCE)NULL);
|
---|
106 | }
|
---|
107 |
|
---|