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