ReactOS  0.4.12-dev-90-g2e2e63e
hotkey.c File Reference
#include <stdarg.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
#include "commctrl.h"
#include "comctl32.h"
#include "wine/debug.h"
#include "wine/heap.h"
Include dependency graph for hotkey.c:

Go to the source code of this file.

Classes

struct  tagHOTKEY_INFO
 

Macros

#define IsOnlySet(flags)   (infoPtr->CurrMod == (flags))
 

Typedefs

typedef struct tagHOTKEY_INFO HOTKEY_INFO
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (hotkey)
 
static LRESULT HOTKEY_SetFont (HOTKEY_INFO *infoPtr, HFONT hFont, BOOL redraw)
 
static BOOL HOTKEY_IsCombInv (const HOTKEY_INFO *infoPtr)
 
static void HOTKEY_DrawHotKey (HOTKEY_INFO *infoPtr, HDC hdc, LPCWSTR KeyName, WORD NameLen)
 
static void HOTKEY_Refresh (HOTKEY_INFO *infoPtr, HDC hdc)
 
static void HOTKEY_Paint (HOTKEY_INFO *infoPtr, HDC hdc)
 
static LRESULT HOTKEY_GetHotKey (const HOTKEY_INFO *infoPtr)
 
static void HOTKEY_SetHotKey (HOTKEY_INFO *infoPtr, WORD hotKey)
 
static void HOTKEY_SetRules (HOTKEY_INFO *infoPtr, WORD invComb, WORD invMod)
 
static LRESULT HOTKEY_Create (HOTKEY_INFO *infoPtr, const CREATESTRUCTW *lpcs)
 
static LRESULT HOTKEY_Destroy (HOTKEY_INFO *infoPtr)
 
static LRESULT HOTKEY_EraseBackground (const HOTKEY_INFO *infoPtr, HDC hdc)
 
static LRESULT HOTKEY_GetFont (const HOTKEY_INFO *infoPtr)
 
static LRESULT HOTKEY_KeyDown (HOTKEY_INFO *infoPtr, DWORD key, DWORD flags)
 
static LRESULT HOTKEY_KeyUp (HOTKEY_INFO *infoPtr, DWORD key)
 
static LRESULT HOTKEY_KillFocus (HOTKEY_INFO *infoPtr)
 
static LRESULT HOTKEY_LButtonDown (const HOTKEY_INFO *infoPtr)
 
static LRESULT HOTKEY_NCCreate (HWND hwnd, const CREATESTRUCTW *lpcs)
 
static LRESULT HOTKEY_SetFocus (HOTKEY_INFO *infoPtr)
 
static LRESULT WINAPI HOTKEY_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
void HOTKEY_Register (void)
 
void HOTKEY_Unregister (void)
 

Variables

static const WCHAR HOTKEY_plussep [] = { ' ', '+', ' ' }
 

Macro Definition Documentation

◆ IsOnlySet

#define IsOnlySet (   flags)    (infoPtr->CurrMod == (flags))

Definition at line 64 of file hotkey.c.

Referenced by HOTKEY_IsCombInv().

Typedef Documentation

◆ HOTKEY_INFO

Function Documentation

◆ HOTKEY_Create()

static LRESULT HOTKEY_Create ( HOTKEY_INFO infoPtr,
const CREATESTRUCTW lpcs 
)
static

Definition at line 230 of file hotkey.c.

Referenced by HOTKEY_WindowProc().

