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>
19 #include "debugtools.h"
21 DEFAULT_DEBUG_CHANNEL(hotkey
);
23 typedef struct tagHOTKEY_INFO
30 #define HOTKEY_GetInfoPtr(hwnd) ((HOTKEY_INFO *)GetWindowLongA (hwnd, 0))
33 /* << HOTHEY_GetHotKey >> */
34 /* << HOTHEY_SetHotKey >> */
35 /* << HOTHEY_SetRules >> */
39 /* << HOTKEY_Char >> */
43 HOTKEY_Create (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
49 /* allocate memory for info structure */
50 infoPtr
= (HOTKEY_INFO
*)COMCTL32_Alloc (sizeof(HOTKEY_INFO
));
51 SetWindowLongA (hwnd
, 0, (DWORD
)infoPtr
);
53 /* initialize info structure */
56 /* get default font height */
58 GetTextMetricsA (hdc
, &tm
);
59 infoPtr
->nHeight
= tm
.tmHeight
;
60 ReleaseDC (hwnd
, hdc
);
67 HOTKEY_Destroy (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
69 HOTKEY_INFO
*infoPtr
= HOTKEY_GetInfoPtr (hwnd
);
73 /* free hotkey info data */
74 COMCTL32_Free (infoPtr
);
75 SetWindowLongA (hwnd
, 0, 0);
81 HOTKEY_EraseBackground (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
83 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
88 (HBRUSH
)SendMessageA (GetParent (hwnd
), WM_CTLCOLOREDIT
,
89 wParam
, (LPARAM
)hwnd
);
91 hBrush
= (HBRUSH
)GetStockObject (WHITE_BRUSH
);
92 GetClientRect (hwnd
, &rc
);
94 FillRect ((HDC
)wParam
, &rc
, hBrush
);
100 inline static LRESULT
101 HOTKEY_GetFont (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
103 HOTKEY_INFO
*infoPtr
= HOTKEY_GetInfoPtr (hwnd
);
105 return infoPtr
->hFont
;
110 HOTKEY_KeyDown (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
112 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
121 return DefWindowProcA (hwnd
, WM_KEYDOWN
, wParam
, lParam
);
126 FIXME("modifier key pressed!\n");
130 FIXME(" %d\n", wParam
);
139 HOTKEY_KeyUp (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
141 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
143 FIXME(" %d\n", wParam
);
150 HOTKEY_KillFocus (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
152 HOTKEY_INFO
*infoPtr
= HOTKEY_GetInfoPtr (hwnd
);
154 infoPtr
->bFocus
= FALSE
;
162 HOTKEY_LButtonDown (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
164 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
172 inline static LRESULT
173 HOTKEY_NCCreate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
175 DWORD dwExStyle
= GetWindowLongA (hwnd
, GWL_EXSTYLE
);
176 SetWindowLongA (hwnd
, GWL_EXSTYLE
, dwExStyle
| WS_EX_CLIENTEDGE
);
177 return DefWindowProcA (hwnd
, WM_NCCREATE
, wParam
, lParam
);
185 HOTKEY_SetFocus (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
187 HOTKEY_INFO
*infoPtr
= HOTKEY_GetInfoPtr (hwnd
);
189 infoPtr
->bFocus
= TRUE
;
192 CreateCaret (hwnd
, (HBITMAP
)0, 1, infoPtr
->nHeight
);
203 inline static LRESULT
204 HOTKEY_SetFont (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
206 HOTKEY_INFO
*infoPtr
= HOTKEY_GetInfoPtr (hwnd
);
211 infoPtr
->hFont
= (HFONT
)wParam
;
215 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
217 GetTextMetricsA (hdc
, &tm
);
218 infoPtr
->nHeight
= tm
.tmHeight
;
221 SelectObject (hdc
, hOldFont
);
222 ReleaseDC (hwnd
, hdc
);
224 if (LOWORD(lParam
)) {
226 FIXME("force redraw!\n");
234 static LRESULT WINE_UNUSED
235 HOTKEY_SysKeyDown (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
237 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
246 return DefWindowProcA (hwnd
, WM_SYSKEYDOWN
, wParam
, lParam
);
251 FIXME("modifier key pressed!\n");
255 FIXME(" %d\n", wParam
);
263 static LRESULT WINE_UNUSED
264 HOTKEY_SysKeyUp (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
266 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
268 FIXME(" %d\n", wParam
);
275 static LRESULT WINAPI
276 HOTKEY_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
278 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd
, uMsg
, wParam
, lParam
);
279 if (!HOTKEY_GetInfoPtr (hwnd
) && (uMsg
!= WM_CREATE
))
280 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
283 /* case HKM_GETHOTKEY: */
284 /* case HKM_SETHOTKEY: */
285 /* case HKM_SETRULES: */
290 return HOTKEY_Create (hwnd
, wParam
, lParam
);
293 return HOTKEY_Destroy (hwnd
, wParam
, lParam
);
296 return HOTKEY_EraseBackground (hwnd
, wParam
, lParam
);
299 return DLGC_WANTCHARS
| DLGC_WANTARROWS
;
302 return HOTKEY_GetFont (hwnd
, wParam
, lParam
);
306 return HOTKEY_KeyDown (hwnd
, wParam
, lParam
);
310 return HOTKEY_KeyUp (hwnd
, wParam
, lParam
);
313 return HOTKEY_KillFocus (hwnd
, wParam
, lParam
);
316 return HOTKEY_LButtonDown (hwnd
, wParam
, lParam
);
319 return HOTKEY_NCCreate (hwnd
, wParam
, lParam
);
324 return HOTKEY_SetFocus (hwnd
, wParam
, lParam
);
327 return HOTKEY_SetFont (hwnd
, wParam
, lParam
);
329 /* case WM_SYSCHAR: */
333 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
334 uMsg
, wParam
, lParam
);
335 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
342 HOTKEY_Register (void)
346 ZeroMemory (&wndClass
, sizeof(WNDCLASSA
));
347 wndClass
.style
= CS_GLOBALCLASS
;
348 wndClass
.lpfnWndProc
= (WNDPROC
)HOTKEY_WindowProc
;
349 wndClass
.cbClsExtra
= 0;
350 wndClass
.cbWndExtra
= sizeof(HOTKEY_INFO
*);
351 wndClass
.hCursor
= 0;
352 wndClass
.hbrBackground
= 0;
353 wndClass
.lpszClassName
= HOTKEY_CLASSA
;
355 RegisterClassA (&wndClass
);
360 HOTKEY_Unregister (void)
362 UnregisterClassA (HOTKEY_CLASSA
, (HINSTANCE
)NULL
);