nativefont.c 2.31 KB
Newer Older
1 2 3
/*
 * Native Font control
 *
4
 * Copyright 1998, 1999 Eric Kohl
5 6 7 8 9 10 11 12 13 14 15
 *
 * NOTES
 *   This is just a dummy control. An author is needed! Any volunteers?
 *   I will only improve this control once in a while.
 *     Eric <ekohl@abo.rhein-zeitung.de>
 *
 * TODO:
 *   - All messages.
 *   - All notifications.
 */

16
#include <string.h>
17
#include "winbase.h"
18
#include "commctrl.h"
19
#include "debugtools.h"
20

21
DEFAULT_DEBUG_CHANNEL(nativefont);
22

23 24 25 26
typedef struct
{
    DWORD  dwDummy;   /* just to keep the compiler happy ;-) */
} NATIVEFONT_INFO;
27

28
#define NATIVEFONT_GetInfoPtr(hwnd) ((NATIVEFONT_INFO *)GetWindowLongA (hwnd, 0))
29 30 31


static LRESULT
32
NATIVEFONT_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
33 34 35 36 37
{
    NATIVEFONT_INFO *infoPtr;

    /* allocate memory for info structure */
    infoPtr = (NATIVEFONT_INFO *)COMCTL32_Alloc (sizeof(NATIVEFONT_INFO));
38
    SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
39 40 41 42 43 44 45 46 47 48


    /* initialize info structure */


    return 0;
}


static LRESULT
49
NATIVEFONT_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
50
{
51
    NATIVEFONT_INFO *infoPtr = NATIVEFONT_GetInfoPtr (hwnd);
52 53 54 55 56 57




    /* free comboex info data */
    COMCTL32_Free (infoPtr);
58
    SetWindowLongA( hwnd, 0, 0 );
59 60 61 62 63 64

    return 0;
}



65
static LRESULT WINAPI
66
NATIVEFONT_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
67
{
68 69 70
    if (!NATIVEFONT_GetInfoPtr(hwnd) && (uMsg != WM_CREATE))
	return DefWindowProcA( hwnd, uMsg, wParam, lParam );

71 72 73 74
    switch (uMsg)
    {

	case WM_CREATE:
75
	    return NATIVEFONT_Create (hwnd, wParam, lParam);
76 77

	case WM_DESTROY:
78
	    return NATIVEFONT_Destroy (hwnd, wParam, lParam);
79 80

	default:
81
	    ERR("unknown msg %04x wp=%08x lp=%08lx\n",
82
		     uMsg, wParam, lParam);
83
	    return DefWindowProcA (hwnd, uMsg, wParam, lParam);
84 85 86 87 88 89
    }
    return 0;
}


VOID
90
NATIVEFONT_Register (void)
91
{
92
    WNDCLASSA wndClass;
93

94
    ZeroMemory (&wndClass, sizeof(WNDCLASSA));
95
    wndClass.style         = CS_GLOBALCLASS;
96
    wndClass.lpfnWndProc   = (WNDPROC)NATIVEFONT_WindowProc;
97 98
    wndClass.cbClsExtra    = 0;
    wndClass.cbWndExtra    = sizeof(NATIVEFONT_INFO *);
99 100 101
    wndClass.hCursor       = LoadCursorA (0, IDC_ARROWA);
    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    wndClass.lpszClassName = WC_NATIVEFONTCTLA;
102
 
103
    RegisterClassA (&wndClass);
104 105 106 107
}


VOID
108
NATIVEFONT_Unregister (void)
109
{
110
    UnregisterClassA (WC_NATIVEFONTCTLA, (HINSTANCE)NULL);
111 112
}