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