231 {
232  infoPtr->hwndNotify = lpcs->hwndParent;
233 
235 
236  return 0;
237 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
HWND hwndNotify
Definition: hotkey.c:48
static LRESULT HOTKEY_SetFont(HOTKEY_INFO *infoPtr, HFONT hFont, BOOL redraw)
Definition: hotkey.c:440
#define SYSTEM_FONT
Definition: wingdi.h:909

◆ HOTKEY_Destroy()

static LRESULT HOTKEY_Destroy ( HOTKEY_INFO infoPtr)
static

Definition at line 241 of file hotkey.c.

Referenced by HOTKEY_WindowProc().

242 {
243  /* free hotkey info data */
244  SetWindowLongPtrW (infoPtr->hwndSelf, 0, 0);
245  heap_free (infoPtr);
246  return 0;
247 }
HWND hwndSelf
Definition: hotkey.c:47
#define SetWindowLongPtrW
Definition: winuser.h:5215
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ HOTKEY_DrawHotKey()

static void HOTKEY_DrawHotKey ( HOTKEY_INFO infoPtr,
HDC  hdc,
LPCWSTR  KeyName,
WORD  NameLen 
)
static

Definition at line 96 of file hotkey.c.

Referenced by HOTKEY_Refresh().

97 {
98  SIZE TextSize;
99  INT nXStart, nYStart;
100  COLORREF clrOldText, clrOldBk;
101  HFONT hFontOld;
102 
103  /* Make a gap from the frame */
104  nXStart = GetSystemMetrics(SM_CXBORDER);
105  nYStart = GetSystemMetrics(SM_CYBORDER);
106 
107  hFontOld = SelectObject(hdc, infoPtr->hFont);
108  if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & WS_DISABLED)
109  {
112  }
113  else
114  {
116  clrOldBk = SetBkColor(hdc, comctl32_color.clrWindow);
117  }
118 
119  TextOutW(hdc, nXStart, nYStart, KeyName, NameLen);
120 
121  /* Get the text width for the caret */
122  GetTextExtentPoint32W(hdc, KeyName, NameLen, &TextSize);
123  infoPtr->CaretPos = nXStart + TextSize.cx;
124 
125  SetBkColor(hdc, clrOldBk);
126  SetTextColor(hdc, clrOldText);
127  SelectObject(hdc, hFontOld);
128 
129  /* position the caret */
130  SetCaretPos(infoPtr->CaretPos, nYStart);
131 }
#define WS_DISABLED
Definition: pedump.c:621
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4693
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
int32_t INT
Definition: typedefs.h:56
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:975
COLORREF clrWindowText
Definition: comctl32.h:168
HDC hdc
Definition: msvc.h:53
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
LONG cx
Definition: windef.h:324
int WINAPI GetSystemMetrics(_In_ int)
COMCTL32_SysColor comctl32_color
Definition: commctrl.c:82
#define SM_CYBORDER
Definition: winuser.h:955
#define SM_CXBORDER
Definition: winuser.h:954
BOOL WINAPI TextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCWSTR lpString, _In_ int c)
#define GWL_STYLE
Definition: winuser.h:846
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:784
COLORREF clrGrayText
Definition: comctl32.h:169
COLORREF clrBtnFace
Definition: comctl32.h:159
INT CaretPos
Definition: hotkey.c:56
HWND hwndSelf
Definition: hotkey.c:47
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
COLORREF clrWindow
Definition: comctl32.h:167
DWORD COLORREF
Definition: windef.h:290
BOOL WINAPI SetCaretPos(_In_ int, _In_ int)
BOOL WINAPI GetTextExtentPoint32W(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE psizl)
HFONT hFont
Definition: hotkey.c:49

◆ HOTKEY_EraseBackground()

static LRESULT HOTKEY_EraseBackground ( const HOTKEY_INFO infoPtr,
HDC  hdc 
)
static

Definition at line 251 of file hotkey.c.

Referenced by HOTKEY_WindowProc().

252 {
253  HBRUSH hBrush, hSolidBrush = NULL;
254  RECT rc;
255 
256  if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & WS_DISABLED)
257  hBrush = hSolidBrush = CreateSolidBrush(comctl32_color.clrBtnFace);
258  else
259  {
260  hBrush = (HBRUSH)SendMessageW(infoPtr->hwndNotify, WM_CTLCOLOREDIT,
261  (WPARAM)hdc, (LPARAM)infoPtr->hwndSelf);
262  if (!hBrush)
263  hBrush = hSolidBrush = CreateSolidBrush(comctl32_color.clrWindow);
264  }
265 
266  GetClientRect (infoPtr->hwndSelf, &rc);
267 
268  FillRect (hdc, &rc, hBrush);
269 
270  if (hSolidBrush)
271  DeleteObject(hSolidBrush);
272 
273  return -1;
274 }
#define WS_DISABLED
Definition: pedump.c:621
HWND hwndNotify
Definition: hotkey.c:48
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
UINT_PTR WPARAM
Definition: windef.h:207
HDC hdc
Definition: msvc.h:53
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
COMCTL32_SysColor comctl32_color
Definition: commctrl.c:82
#define GWL_STYLE
Definition: winuser.h:846
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
COLORREF clrBtnFace
Definition: comctl32.h:159
#define WM_CTLCOLOREDIT
Definition: winuser.h:1743
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
HWND hwndSelf
Definition: hotkey.c:47
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
COLORREF clrWindow
Definition: comctl32.h:167
#define LPARAM
Definition: msvc.h:38

◆ HOTKEY_GetFont()

static LRESULT HOTKEY_GetFont ( const HOTKEY_INFO infoPtr)
inlinestatic

Definition at line 278 of file hotkey.c.

Referenced by HOTKEY_WindowProc().

279 {
280  return (LRESULT)infoPtr->hFont;
281 }
LONG_PTR LRESULT
Definition: windef.h:209
HFONT hFont
Definition: hotkey.c:49

◆ HOTKEY_GetHotKey()

static LRESULT HOTKEY_GetHotKey ( const HOTKEY_INFO infoPtr)
static

Definition at line 201 of file hotkey.c.

Referenced by HOTKEY_WindowProc().

202 {
203  TRACE("(infoPtr=%p) Modifiers: 0x%x, Virtual Key: %d\n", infoPtr,
204  HIBYTE(infoPtr->HotKey), LOBYTE(infoPtr->HotKey));
205  return (LRESULT)infoPtr->HotKey;
206 }
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HIBYTE(W)
Definition: jmemdos.c:486
WORD HotKey
Definition: hotkey.c:52
#define TRACE(s)
Definition: solgame.cpp:4
LONG_PTR LRESULT
Definition: windef.h:209

◆ HOTKEY_IsCombInv()

static BOOL HOTKEY_IsCombInv ( const HOTKEY_INFO infoPtr)
static

Definition at line 67 of file hotkey.c.

