4 * Copyright 1998, 1999 Eric Kohl
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * Development in progress. An author is needed! Any volunteers?
22 * I will only improve this control once in a while.
23 * Eric <ekohl@abo.rhein-zeitung.de>
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(hotkey
);
37 typedef struct tagHOTKEY_INFO
44 #define HOTKEY_GetInfoPtr(hwnd) ((HOTKEY_INFO *)GetWindowLongA (hwnd, 0))
47 /* << HOTHEY_GetHotKey >> */
48 /* << HOTHEY_SetHotKey >> */
49 /* << HOTHEY_SetRules >> */
53 /* << HOTKEY_Char >> */
57 HOTKEY_Create (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
63 /* allocate memory for info structure */
64 infoPtr
= (HOTKEY_INFO
*)COMCTL32_Alloc (sizeof(HOTKEY_INFO
));
65 SetWindowLongA (hwnd
, 0, (DWORD
)infoPtr
);
67 /* initialize info structure */
70 /* get default font height */
72 GetTextMetricsA (hdc
, &tm
);
73 infoPtr
->nHeight
= tm
.tmHeight
;
74 ReleaseDC (hwnd
, hdc
);
81 HOTKEY_Destroy (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
83 HOTKEY_INFO
*infoPtr
= HOTKEY_GetInfoPtr (hwnd
);
87 /* free hotkey info data */
88 COMCTL32_Free (infoPtr
);
89 SetWindowLongA (hwnd
, 0, 0);
95 HOTKEY_EraseBackground (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
97 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
102 (HBRUSH
)SendMessageA (GetParent (hwnd
), WM_CTLCOLOREDIT
,
103 wParam
, (LPARAM
)hwnd
);
105 hBrush
= (HBRUSH
)GetStockObject (WHITE_BRUSH
);
106 GetClientRect (hwnd
, &rc
);
108 FillRect ((HDC
)wParam
, &rc
, hBrush
);
114 inline static LRESULT
115 HOTKEY_GetFont (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
117 HOTKEY_INFO
*infoPtr
= HOTKEY_GetInfoPtr (hwnd
);
119 return infoPtr
->hFont
;
124 HOTKEY_KeyDown (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
126 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
135 return DefWindowProcA (hwnd
, WM_KEYDOWN
, wParam
, lParam
);
140 FIXME("modifier key pressed!\n");
144 FIXME(" %d\n", wParam
);
153 HOTKEY_KeyUp (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
155 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
157 FIXME(" %d\n", wParam
);
164 HOTKEY_KillFocus (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
166 HOTKEY_INFO
*infoPtr
= HOTKEY_GetInfoPtr (hwnd
);
168 infoPtr
->bFocus
= FALSE
;
176 HOTKEY_LButtonDown (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
178 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
186 inline static LRESULT
187 HOTKEY_NCCreate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
189 DWORD dwExStyle
= GetWindowLongA (hwnd
, GWL_EXSTYLE
);
190 SetWindowLongA (hwnd
, GWL_EXSTYLE
, dwExStyle
| WS_EX_CLIENTEDGE
);
191 return DefWindowProcA (hwnd
, WM_NCCREATE
, wParam
, lParam
);
199 HOTKEY_SetFocus (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
201 HOTKEY_INFO
*infoPtr
= HOTKEY_GetInfoPtr (hwnd
);
203 infoPtr
->bFocus
= TRUE
;
206 CreateCaret (hwnd
, (HBITMAP
)0, 1, infoPtr
->nHeight
);
217 inline static LRESULT
218 HOTKEY_SetFont (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
220 HOTKEY_INFO
*infoPtr
= HOTKEY_GetInfoPtr (hwnd
);
225 infoPtr
->hFont
= (HFONT
)wParam
;
229 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
231 GetTextMetricsA (hdc
, &tm
);
232 infoPtr
->nHeight
= tm
.tmHeight
;
235 SelectObject (hdc
, hOldFont
);
236 ReleaseDC (hwnd
, hdc
);
238 if (LOWORD(lParam
)) {
240 FIXME("force redraw!\n");
248 static LRESULT WINE_UNUSED
249 HOTKEY_SysKeyDown (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
251 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
260 return DefWindowProcA (hwnd
, WM_SYSKEYDOWN
, wParam
, lParam
);
265 FIXME("modifier key pressed!\n");
269 FIXME(" %d\n", wParam
);
277 static LRESULT WINE_UNUSED
278 HOTKEY_SysKeyUp (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
280 /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
282 FIXME(" %d\n", wParam
);
289 static LRESULT WINAPI
290 HOTKEY_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
292 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd
, uMsg
, wParam
, lParam
);
293 if (!HOTKEY_GetInfoPtr (hwnd
) && (uMsg
!= WM_CREATE
))
294 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
297 /* case HKM_GETHOTKEY: */
298 /* case HKM_SETHOTKEY: */
299 /* case HKM_SETRULES: */
304 return HOTKEY_Create (hwnd
, wParam
, lParam
);
307 return HOTKEY_Destroy (hwnd
, wParam
, lParam
);
310 return HOTKEY_EraseBackground (hwnd
, wParam
, lParam
);
313 return DLGC_WANTCHARS
| DLGC_WANTARROWS
;
316 return HOTKEY_GetFont (hwnd
, wParam
, lParam
);
320 return HOTKEY_KeyDown (hwnd
, wParam
, lParam
);
324 return HOTKEY_KeyUp (hwnd
, wParam
, lParam
);
327 return HOTKEY_KillFocus (hwnd
, wParam
, lParam
);
330 return HOTKEY_LButtonDown (hwnd
, wParam
, lParam
);
333 return HOTKEY_NCCreate (hwnd
, wParam
, lParam
);
338 return HOTKEY_SetFocus (hwnd
, wParam
, lParam
);
341 return HOTKEY_SetFont (hwnd
, wParam
, lParam
);
343 /* case WM_SYSCHAR: */
346 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
))
347 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
348 uMsg
, wParam
, lParam
);
349 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
356 HOTKEY_Register (void)
360 ZeroMemory (&wndClass
, sizeof(WNDCLASSA
));
361 wndClass
.style
= CS_GLOBALCLASS
;
362 wndClass
.lpfnWndProc
= (WNDPROC
)HOTKEY_WindowProc
;
363 wndClass
.cbClsExtra
= 0;
364 wndClass
.cbWndExtra
= sizeof(HOTKEY_INFO
*);
365 wndClass
.hCursor
= 0;
366 wndClass
.hbrBackground
= 0;
367 wndClass
.lpszClassName
= HOTKEY_CLASSA
;
369 RegisterClassA (&wndClass
);
374 HOTKEY_Unregister (void)
376 UnregisterClassA (HOTKEY_CLASSA
, (HINSTANCE
)NULL
);