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>
21 DEFAULT_DEBUG_CHANNEL(hotkey)
24 #define HOTKEY_GetInfoPtr(hwnd) ((HOTKEY_INFO *)GetWindowLongA (hwnd, 0))
27 /* << HOTHEY_GetHotKey >> */
28 /* << HOTHEY_SetHotKey >> */
29 /* << HOTHEY_SetRules >> */
33 /* << HOTKEY_Char >> */
37 HOTKEY_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
43 /* allocate memory for info structure */
44 infoPtr = (HOTKEY_INFO *)COMCTL32_Alloc (sizeof(HOTKEY_INFO));
45 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
47 /* initialize info structure */
50 /* get default font height */
52 GetTextMetricsA (hdc, &tm);
53 infoPtr->nHeight = tm.tmHeight;
54 ReleaseDC (hwnd, hdc);
61 HOTKEY_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
63 HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd);
67 /* free hotkey info data */
68 COMCTL32_Free (infoPtr);
75 HOTKEY_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
77 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
82 (HBRUSH)SendMessageA (GetParent (hwnd), WM_CTLCOLOREDIT,
83 wParam, (LPARAM)hwnd);
85 hBrush = (HBRUSH)GetStockObject (WHITE_BRUSH);
86 GetClientRect (hwnd, &rc);
88 FillRect ((HDC)wParam, &rc, hBrush);
94 __inline__ static LRESULT
95 HOTKEY_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
97 HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd);
99 return infoPtr->hFont;
104 HOTKEY_KeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
106 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
115 return DefWindowProcA (hwnd, WM_KEYDOWN, wParam, lParam);
120 FIXME (hotkey, "modifier key pressed!\n");
124 FIXME (hotkey, " %d\n", wParam);
133 HOTKEY_KeyUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
135 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
137 FIXME (hotkey, " %d\n", wParam);
144 HOTKEY_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
146 HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd);
148 infoPtr->bFocus = FALSE;
156 HOTKEY_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
158 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
166 __inline__ static LRESULT
167 HOTKEY_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
169 DWORD dwExStyle = GetWindowLongA (hwnd, GWL_EXSTYLE);
170 SetWindowLongA (hwnd, GWL_EXSTYLE, dwExStyle | WS_EX_CLIENTEDGE);
171 return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
179 HOTKEY_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
181 HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd);
183 infoPtr->bFocus = TRUE;
186 CreateCaret (hwnd, (HBITMAP)0, 1, infoPtr->nHeight);
197 __inline__ static LRESULT
198 HOTKEY_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
200 HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd);
205 infoPtr->hFont = (HFONT)wParam;
209 hOldFont = SelectObject (hdc, infoPtr->hFont);
211 GetTextMetricsA (hdc, &tm);
212 infoPtr->nHeight = tm.tmHeight;
215 SelectObject (hdc, hOldFont);
216 ReleaseDC (hwnd, hdc);
218 if (LOWORD(lParam)) {
220 FIXME (hotkey, "force redraw!\n");
228 static LRESULT WINE_UNUSED
229 HOTKEY_SysKeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
231 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
240 return DefWindowProcA (hwnd, WM_SYSKEYDOWN, wParam, lParam);
245 FIXME (hotkey, "modifier key pressed!\n");
249 FIXME (hotkey, " %d\n", wParam);
257 static LRESULT WINE_UNUSED
258 HOTKEY_SysKeyUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
260 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
262 FIXME (hotkey, " %d\n", wParam);
270 HOTKEY_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
274 /* case HKM_GETHOTKEY: */
275 /* case HKM_SETHOTKEY: */
276 /* case HKM_SETRULES: */
281 return HOTKEY_Create (hwnd, wParam, lParam);
284 return HOTKEY_Destroy (hwnd, wParam, lParam);
287 return HOTKEY_EraseBackground (hwnd, wParam, lParam);
290 return DLGC_WANTCHARS | DLGC_WANTARROWS;
293 return HOTKEY_GetFont (hwnd, wParam, lParam);
297 return HOTKEY_KeyDown (hwnd, wParam, lParam);
301 return HOTKEY_KeyUp (hwnd, wParam, lParam);
304 return HOTKEY_KillFocus (hwnd, wParam, lParam);
307 return HOTKEY_LButtonDown (hwnd, wParam, lParam);
310 return HOTKEY_NCCreate (hwnd, wParam, lParam);
315 return HOTKEY_SetFocus (hwnd, wParam, lParam);
318 return HOTKEY_SetFont (hwnd, wParam, lParam);
320 /* case WM_SYSCHAR: */
324 ERR (hotkey, "unknown msg %04x wp=%08x lp=%08lx\n",
325 uMsg, wParam, lParam);
326 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
333 HOTKEY_Register (VOID)
337 if (GlobalFindAtomA (HOTKEY_CLASSA)) return;
339 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
340 wndClass.style = CS_GLOBALCLASS;
341 wndClass.lpfnWndProc = (WNDPROC)HOTKEY_WindowProc;
342 wndClass.cbClsExtra = 0;
343 wndClass.cbWndExtra = sizeof(HOTKEY_INFO *);
344 wndClass.hCursor = 0;
345 wndClass.hbrBackground = 0;
346 wndClass.lpszClassName = HOTKEY_CLASSA;
348 RegisterClassA (&wndClass);
353 HOTKEY_Unregister (VOID)
355 if (GlobalFindAtomA (HOTKEY_CLASSA))
356 UnregisterClassA (HOTKEY_CLASSA, (HINSTANCE)NULL);