Referenced by HOTKEY_KeyDown(), and HOTKEY_Refresh().

68 {
69  TRACE("(infoPtr=%p)\n", infoPtr);
70  if((infoPtr->InvComb & HKCOMB_NONE) && !infoPtr->CurrMod)
71  return TRUE;
72  if((infoPtr->InvComb & HKCOMB_S) && IsOnlySet(HOTKEYF_SHIFT))
73  return TRUE;
74  if((infoPtr->InvComb & HKCOMB_C) && IsOnlySet(HOTKEYF_CONTROL))
75  return TRUE;
76  if((infoPtr->InvComb & HKCOMB_A) && IsOnlySet(HOTKEYF_ALT))
77  return TRUE;
78  if((infoPtr->InvComb & HKCOMB_SC) &&
80  return TRUE;
81  if((infoPtr->InvComb & HKCOMB_SA) && IsOnlySet(HOTKEYF_SHIFT | HOTKEYF_ALT))
82  return TRUE;
83  if((infoPtr->InvComb & HKCOMB_CA) &&
85  return TRUE;
86  if((infoPtr->InvComb & HKCOMB_SCA) &&
88  return TRUE;
89 
90  TRACE("() Modifiers are valid\n");
91  return FALSE;
92 }
#define HKCOMB_SC
Definition: commctrl.h:2196
#define TRUE
Definition: types.h:120
#define HOTKEYF_SHIFT
Definition: commctrl.h:2188
#define HKCOMB_CA
Definition: commctrl.h:2198
#define HKCOMB_SCA
Definition: commctrl.h:2199
#define TRACE(s)
Definition: solgame.cpp:4
WORD InvComb
Definition: hotkey.c:53
#define HOTKEYF_CONTROL
Definition: commctrl.h:2189
#define IsOnlySet(flags)
Definition: hotkey.c:64
BYTE CurrMod
Definition: hotkey.c:55
#define HKCOMB_S
Definition: commctrl.h:2193
#define HKCOMB_SA
Definition: commctrl.h:2197
#define HKCOMB_A
Definition: commctrl.h:2195
#define HKCOMB_C
Definition: commctrl.h:2194
#define HKCOMB_NONE
Definition: commctrl.h:2192
#define HOTKEYF_ALT
Definition: commctrl.h:2190

◆ HOTKEY_KeyDown()

static LRESULT HOTKEY_KeyDown ( HOTKEY_INFO infoPtr,
DWORD  key,
DWORD  flags 
)
static

Definition at line 284 of file hotkey.c.

Referenced by HOTKEY_WindowProc().

285 {
286  WORD wOldHotKey;
287  BYTE bOldMod;
288 
289  if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & WS_DISABLED)
290  return 0;
291 
292  TRACE("() Key: %d\n", key);
293 
294  wOldHotKey = infoPtr->HotKey;
295  bOldMod = infoPtr->CurrMod;
296 
297  /* If any key is Pressed, we have to reset the hotkey in the control */
298  infoPtr->HotKey = 0;
299 
300  switch (key)
301  {
302  case VK_RETURN:
303  case VK_TAB:
304  case VK_SPACE:
305  case VK_DELETE:
306  case VK_ESCAPE:
307  case VK_BACK:
308  InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
309  return DefWindowProcW (infoPtr->hwndSelf, WM_KEYDOWN, key, flags);
310 
311  case VK_SHIFT:
312  infoPtr->CurrMod |= HOTKEYF_SHIFT;
313  break;
314  case VK_CONTROL:
315  infoPtr->CurrMod |= HOTKEYF_CONTROL;
316  break;
317  case VK_MENU:
318  infoPtr->CurrMod |= HOTKEYF_ALT;
319  break;
320 
321  default:
322  if(HOTKEY_IsCombInv(infoPtr))
323  infoPtr->HotKey = MAKEWORD(key, infoPtr->InvMod);
324  else
325  infoPtr->HotKey = MAKEWORD(key, infoPtr->CurrMod);
326  infoPtr->ScanCode = flags;
327  break;
328  }
329 
330  if ((wOldHotKey != infoPtr->HotKey) || (bOldMod != infoPtr->CurrMod))
331  {
332  InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
333 
334  /* send EN_CHANGE notification */
337  (LPARAM)infoPtr->hwndSelf);
338  }
339 
340  return 0;
341 }
#define WS_DISABLED
Definition: pedump.c:621
HWND hwndNotify
Definition: hotkey.c:48
#define TRUE
Definition: types.h:120
#define MAKEWPARAM(l, h)
Definition: winuser.h:3916
#define MAKEWORD(a, b)
Definition: typedefs.h:247
DWORD ScanCode
Definition: hotkey.c:57
#define HOTKEYF_SHIFT
Definition: commctrl.h:2188
#define VK_TAB
Definition: winuser.h:2153
#define VK_MENU
Definition: winuser.h:2158
#define VK_ESCAPE
Definition: winuser.h:2168
static BOOL HOTKEY_IsCombInv(const HOTKEY_INFO *infoPtr)
Definition: hotkey.c:67
#define VK_RETURN
Definition: winuser.h:2155
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
int WINAPI GetDlgCtrlID(_In_ HWND)
WORD HotKey
Definition: hotkey.c:52
LONG_PTR LPARAM
Definition: windef.h:208
#define VK_SHIFT
Definition: winuser.h:2156
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
#define WM_KEYDOWN
Definition: winuser.h:1691
#define VK_DELETE
Definition: winuser.h:2187
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define HOTKEYF_CONTROL
Definition: commctrl.h:2189
unsigned short WORD
Definition: ntddk_ex.h:93
GLbitfield flags
Definition: glext.h:7161
WORD InvMod
Definition: hotkey.c:54
BYTE CurrMod
Definition: hotkey.c:55
unsigned char BYTE
Definition: mem.h:68
#define WM_COMMAND
Definition: winuser.h:1716
#define VK_BACK
Definition: winuser.h:2152
#define GWL_STYLE
Definition: winuser.h:846
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define VK_SPACE
Definition: winuser.h:2173
#define VK_CONTROL
Definition: winuser.h:2157
HWND hwndSelf
Definition: hotkey.c:47
#define HOTKEYF_ALT
Definition: commctrl.h:2190
Definition: path.c:42
#define EN_CHANGE
Definition: winuser.h:1983

◆ HOTKEY_KeyUp()

static LRESULT HOTKEY_KeyUp ( HOTKEY_INFO infoPtr,
DWORD  key 
)
static

Definition at line 345 of file hotkey.c.

Referenced by HOTKEY_WindowProc().

346 {
347  BYTE bOldMod;
348 
349  if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & WS_DISABLED)
350  return 0;
351 
352  TRACE("() Key: %d\n", key);
353 
354  bOldMod = infoPtr->CurrMod;
355 
356  switch (key)
357  {
358  case VK_SHIFT:
359  infoPtr->CurrMod &= ~HOTKEYF_SHIFT;
360  break;
361  case VK_CONTROL:
362  infoPtr->CurrMod &= ~HOTKEYF_CONTROL;
363  break;
364  case VK_MENU:
365  infoPtr->CurrMod &= ~HOTKEYF_ALT;
366  break;
367  default:
368  return 1;
369  }
370 
371  if (bOldMod != infoPtr->CurrMod)
372  {
373  InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
374 
375  /* send EN_CHANGE notification */
378  (LPARAM)infoPtr->hwndSelf);
379  }
380 
381  return 0;
382 }
#define WS_DISABLED
Definition: pedump.c:621
HWND hwndNotify
Definition: hotkey.c:48
#define TRUE
Definition: types.h:120
#define MAKEWPARAM(l, h)
Definition: winuser.h:3916
#define HOTKEYF_SHIFT
Definition: commctrl.h:2188
#define VK_MENU
Definition: winuser.h:2158
int WINAPI GetDlgCtrlID(_In_ HWND)
LONG_PTR LPARAM
Definition: windef.h:208
#define VK_SHIFT
Definition: winuser.h:2156
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define HOTKEYF_CONTROL
Definition: commctrl.h:2189
BYTE CurrMod
Definition: hotkey.c:55
unsigned char BYTE
Definition: mem.h:68
#define WM_COMMAND
Definition: winuser.h:1716
#define GWL_STYLE
Definition: winuser.h:846
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define VK_CONTROL
Definition: winuser.h:2157
HWND hwndSelf
Definition: hotkey.c:47
#define HOTKEYF_ALT
Definition: commctrl.h:2190
Definition: path.c:42
#define EN_CHANGE
Definition: winuser.h:1983

