4 * Copyright 1998, 1999 Eric Kohl
7 * Development in progress. An author is needed! Any volunteers?
8 * I will only improve this control once in a while.
9 * Eric <ekohl@abo.rhein-zeitung.de>
18 #include "debugtools.h"
20 DEFAULT_DEBUG_CHANNEL(hotkey);
22 typedef struct tagHOTKEY_INFO
29 #define HOTKEY_GetInfoPtr(hwnd) ((HOTKEY_INFO *)GetWindowLongA (hwnd, 0))
32 /* << HOTHEY_GetHotKey >> */
33 /* << HOTHEY_SetHotKey >> */
34 /* << HOTHEY_SetRules >> */
38 /* << HOTKEY_Char >> */
42 HOTKEY_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
48 /* allocate memory for info structure */
49 infoPtr = (HOTKEY_INFO *)COMCTL32_Alloc (sizeof(HOTKEY_INFO));
50 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
52 /* initialize info structure */
55 /* get default font height */
57 GetTextMetricsA (hdc, &tm);
58 infoPtr->nHeight = tm.tmHeight;
59 ReleaseDC (hwnd, hdc);
66 HOTKEY_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
68 HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd);
72 /* free hotkey info data */
73 COMCTL32_Free (infoPtr);
74 SetWindowLongA (hwnd, 0, 0);
80 HOTKEY_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
82 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
87 (HBRUSH)SendMessageA (GetParent (hwnd), WM_CTLCOLOREDIT,
88 wParam, (LPARAM)hwnd);
90 hBrush = (HBRUSH)GetStockObject (WHITE_BRUSH);
91 GetClientRect (hwnd, &rc);
93 FillRect ((HDC)wParam, &rc, hBrush);
100 HOTKEY_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
102 HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd);
104 return infoPtr->hFont;
109 HOTKEY_KeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
111 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
120 return DefWindowProcA (hwnd, WM_KEYDOWN, wParam, lParam);
125 FIXME("modifier key pressed!\n");
129 FIXME(" %d\n", wParam);
138 HOTKEY_KeyUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
140 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
142 FIXME(" %d\n", wParam);
149 HOTKEY_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
151 HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd);
153 infoPtr->bFocus = FALSE;
161 HOTKEY_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
163 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
171 inline static LRESULT
172 HOTKEY_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
174 DWORD dwExStyle = GetWindowLongA (hwnd, GWL_EXSTYLE);
175 SetWindowLongA (hwnd, GWL_EXSTYLE, dwExStyle | WS_EX_CLIENTEDGE);
176 return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
184 HOTKEY_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
186 HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd);
188 infoPtr->bFocus = TRUE;
191 CreateCaret (hwnd, (HBITMAP)0, 1, infoPtr->nHeight);
202 inline static LRESULT
203 HOTKEY_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
205 HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd);
210 infoPtr->hFont = (HFONT)wParam;
214 hOldFont = SelectObject (hdc, infoPtr->hFont);
216 GetTextMetricsA (hdc, &tm);
217 infoPtr->nHeight = tm.tmHeight;
220 SelectObject (hdc, hOldFont);
221 ReleaseDC (hwnd, hdc);
223 if (LOWORD(lParam)) {
225 FIXME("force redraw!\n");
233 static LRESULT WINE_UNUSED
234 HOTKEY_SysKeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
236 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
245 return DefWindowProcA (hwnd, WM_SYSKEYDOWN, wParam, lParam);
250 FIXME("modifier key pressed!\n");
254 FIXME(" %d\n", wParam);
262 static LRESULT WINE_UNUSED
263 HOTKEY_SysKeyUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
265 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
267 FIXME(" %d\n", wParam);
274 static LRESULT WINAPI
275 HOTKEY_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
277 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam);
278 if (!HOTKEY_GetInfoPtr (hwnd) && (uMsg != WM_CREATE))
279 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
282 /* case HKM_GETHOTKEY: */
283 /* case HKM_SETHOTKEY: */
284 /* case HKM_SETRULES: */
289 return HOTKEY_Create (hwnd, wParam, lParam);
292 return HOTKEY_Destroy (hwnd, wParam, lParam);
295 return HOTKEY_EraseBackground (hwnd, wParam, lParam);
298 return DLGC_WANTCHARS | DLGC_WANTARROWS;
301 return HOTKEY_GetFont (hwnd, wParam, lParam);
305 return HOTKEY_KeyDown (hwnd, wParam, lParam);
309 return HOTKEY_KeyUp (hwnd, wParam, lParam);
312 return HOTKEY_KillFocus (hwnd, wParam, lParam);
315 return HOTKEY_LButtonDown (hwnd, wParam, lParam);
318 return HOTKEY_NCCreate (hwnd, wParam, lParam);
323 return HOTKEY_SetFocus (hwnd, wParam, lParam);
326 return HOTKEY_SetFont (hwnd, wParam, lParam);
328 /* case WM_SYSCHAR: */
332 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
333 uMsg, wParam, lParam);
334 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
341 HOTKEY_Register (void)
345 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
346 wndClass.style = CS_GLOBALCLASS;
347 wndClass.lpfnWndProc = (WNDPROC)HOTKEY_WindowProc;
348 wndClass.cbClsExtra = 0;
349 wndClass.cbWndExtra = sizeof(HOTKEY_INFO *);
350 wndClass.hCursor = 0;
351 wndClass.hbrBackground = 0;
352 wndClass.lpszClassName = HOTKEY_CLASSA;
354 RegisterClassA (&wndClass);
359 HOTKEY_Unregister (void)
361 UnregisterClassA (HOTKEY_CLASSA, (HINSTANCE)NULL);