4 * Copyright 1998 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>
23 #define HOTKEY_GetInfoPtr(wndPtr) ((HOTKEY_INFO *)wndPtr->wExtra[0])
26 // << HOTHEY_GetHotKey >>
27 // << HOTHEY_SetHotKey >>
28 // << HOTHEY_SetRules >>
36 HOTKEY_Create (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
42 /* allocate memory for info structure */
43 infoPtr
= (HOTKEY_INFO
*)COMCTL32_Alloc (sizeof(HOTKEY_INFO
));
44 wndPtr
->wExtra
[0] = (DWORD
)infoPtr
;
46 if (infoPtr
== NULL
) {
47 ERR (listview
, "could not allocate info memory!\n");
51 if ((HOTKEY_INFO
*)wndPtr
->wExtra
[0] != infoPtr
) {
52 ERR (listview
, "pointer assignment error!\n");
57 /* initialize info structure */
59 /* get default font height */
60 hdc
= GetDC32 (wndPtr
->hwndSelf
);
61 GetTextMetrics32A (hdc
, &tm
);
62 infoPtr
->nHeight
= tm
.tmHeight
;
63 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
70 HOTKEY_Destroy (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
72 HOTKEY_INFO
*infoPtr
= HOTKEY_GetInfoPtr(wndPtr
);
76 /* free hotkey info data */
77 COMCTL32_Free (infoPtr
);
84 HOTKEY_EraseBackground (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
86 HOTKEY_INFO
*infoPtr
= HOTKEY_GetInfoPtr(wndPtr
);
91 (HBRUSH32
)SendMessage32A (wndPtr
->parent
->hwndSelf
, WM_CTLCOLOREDIT
,
92 wParam
, (LPARAM
)wndPtr
->hwndSelf
);
94 hBrush
= (HBRUSH32
)GetStockObject32 (WHITE_BRUSH
);
95 GetClientRect32 (wndPtr
->hwndSelf
, &rc
);
97 FillRect32 ((HDC32
)wParam
, &rc
, hBrush
);
103 __inline__
static LRESULT
104 HOTKEY_GetFont (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
106 HOTKEY_INFO
*infoPtr
= HOTKEY_GetInfoPtr(wndPtr
);
108 return infoPtr
->hFont
;
113 HOTKEY_KeyDown (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
115 HOTKEY_INFO
*infoPtr
= HOTKEY_GetInfoPtr(wndPtr
);
124 return DefWindowProc32A (wndPtr
->hwndSelf
, WM_KEYDOWN
, wParam
, lParam
);
129 FIXME (hotkey
, "modifier key pressed!\n");
133 FIXME (hotkey
, " %d\n", wParam
);
142 HOTKEY_KeyUp (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
144 HOTKEY_INFO
*infoPtr
= HOTKEY_GetInfoPtr(wndPtr
);
146 FIXME (hotkey
, " %d\n", wParam
);
153 HOTKEY_KillFocus (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
155 HOTKEY_INFO
*infoPtr
= HOTKEY_GetInfoPtr(wndPtr
);
157 infoPtr
->bFocus
= FALSE
;
165 HOTKEY_LButtonDown (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
167 // HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr(wndPtr);
169 SetFocus32 (wndPtr
->hwndSelf
);
175 __inline__
static LRESULT
176 HOTKEY_NCCreate (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
178 wndPtr
->dwExStyle
|= WS_EX_CLIENTEDGE
;
180 return DefWindowProc32A (wndPtr
->hwndSelf
, WM_NCCREATE
, wParam
, lParam
);
188 HOTKEY_SetFocus (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
190 HOTKEY_INFO
*infoPtr
= HOTKEY_GetInfoPtr(wndPtr
);
192 infoPtr
->bFocus
= TRUE
;
195 CreateCaret32 (wndPtr
->hwndSelf
, (HBITMAP32
)0, 1, infoPtr
->nHeight
);
197 SetCaretPos32 (1, 1);
199 ShowCaret32 (wndPtr
->hwndSelf
);
206 __inline__
static LRESULT
207 HOTKEY_SetFont (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
209 HOTKEY_INFO
*infoPtr
= HOTKEY_GetInfoPtr(wndPtr
);
212 HFONT32 hOldFont
= 0;
214 infoPtr
->hFont
= (HFONT32
)wParam
;
216 hdc
= GetDC32 (wndPtr
->hwndSelf
);
218 hOldFont
= SelectObject32 (hdc
, infoPtr
->hFont
);
220 GetTextMetrics32A (hdc
, &tm
);
221 infoPtr
->nHeight
= tm
.tmHeight
;
224 SelectObject32 (hdc
, hOldFont
);
225 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
227 if (LOWORD(lParam
)) {
229 FIXME (hotkey
, "force redraw!\n");
238 HOTKEY_SysKeyDown (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
240 HOTKEY_INFO
*infoPtr
= HOTKEY_GetInfoPtr(wndPtr
);
249 return DefWindowProc32A (wndPtr
->hwndSelf
, WM_SYSKEYDOWN
, wParam
, lParam
);
254 FIXME (hotkey
, "modifier key pressed!\n");
258 FIXME (hotkey
, " %d\n", wParam
);
267 HOTKEY_SysKeyUp (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
269 HOTKEY_INFO
*infoPtr
= HOTKEY_GetInfoPtr(wndPtr
);
271 FIXME (hotkey
, " %d\n", wParam
);
279 HOTKEY_WindowProc (HWND32 hwnd
, UINT32 uMsg
, WPARAM32 wParam
, LPARAM lParam
)
281 WND
*wndPtr
= WIN_FindWndPtr(hwnd
);
285 // case HKM_GETHOTKEY:
286 // case HKM_SETHOTKEY:
287 // case HKM_SETRULES:
292 return HOTKEY_Create (wndPtr
, wParam
, lParam
);
295 return HOTKEY_Destroy (wndPtr
, wParam
, lParam
);
298 return HOTKEY_EraseBackground (wndPtr
, wParam
, lParam
);
301 return DLGC_WANTCHARS
| DLGC_WANTARROWS
;
304 return HOTKEY_GetFont (wndPtr
, wParam
, lParam
);
308 return HOTKEY_KeyDown (wndPtr
, wParam
, lParam
);
312 return HOTKEY_KeyUp (wndPtr
, wParam
, lParam
);
315 return HOTKEY_KillFocus (wndPtr
, wParam
, lParam
);
318 return HOTKEY_LButtonDown (wndPtr
, wParam
, lParam
);
321 return HOTKEY_NCCreate (wndPtr
, wParam
, lParam
);
326 return HOTKEY_SetFocus (wndPtr
, wParam
, lParam
);
329 return HOTKEY_SetFont (wndPtr
, wParam
, lParam
);
335 ERR (hotkey
, "unknown msg %04x wp=%08x lp=%08lx\n",
336 uMsg
, wParam
, lParam
);
337 return DefWindowProc32A (hwnd
, uMsg
, wParam
, lParam
);
344 HOTKEY_Register (VOID
)
346 WNDCLASS32A wndClass
;
348 if (GlobalFindAtom32A (HOTKEY_CLASS32A
)) return;
350 ZeroMemory (&wndClass
, sizeof(WNDCLASS32A
));
351 wndClass
.style
= CS_GLOBALCLASS
;
352 wndClass
.lpfnWndProc
= (WNDPROC32
)HOTKEY_WindowProc
;
353 wndClass
.cbClsExtra
= 0;
354 wndClass
.cbWndExtra
= sizeof(HOTKEY_INFO
*);
355 wndClass
.hCursor
= 0;
356 wndClass
.hbrBackground
= 0;
357 wndClass
.lpszClassName
= HOTKEY_CLASS32A
;
359 RegisterClass32A (&wndClass
);
364 HOTKEY_Unregister (VOID
)
366 if (GlobalFindAtom32A (HOTKEY_CLASS32A
))
367 UnregisterClass32A (HOTKEY_CLASS32A
, (HINSTANCE32
)NULL
);