◆ HOTKEY_KillFocus()

static LRESULT HOTKEY_KillFocus ( HOTKEY_INFO infoPtr)
static

Definition at line 386 of file hotkey.c.

Referenced by HOTKEY_WindowProc().

387 {
388  infoPtr->bFocus = FALSE;
389  DestroyCaret ();
390 
391  return 0;
392 }
BOOL bFocus
Definition: hotkey.c:50
BOOL WINAPI DestroyCaret(void)
Definition: caret.c:35

◆ HOTKEY_LButtonDown()

static LRESULT HOTKEY_LButtonDown ( const HOTKEY_INFO infoPtr)
static

Definition at line 396 of file hotkey.c.

Referenced by HOTKEY_WindowProc().

397 {
398  if (!(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & WS_DISABLED))
399  SetFocus (infoPtr->hwndSelf);
400 
401  return 0;
402 }
#define WS_DISABLED
Definition: pedump.c:621
HWND WINAPI SetFocus(_In_opt_ HWND)
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define GWL_STYLE
Definition: winuser.h:846
HWND hwndSelf
Definition: hotkey.c:47

◆ HOTKEY_NCCreate()

static LRESULT HOTKEY_NCCreate ( HWND  hwnd,
const CREATESTRUCTW lpcs 
)
inlinestatic

Definition at line 406 of file hotkey.c.

Referenced by HOTKEY_WindowProc().

407 {
408  HOTKEY_INFO *infoPtr;
409  DWORD dwExStyle = GetWindowLongW (hwnd, GWL_EXSTYLE);
410  SetWindowLongW (hwnd, GWL_EXSTYLE,
411  dwExStyle | WS_EX_CLIENTEDGE);
412 
413  /* allocate memory for info structure */
414  infoPtr = heap_alloc_zero (sizeof(*infoPtr));
415  SetWindowLongPtrW(hwnd, 0, (DWORD_PTR)infoPtr);
416 
417  /* initialize info structure */
418  infoPtr->HotKey = infoPtr->InvComb = infoPtr->InvMod = infoPtr->CurrMod = 0;
420  infoPtr->hwndSelf = hwnd;
422 
423  return DefWindowProcW (infoPtr->hwndSelf, WM_NCCREATE, 0, (LPARAM)lpcs);
424 }
#define HKY_NONE
Definition: comctl32.h:95
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define GWL_EXSTYLE
Definition: winuser.h:845
#define WM_NCCREATE
Definition: winuser.h:1665
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
WORD HotKey
Definition: hotkey.c:52
LONG_PTR LPARAM
Definition: windef.h:208
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
WORD InvComb
Definition: hotkey.c:53
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
WORD InvMod
Definition: hotkey.c:54
#define SM_CXBORDER
Definition: winuser.h:954
BYTE CurrMod
Definition: hotkey.c:55
uint32_t DWORD_PTR
Definition: typedefs.h:63
INT CaretPos
Definition: hotkey.c:56
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
HMODULE COMCTL32_hModule
Definition: commctrl.c:79
HWND hwndSelf
Definition: hotkey.c:47
WCHAR strNone[15]
Definition: hotkey.c:58
#define SetWindowLongPtrW
Definition: winuser.h:5215

◆ HOTKEY_Paint()

static void HOTKEY_Paint ( HOTKEY_INFO infoPtr,
HDC  hdc 
)
static

Definition at line 188 of file hotkey.c.

Referenced by HOTKEY_WindowProc().

189 {
190  if (hdc)
191  HOTKEY_Refresh(infoPtr, hdc);
192  else {
193  PAINTSTRUCT ps;
194  hdc = BeginPaint (infoPtr->hwndSelf, &ps);
195  HOTKEY_Refresh (infoPtr, hdc);
196  EndPaint (infoPtr->hwndSelf, &ps);
197  }
198 }
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
HDC hdc
Definition: msvc.h:53
static void HOTKEY_Refresh(HOTKEY_INFO *infoPtr, HDC hdc)
Definition: hotkey.c:135
HWND hwndSelf
Definition: hotkey.c:47

◆ HOTKEY_Refresh()

static void HOTKEY_Refresh ( HOTKEY_INFO infoPtr,
HDC  hdc 
)
static

Definition at line 135 of file hotkey.c.

Referenced by HOTKEY_Paint().

136 {
137  WCHAR KeyName[64];
138  WORD NameLen = 0;
139  BYTE Modifier;
140 
141  TRACE("(infoPtr=%p hdc=%p)\n", infoPtr, hdc);
142 
143  if(!infoPtr->CurrMod && !infoPtr->HotKey) {
144  HOTKEY_DrawHotKey (infoPtr, hdc, infoPtr->strNone, lstrlenW(infoPtr->strNone));
145  return;
146  }
147 
148  if(infoPtr->HotKey)
149  Modifier = HIBYTE(infoPtr->HotKey);
150  else if(HOTKEY_IsCombInv(infoPtr))
151  Modifier = infoPtr->InvMod;
152  else
153  Modifier = infoPtr->CurrMod;
154 
155  if(Modifier & HOTKEYF_CONTROL) {
157  KeyName, 64);
158  NameLen = lstrlenW(KeyName);
159  memcpy(&KeyName[NameLen], HOTKEY_plussep, sizeof(HOTKEY_plussep));
160  NameLen += 3;
161  }
162  if(Modifier & HOTKEYF_SHIFT) {
164  &KeyName[NameLen], 64 - NameLen);
165  NameLen = lstrlenW(KeyName);
166  memcpy(&KeyName[NameLen], HOTKEY_plussep, sizeof(HOTKEY_plussep));
167  NameLen += 3;
168  }
169  if(Modifier & HOTKEYF_ALT) {
171  &KeyName[NameLen], 64 - NameLen);
172  NameLen = lstrlenW(KeyName);
173  memcpy(&KeyName[NameLen], HOTKEY_plussep, sizeof(HOTKEY_plussep));
174  NameLen += 3;
175  }
176 
177  if(infoPtr->HotKey) {
178  GetKeyNameTextW(infoPtr->ScanCode, &KeyName[NameLen], 64 - NameLen);
179  NameLen = lstrlenW(KeyName);
180  }
181  else
182  KeyName[NameLen] = 0;
183 
184  HOTKEY_DrawHotKey (infoPtr, hdc, KeyName, NameLen);
185 }
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4693
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD ScanCode
Definition: hotkey.c:57
#define MAKELPARAM(l, h)
Definition: winuser.h:3915
#define HIBYTE(W)
Definition: jmemdos.c:486
#define HOTKEYF_SHIFT
Definition: commctrl.h:2188
#define VK_MENU
Definition: winuser.h:2158
static BOOL HOTKEY_IsCombInv(const HOTKEY_INFO *infoPtr)
Definition: hotkey.c:67
#define lstrlenW
Definition: compat.h:407
WORD HotKey
Definition: hotkey.c:52
#define VK_SHIFT
Definition: winuser.h:2156
HDC hdc
Definition: msvc.h:53
UINT WINAPI MapVirtualKeyW(_In_ UINT, _In_ UINT)
#define TRACE(s)
Definition: solgame.cpp:4
#define HOTKEYF_CONTROL
Definition: commctrl.h:2189
unsigned short WORD
Definition: ntddk_ex.h:93
WORD InvMod
Definition: hotkey.c:54
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
BYTE CurrMod
Definition: hotkey.c:55
unsigned char BYTE
Definition: mem.h:68
int WINAPI GetKeyNameTextW(_In_ LONG lParam, _Out_writes_(cchSize) LPWSTR lpString, _In_ int cchSize)
static void HOTKEY_DrawHotKey(HOTKEY_INFO *infoPtr, HDC hdc, LPCWSTR KeyName, WORD NameLen)
Definition: hotkey.c:96
#define VK_CONTROL
Definition: winuser.h:2157
WCHAR strNone[15]
Definition: hotkey.c:58
static const WCHAR HOTKEY_plussep[]
Definition: hotkey.c:61
#define HOTKEYF_ALT
Definition: commctrl.h:2190

◆ HOTKEY_Register()

void HOTKEY_Register ( void  )

Definition at line 541 of file hotkey.c.

Referenced by DllMain().

542 {
543  WNDCLASSW wndClass;
544 
545  ZeroMemory (&wndClass, sizeof(WNDCLASSW));
546  wndClass.style = CS_GLOBALCLASS;
547  wndClass.lpfnWndProc = HOTKEY_WindowProc;
548  wndClass.cbClsExtra = 0;
549  wndClass.cbWndExtra = sizeof(HOTKEY_INFO *);
550  wndClass.hCursor = 0;
551  wndClass.hbrBackground = 0;
552  wndClass.lpszClassName = HOTKEY_CLASSW;
553 
554  RegisterClassW (&wndClass);
555 }
static LRESULT WINAPI HOTKEY_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: hotkey.c:466
UINT style
Definition: winuser.h:3129
#define ZeroMemory
Definition: winbase.h:1635
int cbClsExtra
Definition: winuser.h:3131
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
WNDPROC lpfnWndProc
Definition: winuser.h:3130
LPCWSTR lpszClassName
Definition: winuser.h:3138
int cbWndExtra
Definition: winuser.h:3132
#define CS_GLOBALCLASS
Definition: winuser.h:647
HCURSOR hCursor
Definition: winuser.h:3135
HBRUSH hbrBackground
Definition: winuser.h:3136
#define HOTKEY_CLASSW
Definition: commctrl.h:2206

◆ HOTKEY_SetFocus()

static LRESULT HOTKEY_SetFocus ( HOTKEY_INFO infoPtr)
static

Definition at line 427 of file hotkey.c.

Referenced by HOTKEY_WindowProc().

428 {
429  infoPtr->bFocus = TRUE;
430 
431  CreateCaret (infoPtr->hwndSelf, NULL, 1, infoPtr->nHeight);
433  ShowCaret (infoPtr->hwndSelf);
434 
435  return 0;
436 }
#define TRUE
Definition: types.h:120
BOOL WINAPI CreateCaret(_In_ HWND, _In_opt_ HBITMAP, _In_ int, _In_ int)
BOOL bFocus
Definition: hotkey.c:50
smooth NULL
Definition: ftsmooth.c:416
int WINAPI GetSystemMetrics(_In_ int)
#define SM_CYBORDER
Definition: winuser.h:955
INT CaretPos
Definition: hotkey.c:56
INT nHeight
Definition: hotkey.c:51
HWND hwndSelf
Definition: hotkey.c:47
BOOL WINAPI ShowCaret(_In_opt_ HWND)
BOOL WINAPI SetCaretPos(_In_ int, _In_ int)

◆ HOTKEY_SetFont()

static LRESULT HOTKEY_SetFont ( HOTKEY_INFO infoPtr,
HFONT  hFont,
BOOL  redraw 
)
static

Definition at line 440 of file hotkey.c.

Referenced by HOTKEY_Create(), and HOTKEY_WindowProc().

441 {
442  TEXTMETRICW tm;
443  HDC hdc;
444  HFONT hOldFont = 0;
445 
446  infoPtr->hFont = hFont;
447 
448  hdc = GetDC (infoPtr->hwndSelf);
449  if (infoPtr->hFont)
450  hOldFont = SelectObject (hdc, infoPtr->hFont);
451 
452  GetTextMetricsW (hdc, &tm);
453  infoPtr->nHeight = tm.tmHeight;
454 
455  if (infoPtr->hFont)
456  SelectObject (hdc, hOldFont);
457  ReleaseDC (infoPtr->hwndSelf, hdc);
458 
459  if (redraw)
460  InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
461 
462  return 0;
463 }
#define HDC
Definition: msvc.h:22
#define TRUE
Definition: types.h:120
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
HDC WINAPI GetDC(_In_opt_ HWND)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
HFONT hFont
Definition: main.c:53
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
Definition: time.h:76
void redraw(int x, int y, int cx, int cy)
Definition: qtewin.cpp:1248
INT nHeight
Definition: hotkey.c:51
HWND hwndSelf
Definition: hotkey.c:47
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
LONG tmHeight
Definition: wingdi.h:2360
HFONT hFont
Definition: hotkey.c:49

◆ HOTKEY_SetHotKey()

static void HOTKEY_SetHotKey ( HOTKEY_INFO infoPtr,
WORD  hotKey 
)
static

Definition at line 209 of file hotkey.c.

Referenced by HOTKEY_WindowProc().

210 {
211  infoPtr->HotKey = hotKey;
212  infoPtr->ScanCode =
213  MAKELPARAM(0, MapVirtualKeyW(LOBYTE(infoPtr->HotKey), 0));
214  TRACE("(infoPtr=%p hotKey=%x) Modifiers: 0x%x, Virtual Key: %d\n", infoPtr,
215  hotKey, HIBYTE(infoPtr->HotKey), LOBYTE(infoPtr->HotKey));
216  InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
217 }
#define TRUE
Definition: types.h:120
#define LOBYTE(W)
Definition: jmemdos.c:487
DWORD ScanCode
Definition: hotkey.c:57
#define MAKELPARAM(l, h)
Definition: winuser.h:3915
#define HIBYTE(W)
Definition: jmemdos.c:486
WORD HotKey
Definition: hotkey.c:52
smooth NULL
Definition: ftsmooth.c:416
UINT WINAPI MapVirtualKeyW(_In_ UINT, _In_ UINT)
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
HWND hwndSelf
Definition: hotkey.c:47

◆ HOTKEY_SetRules()

static void HOTKEY_SetRules ( HOTKEY_INFO infoPtr,
WORD  invComb,
WORD  invMod 
)
static

Definition at line 220 of file hotkey.c.

Referenced by HOTKEY_WindowProc().

221 {
222  infoPtr->InvComb = invComb;
223  infoPtr->InvMod = invMod;
224  TRACE("(infoPtr=%p) Invalid Modifers: 0x%x, If Invalid: 0x%x\n", infoPtr,
225  infoPtr->InvComb, infoPtr->InvMod);
226 }
#define TRACE(s)
Definition: solgame.cpp:4
WORD InvComb
Definition: hotkey.c:53
WORD InvMod
Definition: hotkey.c:54

◆ HOTKEY_Unregister()

void HOTKEY_Unregister ( void  )

Definition at line 559 of file hotkey.c.

Referenced by DllMain().

560 {
562 }
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
smooth NULL
Definition: ftsmooth.c:416
#define HOTKEY_CLASSW
Definition: commctrl.h:2206

◆ HOTKEY_WindowProc()

static LRESULT WINAPI HOTKEY_WindowProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 466 of file hotkey.c.

Referenced by HOTKEY_Register().

467 {
468  HOTKEY_INFO *infoPtr = (HOTKEY_INFO *)GetWindowLongPtrW (hwnd, 0);
469  TRACE("hwnd=%p msg=%x wparam=%lx lparam=%lx\n", hwnd, uMsg, wParam, lParam);
470  if (!infoPtr && (uMsg != WM_NCCREATE))
471  return DefWindowProcW (hwnd, uMsg, wParam, lParam);
472  switch (uMsg)
473  {
474  case HKM_GETHOTKEY:
475  return HOTKEY_GetHotKey (infoPtr);
476  case HKM_SETHOTKEY:
477  HOTKEY_SetHotKey (infoPtr, (WORD)wParam);
478  break;
479  case HKM_SETRULES:
480  HOTKEY_SetRules (infoPtr, (WORD)wParam, (WORD)lParam);
481  break;
482 
483  case WM_CHAR:
484  case WM_SYSCHAR:
485  return HOTKEY_KeyDown (infoPtr, MapVirtualKeyW(LOBYTE(HIWORD(lParam)), 1), lParam);
486 
487  case WM_CREATE:
488  return HOTKEY_Create (infoPtr, (LPCREATESTRUCTW)lParam);
489 
490  case WM_DESTROY:
491  return HOTKEY_Destroy (infoPtr);
492 
493  case WM_ERASEBKGND:
494  return HOTKEY_EraseBackground (infoPtr, (HDC)wParam);
495 
496  case WM_GETDLGCODE:
498 
499  case WM_GETFONT:
500  return HOTKEY_GetFont (infoPtr);
501 
502  case WM_KEYDOWN:
503  case WM_SYSKEYDOWN:
504  return HOTKEY_KeyDown (infoPtr, wParam, lParam);
505 
506  case WM_KEYUP:
507  case WM_SYSKEYUP:
508  return HOTKEY_KeyUp (infoPtr, wParam);
509 
510  case WM_KILLFOCUS:
511  return HOTKEY_KillFocus (infoPtr);
512 
513  case WM_LBUTTONDOWN:
514  return HOTKEY_LButtonDown (infoPtr);
515 
516  case WM_NCCREATE:
517  return HOTKEY_NCCreate (hwnd, (LPCREATESTRUCTW)lParam);
518 
519  case WM_PRINTCLIENT:
520  case WM_PAINT:
521  HOTKEY_Paint(infoPtr, (HDC)wParam);
522  return 0;
523 
524  case WM_SETFOCUS:
525  return HOTKEY_SetFocus (infoPtr);
526 
527  case WM_SETFONT:
528  return HOTKEY_SetFont (infoPtr, (HFONT)wParam, LOWORD(lParam));
529 
530  default:
532  ERR("unknown msg %04x wp=%08lx lp=%08lx\n",
533  uMsg, wParam, lParam);
534  return DefWindowProcW (hwnd, uMsg, wParam, lParam);
535  }
536  return 0;
537 }
#define HDC
Definition: msvc.h:22
#define DLGC_WANTCHARS
Definition: winuser.h:2572
#define WM_GETDLGCODE
Definition: winuser.h:1671
#define WM_CHAR
Definition: winuser.h:1693
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
#define LOBYTE(W)
Definition: jmemdos.c:487
static void HOTKEY_Paint(HOTKEY_INFO *infoPtr, HDC hdc)
Definition: hotkey.c:188
static LRESULT HOTKEY_Create(HOTKEY_INFO *infoPtr, const CREATESTRUCTW *lpcs)
Definition: hotkey.c:230
static void HOTKEY_SetRules(HOTKEY_INFO *infoPtr, WORD invComb, WORD invMod)
Definition: hotkey.c:220
#define GetWindowLongPtrW
Definition: winuser.h:4698
static LRESULT HOTKEY_SetFocus(HOTKEY_INFO *infoPtr)
Definition: hotkey.c:427
#define WM_NCCREATE
Definition: winuser.h:1665
WPARAM wParam
Definition: combotst.c:138
#define WM_PRINTCLIENT
Definition: richedit.h:70
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static LRESULT HOTKEY_NCCreate(HWND hwnd, const CREATESTRUCTW *lpcs)
Definition: hotkey.c:406
static LRESULT HOTKEY_KillFocus(HOTKEY_INFO *infoPtr)
Definition: hotkey.c:386
static LRESULT HOTKEY_KeyUp(HOTKEY_INFO *infoPtr, DWORD key)
Definition: hotkey.c:345
#define WM_SYSCHAR
Definition: winuser.h:1697
static LRESULT HOTKEY_SetFont(HOTKEY_INFO *infoPtr, HFONT hFont, BOOL redraw)
Definition: hotkey.c:440
static LRESULT HOTKEY_KeyDown(HOTKEY_INFO *infoPtr, DWORD key, DWORD flags)
Definition: hotkey.c:284
#define HKM_GETHOTKEY
Definition: commctrl.h:2202
static LRESULT HOTKEY_Destroy(HOTKEY_INFO *infoPtr)
Definition: hotkey.c:241
#define WM_GETFONT
Definition: winuser.h:1633
#define WM_KEYDOWN
Definition: winuser.h:1691
UINT WINAPI MapVirtualKeyW(_In_ UINT, _In_ UINT)
#define WM_DESTROY
Definition: winuser.h:1591
#define TRACE(s)
Definition: solgame.cpp:4
#define WM_KILLFOCUS
Definition: winuser.h:1596
#define WM_KEYUP
Definition: winuser.h:1692
unsigned short WORD
Definition: ntddk_ex.h:93
static void HOTKEY_SetHotKey(HOTKEY_INFO *infoPtr, WORD hotKey)
Definition: hotkey.c:209
#define WM_PAINT
Definition: winuser.h:1602
#define HKM_SETHOTKEY
Definition: commctrl.h:2201
#define WM_APP
Definition: eventvwr.h:70
#define WM_USER
Definition: winuser.h:1856
#define ERR(fmt,...)
Definition: debug.h:109
static LRESULT HOTKEY_GetHotKey(const HOTKEY_INFO *infoPtr)
Definition: hotkey.c:201
#define WM_SYSKEYUP
Definition: winuser.h:1696
static LRESULT HOTKEY_EraseBackground(const HOTKEY_INFO *infoPtr, HDC hdc)
Definition: hotkey.c:251
#define WM_SETFONT
Definition: winuser.h:1632
#define HKM_SETRULES
Definition: commctrl.h:2203
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define WM_CREATE
Definition: winuser.h:1590
#define WM_SYSKEYDOWN
Definition: winuser.h:1695
#define HIWORD(l)
Definition: typedefs.h:246
BOOL COMCTL32_IsReflectedMessage(UINT uMsg) DECLSPEC_HIDDEN
Definition: commctrl.c:1745
static LRESULT HOTKEY_LButtonDown(const HOTKEY_INFO *infoPtr)
Definition: hotkey.c:396
#define WM_ERASEBKGND
Definition: winuser.h:1607
#define WM_SETFOCUS
Definition: winuser.h:1595
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define DLGC_WANTARROWS
Definition: winuser.h:2564
static LRESULT HOTKEY_GetFont(const HOTKEY_INFO *infoPtr)
Definition: hotkey.c:278

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( hotkey  )

Variable Documentation

◆ HOTKEY_plussep

const WCHAR HOTKEY_plussep[] = { ' ', '+', ' ' }
static

Definition at line 61 of file hotkey.c.

Referenced by HOTKEY_Refresh().