ReactOS 0.4.17-dev-444-g71ee754
menuaccels.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include "resource.h"
#include "data.c"
Include dependency graph for menuaccels.c:

Go to the source code of this file.

Macros

#define EDIT_STYLE_WRAP   (WS_CHILD | WS_VSCROLL | ES_AUTOVSCROLL | ES_MULTILINE | ES_NOHIDESEL)
 
#define EDIT_STYLE   (EDIT_STYLE_WRAP | WS_HSCROLL | ES_AUTOHSCROLL)
 
#define MSGDUMP_PRINTF   dump_printf
 
#define MSGDUMP_PREFIX   ""
 
#define MSGDUMP_API   WINAPI
 

Functions

LRESULT CALLBACK HookProcCallWnd (_In_ int nCode, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
LRESULT CALLBACK HookProcGetMsg (_In_ int nCode, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
LRESULT CALLBACK HookProcMessage (_In_ int nCode, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
LRESULT CALLBACK WndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static ATOM MyRegisterClass (_In_ HINSTANCE hInstance)
 
int APIENTRY wWinMain (_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow)
 
static void SetMenuString (_In_ HMENU hMenu, _In_ UINT uCommand, _In_ LPCWSTR pszString)
 
static void UpdateEditWnd (_In_ HWND hWndParent)
 
static void UpdateAccelXlatMenu (_In_ HWND hWnd)
 
static void DoCreateEditChildren (_In_ HWND hWndParent)
 
static void AppendTextLineA (_In_ HWND hEdit, _In_ PCSTR pszLine)
 
static void dump_printf (const CHAR *fmt,...)
 
static int GetVkName (_In_ UINT vk, _Out_writes_(cchBuff) PSTR pszBuffer, _In_ SIZE_T cchBuff)
 
static __inline void MSGDUMP_API MD_OnKey (_In_ CHAR Pfx, _In_ HWND hwnd, _In_ BOOL fDown, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
static __inline void MSGDUMP_API MD_OnChar (_In_ CHAR Pfx, _In_ HWND hwnd, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
static __inline void MSGDUMP_API MD_OnDeadChar (_In_ CHAR Pfx, _In_ HWND hwnd, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
static __inline void MSGDUMP_API MD_OnSysKey (_In_ CHAR Pfx, _In_ HWND hwnd, _In_ BOOL fDown, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
static __inline void MSGDUMP_API MD_OnSysChar (_In_ CHAR Pfx, _In_ HWND hwnd, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
static __inline void MSGDUMP_API MD_OnSysDeadChar (_In_ CHAR Pfx, _In_ HWND hwnd, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
static __inline void MSGDUMP_API MD_OnUniChar (_In_ CHAR Pfx, _In_ HWND hwnd, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
static __inline void MSGDUMP_API MD_OnHotKey (_In_ CHAR Pfx, _In_ HWND hwnd, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
static __inline LRESULT MSGDUMP_API MD_msgdump (_In_ CHAR Pfx, _In_ HWND hwnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
 

Variables

static HINSTANCE g_hInst
 
static const PCWSTR szWindowClass = L"TESTAPP"
 
static HWND g_hEdit
 
static HWND g_hMsgDump
 
static ATOM g_aHotKey1
 
static ATOM g_aHotKey2
 
static HHOOK g_hHook1
 
static HHOOK g_hHook2
 
static HHOOK g_hHook3
 
static BOOL g_bShowEdit = TRUE
 
static BOOL g_bXlatAccels = TRUE
 

Macro Definition Documentation

◆ EDIT_STYLE

Definition at line 33 of file menuaccels.c.

◆ EDIT_STYLE_WRAP

Definition at line 32 of file menuaccels.c.

◆ MSGDUMP_API

#define MSGDUMP_API   WINAPI

Definition at line 274 of file menuaccels.c.

◆ MSGDUMP_PREFIX

#define MSGDUMP_PREFIX   ""

Definition at line 273 of file menuaccels.c.

◆ MSGDUMP_PRINTF

#define MSGDUMP_PRINTF   dump_printf

Definition at line 271 of file menuaccels.c.

Function Documentation

◆ AppendTextLineA()

static void AppendTextLineA ( _In_ HWND  hEdit,
_In_ PCSTR  pszLine 
)
static

Definition at line 236 of file menuaccels.c.

239{
240 DWORD l, r;
242 //SendMessageW(hEdit, EM_SETSEL, -1, -1);
246}
r l[0]
Definition: byte_order.h:168
#define FALSE
Definition: types.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
LONG_PTR LPARAM
Definition: minwindef.h:175
UINT_PTR WPARAM
Definition: minwindef.h:174
static HWND hEdit
Definition: autocomplete.c:34
#define EM_GETSEL
Definition: winuser.h:2026
#define EM_REPLACESEL
Definition: winuser.h:2035
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define EM_SETSEL
Definition: winuser.h:2047
int WINAPI GetWindowTextLengthW(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by dump_printf().

◆ DoCreateEditChildren()

static void DoCreateEditChildren ( _In_ HWND  hWndParent)
static

Definition at line 214 of file menuaccels.c.

215{
216 g_hEdit = CreateWindowW(/*WC_EDITW*/ L"Edit", L"", EDIT_STYLE_WRAP,
220
221 g_hMsgDump = CreateWindowW(/*WC_EDITW*/ L"Edit", L"", EDIT_STYLE_WRAP | ES_READONLY,
225
226 /* Finally shows new edit controls */
229
230 /* Re-arrange controls */
232}
#define NULL
Definition: types.h:112
#define L(x)
Definition: resources.c:13
static void UpdateEditWnd(_In_ HWND hWndParent)
Definition: menuaccels.c:188
#define EDIT_STYLE_WRAP
Definition: menuaccels.c:32
static HWND g_hMsgDump
Definition: menuaccels.c:26
static HWND g_hEdit
Definition: menuaccels.c:26
static HINSTANCE g_hInst
Definition: menuaccels.c:23
#define ES_READONLY
Definition: pedump.c:675
#define EM_LIMITTEXT
Definition: winuser.h:2029
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_SIZE
Definition: winuser.h:1639
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4470
#define CW_USEDEFAULT
Definition: winuser.h:225
#define SW_SHOW
Definition: winuser.h:786

Referenced by WndProc().

◆ dump_printf()

static void dump_printf ( const CHAR fmt,
  ... 
)
static

Definition at line 248 of file menuaccels.c.

249{
250 CHAR szText[512];
251 int len;
252
253 va_list va;
254 va_start(va, fmt);
255 len = _vsnprintf(szText, _countof(szText) - 2, fmt, va);
256 if (len < 0)
257 *szText = ANSI_NULL;
258 va_end(va);
259
260 /* Ensure the line ends with CR-LF */
261 len = min(len, _countof(szText) - 3);
262 szText[len + 0] = '\r';
263 szText[len + 1] = '\n';
264 szText[len + 2] = ANSI_NULL;
265
266 /* Append the text line */
268 //DbgPrint("TEST: %s\n", szText);
269 OutputDebugStringA(szText);
270}
#define va_end(v)
Definition: stdarg.h:28
#define va_start(v, l)
Definition: stdarg.h:26
char * va_list
Definition: vadefs.h:50
GLenum GLsizei len
Definition: glext.h:6722
void WINAPI SHIM_OBJ_NAME() OutputDebugStringA(LPCSTR lpOutputString)
Definition: ignoredbgout.c:18
static void AppendTextLineA(_In_ HWND hEdit, _In_ PCSTR pszLine)
Definition: menuaccels.c:236
#define _vsnprintf
Definition: _vsnprintf.c:28
#define min(a, b)
Definition: monoChain.cc:55
#define ANSI_NULL
char CHAR
Definition: pedump.c:57
#define _countof(array)
Definition: sndvol32.h:70
Definition: dsound.c:943

◆ GetVkName()

static int GetVkName ( _In_ UINT  vk,
_Out_writes_(cchBuff) PSTR  pszBuffer,
_In_ SIZE_T  cchBuff 
)
static

Definition at line 280 of file menuaccels.c.

284{
285 PCSTR vkName;
286
287 if (vk > 0xFF)
288 vk = 0xFF; // VK_UNKNOWN
289 vkName = VkNames[vk];
290
291 if (!vkName)
292 {
293 return _snprintf(pszBuffer, cchBuff, "%lX", vk);
294 }
295 else
296 {
297 if ((0x30 <= vk && vk <= 0x39) || (0x41 <= vk && vk <= 0x5A))
298 return _snprintf(pszBuffer, cchBuff, "'%s'", vkName);
299 else
300 return _snprintf(pszBuffer, cchBuff, "%s", vkName);
301 }
302}
unsigned short vk
Definition: console.c:118
static int __cdecl _snprintf(char *buffer, size_t size, const char *format,...) __WINE_CRT_PRINTF_ATTR(3
Definition: stdio.h:507
static const PCSTR VkNames[]
Definition: data.c:13
const char * PCSTR
Definition: typedefs.h:52

Referenced by MD_OnHotKey(), MD_OnKey(), and MD_OnSysKey().

◆ HookProcCallWnd()

LRESULT CALLBACK HookProcCallWnd ( _In_ int  nCode,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)

Definition at line 462 of file menuaccels.c.

466{
467 PCWPSTRUCT pcwp;
468
469 //if (nCode < 0) /* Do not process the message */
470 // return CallNextHookEx(g_hHook1, nCode, wParam, lParam);
471
472 pcwp = (PCWPSTRUCT)lParam;
473 MD_msgdump('C', pcwp->hwnd, pcwp->message, pcwp->wParam, pcwp->lParam);
474
475 return CallNextHookEx(g_hHook1, nCode, wParam, lParam);
476}
#define MD_msgdump(hwnd, uMsg, wParam, lParam)
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static HHOOK g_hHook1
Definition: menuaccels.c:28
LPARAM lParam
Definition: winuser.h:3133
WPARAM wParam
Definition: winuser.h:3134
UINT message
Definition: winuser.h:3135
struct tagCWPSTRUCT * PCWPSTRUCT
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)

Referenced by wWinMain().

◆ HookProcGetMsg()

LRESULT CALLBACK HookProcGetMsg ( _In_ int  nCode,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)

Definition at line 479 of file menuaccels.c.

483{
484 PMSG pmsg;
485
486 //if (nCode < 0) /* Do not process the message */
487 // return CallNextHookEx(g_hHook2, nCode, wParam, lParam);
488
489 pmsg = (PMSG)lParam;
490 MD_msgdump('G', pmsg->hwnd, pmsg->message, pmsg->wParam, pmsg->lParam);
491
492 return CallNextHookEx(g_hHook2, nCode, wParam, lParam);
493}
static HHOOK g_hHook2
Definition: menuaccels.c:28
UINT message
Definition: winuser.h:3223
HWND hwnd
Definition: winuser.h:3222
WPARAM wParam
Definition: winuser.h:3224
LPARAM lParam
Definition: winuser.h:3225
struct tagMSG * PMSG

Referenced by wWinMain().

◆ HookProcMessage()

LRESULT CALLBACK HookProcMessage ( _In_ int  nCode,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)

Definition at line 496 of file menuaccels.c.

500{
501 PMSG pmsg;
502
503 //if (nCode < 0) /* Do not process the message */
504 // return CallNextHookEx(g_hHook3, nCode, wParam, lParam);
505
506 pmsg = (PMSG)lParam;
507 MD_msgdump('M', pmsg->hwnd, pmsg->message, pmsg->wParam, pmsg->lParam);
508
509 return CallNextHookEx(g_hHook3, nCode, wParam, lParam);
510}
static HHOOK g_hHook3
Definition: menuaccels.c:28

Referenced by wWinMain().

◆ MD_msgdump()

static __inline LRESULT MSGDUMP_API MD_msgdump ( _In_ CHAR  Pfx,
_In_ HWND  hwnd,
_In_ UINT  uMsg,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)
static

Definition at line 440 of file menuaccels.c.

441{
442 switch (uMsg)
443 {
444 case WM_KEYDOWN: MD_OnKey(Pfx, hwnd, TRUE, wParam, lParam); break;
445 case WM_KEYUP: MD_OnKey(Pfx, hwnd, FALSE, wParam, lParam); break;
446 case WM_CHAR: MD_OnChar(Pfx, hwnd, wParam, lParam); break;
447 case WM_DEADCHAR: MD_OnDeadChar(Pfx, hwnd, wParam, lParam); break;
448 case WM_SYSKEYDOWN: MD_OnSysKey(Pfx, hwnd, TRUE, wParam, lParam); break;
449 case WM_SYSKEYUP: MD_OnSysKey(Pfx, hwnd, FALSE, wParam, lParam); break;
450 case WM_SYSCHAR: MD_OnSysChar(Pfx, hwnd, wParam, lParam); break;
451 case WM_SYSDEADCHAR: MD_OnSysDeadChar(Pfx, hwnd, wParam, lParam); break;
452 case WM_UNICHAR: MD_OnUniChar(Pfx, hwnd, wParam, lParam); break;
453 case WM_HOTKEY: MD_OnHotKey(Pfx, hwnd, wParam, lParam); break;
454 case WM_IME_CHAR: break; // TODO
455 case WM_IME_KEYDOWN: break; // TODO
456 case WM_IME_KEYUP: break; // TODO
457 }
458 return 0;
459}
#define TRUE
Definition: types.h:120
static __inline void MSGDUMP_API MD_OnDeadChar(_In_ CHAR Pfx, _In_ HWND hwnd, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: menuaccels.c:345
static __inline void MSGDUMP_API MD_OnKey(_In_ CHAR Pfx, _In_ HWND hwnd, _In_ BOOL fDown, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: menuaccels.c:305
static __inline void MSGDUMP_API MD_OnUniChar(_In_ CHAR Pfx, _In_ HWND hwnd, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: menuaccels.c:411
static __inline void MSGDUMP_API MD_OnHotKey(_In_ CHAR Pfx, _In_ HWND hwnd, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: menuaccels.c:424
static __inline void MSGDUMP_API MD_OnChar(_In_ CHAR Pfx, _In_ HWND hwnd, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: menuaccels.c:332
static __inline void MSGDUMP_API MD_OnSysChar(_In_ CHAR Pfx, _In_ HWND hwnd, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: menuaccels.c:385
static __inline void MSGDUMP_API MD_OnSysDeadChar(_In_ CHAR Pfx, _In_ HWND hwnd, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: menuaccels.c:398
static __inline void MSGDUMP_API MD_OnSysKey(_In_ CHAR Pfx, _In_ HWND hwnd, _In_ BOOL fDown, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: menuaccels.c:358
#define WM_UNICHAR
Definition: richedit.h:67
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define WM_IME_KEYUP
Definition: winuser.h:1867
#define WM_KEYUP
Definition: winuser.h:1744
#define WM_IME_KEYDOWN
Definition: winuser.h:1866
#define WM_IME_CHAR
Definition: winuser.h:1862
#define WM_SYSCHAR
Definition: winuser.h:1749
#define WM_SYSDEADCHAR
Definition: winuser.h:1750
#define WM_SYSKEYUP
Definition: winuser.h:1748
#define WM_CHAR
Definition: winuser.h:1745
#define WM_HOTKEY
Definition: winuser.h:1907
#define WM_KEYDOWN
Definition: winuser.h:1743
#define WM_DEADCHAR
Definition: winuser.h:1746
#define WM_SYSKEYDOWN
Definition: winuser.h:1747

◆ MD_OnChar()

static __inline void MSGDUMP_API MD_OnChar ( _In_ CHAR  Pfx,
_In_ HWND  hwnd,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)
static

Definition at line 332 of file menuaccels.c.

333{
334 WCHAR ch = (WCHAR)wParam;
335 UINT cRepeat = (UINT)LOWORD(lParam);
337 UCHAR ScanCode = (flags & 0xFF);
338 MSGDUMP_PRINTF("%p %c %sWM_CHAR\tchCharCode:'%04X' (%u) cRepeat:%u ScanCode:%02X fExtended:%u fAltDown:%u fRepeat:%u fUp:%u [wParam:%08lX lParam:%08lX]",
339 hwnd, Pfx, MSGDUMP_PREFIX, ch, ch, cRepeat, ScanCode,
340 !!(flags & KF_EXTENDED), !!(flags & KF_ALTDOWN), !!(flags & KF_REPEAT), !!(flags & KF_UP),
341 wParam, lParam);
342}
UINT ScanCode
Definition: VirtualKey.c:24
unsigned char ch[4][2]
Definition: console.c:118
GLbitfield flags
Definition: glext.h:7161
unsigned int UINT
Definition: sysinfo.c:13
#define MSGDUMP_PREFIX
Definition: menuaccels.c:273
#define MSGDUMP_PRINTF
Definition: menuaccels.c:271
#define LOWORD(l)
Definition: pedump.c:82
short WCHAR
Definition: pedump.c:58
unsigned short USHORT
Definition: pedump.c:61
unsigned char UCHAR
Definition: typedefs.h:53
#define HIWORD(l)
Definition: typedefs.h:247
#define KF_ALTDOWN
Definition: winuser.h:2485
#define KF_EXTENDED
Definition: winuser.h:2482
#define KF_UP
Definition: winuser.h:2487
#define KF_REPEAT
Definition: winuser.h:2486

Referenced by MD_msgdump().

◆ MD_OnDeadChar()

static __inline void MSGDUMP_API MD_OnDeadChar ( _In_ CHAR  Pfx,
_In_ HWND  hwnd,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)
static

Definition at line 345 of file menuaccels.c.

346{
347 WCHAR ch = (WCHAR)wParam;
348 UINT cRepeat = (UINT)LOWORD(lParam);
350 UCHAR ScanCode = (flags & 0xFF);
351 MSGDUMP_PRINTF("%p %c %sWM_DEADCHAR\tchCharCode:'%04X' (%u) cRepeat:%u ScanCode:%02X fExtended:%u fAltDown:%u fRepeat:%u fUp:%u [wParam:%08lX lParam:%08lX]",
352 hwnd, Pfx, MSGDUMP_PREFIX, ch, ch, cRepeat, ScanCode,
353 !!(flags & KF_EXTENDED), !!(flags & KF_ALTDOWN), !!(flags & KF_REPEAT), !!(flags & KF_UP),
354 wParam, lParam);
355}

Referenced by MD_msgdump().

◆ MD_OnHotKey()

static __inline void MSGDUMP_API MD_OnHotKey ( _In_ CHAR  Pfx,
_In_ HWND  hwnd,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)
static

Definition at line 424 of file menuaccels.c.

425{
426 int idHotKey = (int)wParam;
427 UINT fuModifiers = (UINT)LOWORD(lParam);
429
430 CHAR szVkName[100];
431 GetVkName(vk, szVkName, _countof(szVkName));
432 // TODO: Convert fuModifiers to "human-readable" names.
433
434 MSGDUMP_PRINTF("%p %c %sWM_HOTKEY\tidHotKey:%04X fuModifiers:%u nVirtKey:%s [wParam:%08lX lParam:%08lX]",
435 hwnd, Pfx, MSGDUMP_PREFIX, idHotKey, fuModifiers, szVkName,
436 wParam, lParam);
437}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
static int GetVkName(_In_ UINT vk, _Out_writes_(cchBuff) PSTR pszBuffer, _In_ SIZE_T cchBuff)
Definition: menuaccels.c:280

Referenced by MD_msgdump().

◆ MD_OnKey()

static __inline void MSGDUMP_API MD_OnKey ( _In_ CHAR  Pfx,
_In_ HWND  hwnd,
_In_ BOOL  fDown,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)
static

Definition at line 305 of file menuaccels.c.

306{
307 UINT vk = (UINT)wParam;
308 UINT cRepeat = (UINT)LOWORD(lParam);
310 UCHAR ScanCode = (flags & 0xFF);
311
312 CHAR szVkName[100];
313 GetVkName(vk, szVkName, _countof(szVkName));
314
315 if (fDown)
316 {
317 MSGDUMP_PRINTF("%p %c %sWM_KEYDOWN\tnVirtKey:%s cRepeat:%u ScanCode:%02X fExtended:%u fAltDown:%u fRepeat:%u fUp:%u [wParam:%08lX lParam:%08lX]",
318 hwnd, Pfx, MSGDUMP_PREFIX, szVkName, cRepeat, ScanCode,
319 !!(flags & KF_EXTENDED), !!(flags & KF_ALTDOWN), !!(flags & KF_REPEAT), !!(flags & KF_UP),
320 wParam, lParam);
321 }
322 else
323 {
324 MSGDUMP_PRINTF("%p %c %sWM_KEYUP\tnVirtKey:%s cRepeat:%u ScanCode:%02X fExtended:%u fAltDown:%u fRepeat:%u fUp:%u [wParam:%08lX lParam:%08lX]",
325 hwnd, Pfx, MSGDUMP_PREFIX, szVkName, cRepeat, ScanCode,
326 !!(flags & KF_EXTENDED), !!(flags & KF_ALTDOWN), !!(flags & KF_REPEAT), !!(flags & KF_UP),
327 wParam, lParam);
328 }
329}

Referenced by MD_msgdump().

◆ MD_OnSysChar()

static __inline void MSGDUMP_API MD_OnSysChar ( _In_ CHAR  Pfx,
_In_ HWND  hwnd,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)
static

Definition at line 385 of file menuaccels.c.

386{
387 WCHAR ch = (WCHAR)wParam;
388 UINT cRepeat = (UINT)LOWORD(lParam);
390 UCHAR ScanCode = (flags & 0xFF);
391 MSGDUMP_PRINTF("%p %c %sWM_SYSCHAR\tchCharCode:'%04X' (%u) cRepeat:%u ScanCode:%02X fExtended:%u fAltDown:%u fRepeat:%u fUp:%u [wParam:%08lX lParam:%08lX]",
392 hwnd, Pfx, MSGDUMP_PREFIX, ch, ch, cRepeat, ScanCode,
393 !!(flags & KF_EXTENDED), !!(flags & KF_ALTDOWN), !!(flags & KF_REPEAT), !!(flags & KF_UP),
394 wParam, lParam);
395}

Referenced by MD_msgdump().

◆ MD_OnSysDeadChar()

static __inline void MSGDUMP_API MD_OnSysDeadChar ( _In_ CHAR  Pfx,
_In_ HWND  hwnd,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)
static

Definition at line 398 of file menuaccels.c.

399{
400 WCHAR ch = (WCHAR)wParam;
401 UINT cRepeat = (UINT)LOWORD(lParam);
403 UCHAR ScanCode = (flags & 0xFF);
404 MSGDUMP_PRINTF("%p %c %sWM_SYSDEADCHAR\tchCharCode:'%04X' (%u) cRepeat:%u ScanCode:%02X fExtended:%u fAltDown:%u fRepeat:%u fUp:%u [wParam:%08lX lParam:%08lX]",
405 hwnd, Pfx, MSGDUMP_PREFIX, ch, ch, cRepeat, ScanCode,
406 !!(flags & KF_EXTENDED), !!(flags & KF_ALTDOWN), !!(flags & KF_REPEAT), !!(flags & KF_UP),
407 wParam, lParam);
408}

Referenced by MD_msgdump().

◆ MD_OnSysKey()

static __inline void MSGDUMP_API MD_OnSysKey ( _In_ CHAR  Pfx,
_In_ HWND  hwnd,
_In_ BOOL  fDown,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)
static

Definition at line 358 of file menuaccels.c.

359{
360 UINT vk = (UINT)wParam;
361 UINT cRepeat = (UINT)LOWORD(lParam);
363 UCHAR ScanCode = (flags & 0xFF);
364
365 CHAR szVkName[100];
366 GetVkName(vk, szVkName, _countof(szVkName));
367
368 if (fDown)
369 {
370 MSGDUMP_PRINTF("%p %c %sWM_SYSKEYDOWN\tnVirtKey:%s cRepeat:%u ScanCode:%02X fExtended:%u fAltDown:%u fRepeat:%u fUp:%u [wParam:%08lX lParam:%08lX]",
371 hwnd, Pfx, MSGDUMP_PREFIX, szVkName, cRepeat, ScanCode,
372 !!(flags & KF_EXTENDED), !!(flags & KF_ALTDOWN), !!(flags & KF_REPEAT), !!(flags & KF_UP),
373 wParam, lParam);
374 }
375 else
376 {
377 MSGDUMP_PRINTF("%p %c %sWM_SYSKEYUP\tnVirtKey:%s cRepeat:%u ScanCode:%02X fExtended:%u fAltDown:%u fRepeat:%u fUp:%u [wParam:%08lX lParam:%08lX]",
378 hwnd, Pfx, MSGDUMP_PREFIX, szVkName, cRepeat, ScanCode,
379 !!(flags & KF_EXTENDED), !!(flags & KF_ALTDOWN), !!(flags & KF_REPEAT), !!(flags & KF_UP),
380 wParam, lParam);
381 }
382}

Referenced by MD_msgdump().

◆ MD_OnUniChar()

static __inline void MSGDUMP_API MD_OnUniChar ( _In_ CHAR  Pfx,
_In_ HWND  hwnd,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)
static

Definition at line 411 of file menuaccels.c.

412{
413 WCHAR ch = (WCHAR)wParam;
414 UINT cRepeat = (UINT)LOWORD(lParam);
416 UCHAR ScanCode = (flags & 0xFF);
417 MSGDUMP_PRINTF("%p %c %sWM_UNICHAR\tchCharCode:'%04X' (%u) cRepeat:%u ScanCode:%02X fExtended:%u fAltDown:%u fRepeat:%u fUp:%u [wParam:%08lX lParam:%08lX]",
418 hwnd, Pfx, MSGDUMP_PREFIX, ch, ch, cRepeat, ScanCode,
419 !!(flags & KF_EXTENDED), !!(flags & KF_ALTDOWN), !!(flags & KF_REPEAT), !!(flags & KF_UP),
420 wParam, lParam);
421}

Referenced by MD_msgdump().

◆ MyRegisterClass()

static ATOM MyRegisterClass ( _In_ HINSTANCE  hInstance)
static

Definition at line 59 of file menuaccels.c.

60{
61 WNDCLASSEXW wcex;
63
69 LR_SHARED);
70
76 LR_SHARED);
77
78 wcex.cbSize = sizeof(wcex);
80 wcex.lpfnWndProc = WndProc;
81 wcex.cbClsExtra = 0;
82 wcex.cbWndExtra = 0;
83 wcex.hInstance = hInstance;
84 wcex.hIcon = hBgIcon;
86 wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
89 wcex.hIconSm = hSmIcon;
90
91 return RegisterClassExW(&wcex);
92}
HINSTANCE hInstance
Definition: charmap.c:19
HICON hSmIcon
Definition: charmap.c:23
HICON hBgIcon
Definition: charmap.c:24
static const PCWSTR szWindowClass
Definition: menuaccels.c:24
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: menuaccels.c:514
#define IDI_TESTAPP
Definition: resource.h:10
#define IDC_TESTAPP
Definition: resource.h:11
static HICON
Definition: imagelist.c:80
LPCWSTR lpszClassName
Definition: winuser.h:3334
LPCWSTR lpszMenuName
Definition: winuser.h:3333
HBRUSH hbrBackground
Definition: winuser.h:3332
WNDPROC lpfnWndProc
Definition: winuser.h:3326
UINT cbSize
Definition: winuser.h:3324
int cbWndExtra
Definition: winuser.h:3328
HCURSOR hCursor
Definition: winuser.h:3331
HICON hIconSm
Definition: winuser.h:3335
HINSTANCE hInstance
Definition: winuser.h:3329
UINT style
Definition: winuser.h:3325
int cbClsExtra
Definition: winuser.h:3327
HICON hIcon
Definition: winuser.h:3330
#define CS_VREDRAW
Definition: winuser.h:666
#define COLOR_WINDOW
Definition: winuser.h:929
#define IMAGE_ICON
Definition: winuser.h:212
#define CS_HREDRAW
Definition: winuser.h:661
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2572
#define IDC_ARROW
Definition: winuser.h:695
#define SM_CYSMICON
Definition: winuser.h:1024
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2474
#define SM_CXSMICON
Definition: winuser.h:1023
#define SM_CYICON
Definition: winuser.h:984
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define LR_SHARED
Definition: winuser.h:1111
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define SM_CXICON
Definition: winuser.h:983
int WINAPI GetSystemMetrics(_In_ int)

Referenced by wWinMain().

◆ SetMenuString()

static void SetMenuString ( _In_ HMENU  hMenu,
_In_ UINT  uCommand,
_In_ LPCWSTR  pszString 
)
static

Definition at line 172 of file menuaccels.c.

176{
177 WCHAR szMenu[128];
178
179 if (IS_INTRESOURCE(pszString))
180 {
181 LoadStringW(g_hInst, PtrToUlong(pszString), szMenu, _countof(szMenu));
182 pszString = szMenu;
183 }
184 ModifyMenuW(hMenu, uCommand, MF_BYCOMMAND | MF_STRING, uCommand, pszString);
185}
#define IS_INTRESOURCE(x)
Definition: loader.c:613
#define PtrToUlong(u)
Definition: config.h:107
#define LoadStringW
Definition: utils.h:64
#define MF_BYCOMMAND
Definition: winuser.h:202
#define MF_STRING
Definition: winuser.h:138
BOOL WINAPI ModifyMenuW(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)

Referenced by UpdateAccelXlatMenu(), and UpdateEditWnd().

◆ UpdateAccelXlatMenu()

static void UpdateAccelXlatMenu ( _In_ HWND  hWnd)
static

Definition at line 205 of file menuaccels.c.

206{
207 /* Change the menu command string */
211}
HWND hWnd
Definition: settings.c:17
static BOOL g_bXlatAccels
Definition: menuaccels.c:30
static void SetMenuString(_In_ HMENU hMenu, _In_ UINT uCommand, _In_ LPCWSTR pszString)
Definition: menuaccels.c:172
#define IDS_ACCELNOXLAT
Definition: resource.h:16
#define IDM_ACCELXLAT
Definition: resource.h:19
#define IDS_ACCELXLAT
Definition: resource.h:15
HMENU WINAPI GetMenu(_In_ HWND)

Referenced by WndProc().

◆ UpdateEditWnd()

static void UpdateEditWnd ( _In_ HWND  hWndParent)
static

Definition at line 188 of file menuaccels.c.

189{
190 /* Change the menu command string */
194
195 /* Show or hide the editable edit control and set focus to it if needed */
197 if (g_bShowEdit)
199
200 /* Re-arrange controls */
202}
static BOOL g_bShowEdit
Definition: menuaccels.c:29
#define IDS_EDITSHOW
Definition: resource.h:13
#define IDM_SHOWHIDEEDIT
Definition: resource.h:18
#define IDS_EDITHIDE
Definition: resource.h:14
#define SW_HIDE
Definition: winuser.h:779
HWND WINAPI SetFocus(_In_opt_ HWND)

Referenced by DoCreateEditChildren(), and WndProc().

◆ WndProc()

LRESULT CALLBACK WndProc ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 514 of file menuaccels.c.

515{
516 // MD_msgdump(hWnd, uMsg, wParam, lParam);
517 switch (uMsg)
518 {
519 case WM_CREATE:
522 break;
523
524 case WM_DESTROY:
526 break;
527
528 case WM_HOTKEY:
529 if (wParam == g_aHotKey1) // && LOWORD(lParam) == MOD_ALT && HIWORD(lParam) == VK_NUMPAD4
531 else if (wParam == g_aHotKey2) // && LOWORD(lParam) == MOD_ALT && HIWORD(lParam) == VK_NUMPAD5
533 break;
534
535 case WM_COMMAND:
536 {
537 WORD wmId = LOWORD(wParam);
538 //WORD wmEvent = HIWORD(wParam);
539 switch (wmId)
540 {
541 case IDM_ONE: case IDM_TWO: case IDM_THREE:
542 case IDM_FOUR: case IDM_FIVE:
543 case IDM_THIRTEEN: case IDM_FOURTEEN: case IDM_FIFTEEN:
544 {
545 /* See `IDC_TESTAPP ACCELERATORS` */
546 static const PCWSTR Messages[] =
547 {L"One (Alt '1' ASCII)", L"Two (Alt 2 VIRTKEY)", L"Three (Alt VK_NUMPAD3 VIRTKEY)",
548 L"Four (Alt VK_NUMPAD4 -- WM_HOTKEY thread)", L"Five (Alt VK_NUMPAD5 -- WM_HOTKEY hWnd)",
549 L"Thirteen (Alt 'D' ASCII)", L"Fourteen (Alt E VIRTKEY)", L"Fifteen (Alt F VIRTKEY)"};
550
551 if (IDM_ONE <= wmId && wmId <= IDM_FIVE)
552 wmId -= IDM_ONE;
553 else if (IDM_THIRTEEN <= wmId && wmId <= IDM_FIFTEEN)
554 wmId -= IDM_THIRTEEN - (IDM_FIVE - IDM_ONE + 1);
555 MessageBoxW(hWnd, Messages[wmId], L"Info", MB_OK);
556 break;
557 }
558
559 case IDM_SHOWHIDEEDIT:
562 break;
563
564 case IDM_ACCELXLAT:
567 break;
568
569 case IDM_CLEARLOG:
571 break;
572
573 case IDM_EXIT:
575 break;
576 default:
577 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
578 }
579 break;
580 }
581
582 case WM_SIZE:
583 {
584 RECT rc;
585 GetClientRect(hWnd, &rc);
586 if (g_bShowEdit)
587 {
588 MoveWindow(g_hEdit, 0, 0, rc.right, rc.bottom / 2, TRUE);
589 MoveWindow(g_hMsgDump, 0, rc.bottom / 2, rc.right, rc.bottom / 2, TRUE);
590 }
591 else
592 {
593 MoveWindow(g_hMsgDump, 0, 0, rc.right, rc.bottom, TRUE);
594 }
595 break;
596 }
597
598 case WM_PAINT:
599 {
600 PAINTSTRUCT ps;
601 BeginPaint(hWnd, &ps);
602 EndPaint(hWnd, &ps);
603 break;
604 }
605
606 default:
607 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
608 }
609 return 0;
610}
#define IDM_EXIT
Definition: resource.h:27
unsigned short WORD
Definition: ntddk_ex.h:93
static ATOM g_aHotKey1
Definition: menuaccels.c:27
static void UpdateAccelXlatMenu(_In_ HWND hWnd)
Definition: menuaccels.c:205
static void DoCreateEditChildren(_In_ HWND hWndParent)
Definition: menuaccels.c:214
static ATOM g_aHotKey2
Definition: menuaccels.c:27
#define IDM_THREE
Definition: resource.h:24
#define IDM_ONE
Definition: resource.h:22
#define IDM_FIVE
Definition: resource.h:26
#define IDM_CLEARLOG
Definition: resource.h:20
#define IDM_FOURTEEN
Definition: resource.h:28
#define IDM_FOUR
Definition: resource.h:25
#define IDM_TWO
Definition: resource.h:23
#define IDM_THIRTEEN
Definition: resource.h:27
#define IDM_FIFTEEN
Definition: resource.h:29
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define WM_PAINT
Definition: winuser.h:1648
#define MAKEWPARAM(l, h)
Definition: winuser.h:4117
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CREATE
Definition: winuser.h:1636
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_COMMAND
Definition: winuser.h:1768
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define WM_SETTEXT
Definition: winuser.h:1645
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define MB_OK
Definition: winuser.h:801
#define WM_DESTROY
Definition: winuser.h:1637
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
BOOL WINAPI DestroyWindow(_In_ HWND)
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)

Referenced by MyRegisterClass().

◆ wWinMain()

int APIENTRY wWinMain ( _In_ HINSTANCE  hInstance,
_In_ HINSTANCE  hPrevInstance,
_In_ LPWSTR  lpCmdLine,
_In_ int  nCmdShow 
)

Definition at line 95 of file menuaccels.c.

100{
101 HWND hWnd;
102 MSG msg;
103 HACCEL hAccelTable;
104
105 UNREFERENCED_PARAMETER(hPrevInstance);
106 UNREFERENCED_PARAMETER(lpCmdLine);
107
108 /* Register ourselves */
110 return FALSE;
112
113 /* Create the main window and load the accelerators */
117 if (!hWnd)
118 return FALSE;
119
120 /* Show ourselves */
121 ShowWindow(hWnd, nCmdShow);
123
124 /* Set up the accelerators, hotkey, and window hooks */
126 if (!hAccelTable)
127 OutputDebugStringA("LoadAcceleratorsW() failed\n");
128
129 g_aHotKey1 = GlobalAddAtomW(L"TESTAPP Alt 4 Hotkey");
131 OutputDebugStringA("RegisterHotKey() failed\n"); //DPRINT1("RegisterHotKey failed with %lu\n", GetLastError());
132
133 g_aHotKey2 = GlobalAddAtomW(L"TESTAPP Alt 5 Hotkey");
135 OutputDebugStringA("RegisterHotKey() failed\n"); //DPRINT1("RegisterHotKey failed with %lu\n", GetLastError());
136
140
141 /* Pump the queue */
142 while (GetMessageW(&msg, NULL, 0, 0))
143 {
144 if ((msg.message == WM_HOTKEY) && (msg.wParam == g_aHotKey1))
145 {
146 // if (LOWORD(msg.lParam) == MOD_ALT && HIWORD(msg.lParam) == VK_NUMPAD4)
148 continue;
149 }
150
151 if (!g_bXlatAccels || !TranslateAcceleratorW(hWnd, hAccelTable, &msg))
152 {
155 }
156 }
157
158 /* Cleanup and return */
162
167
168 return (int)msg.wParam;
169}
#define msg(x)
Definition: auth_time.c:54
ATOM WINAPI GlobalDeleteAtom(ATOM nAtom)
Definition: atom.c:444
ATOM WINAPI GlobalAddAtomW(LPCWSTR lpString)
Definition: atom.c:434
#define MOD_ALT
Definition: imm.h:184
LRESULT CALLBACK HookProcMessage(_In_ int nCode, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: menuaccels.c:496
LRESULT CALLBACK HookProcGetMsg(_In_ int nCode, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: menuaccels.c:479
static ATOM MyRegisterClass(_In_ HINSTANCE hInstance)
Definition: menuaccels.c:59
LRESULT CALLBACK HookProcCallWnd(_In_ int nCode, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: menuaccels.c:462
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
HHOOK WINAPI SetWindowsHookExW(_In_ int, _In_ HOOKPROC, _In_opt_ HINSTANCE, _In_ DWORD)
BOOL WINAPI UnregisterHotKey(_In_opt_ HWND, _In_ int)
#define WH_MSGFILTER
Definition: winuser.h:29
#define VK_NUMPAD4
Definition: winuser.h:2279
BOOL WINAPI RegisterHotKey(_In_opt_ HWND, _In_ int, _In_ UINT, _In_ UINT)
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
BOOL WINAPI UpdateWindow(_In_ HWND)
#define WH_GETMESSAGE
Definition: winuser.h:33
HACCEL WINAPI LoadAcceleratorsW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
#define VK_NUMPAD5
Definition: winuser.h:2280
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
int WINAPI TranslateAcceleratorW(_In_ HWND, _In_ HACCEL, _In_ LPMSG)
#define WH_CALLWNDPROC
Definition: winuser.h:34

Variable Documentation

◆ g_aHotKey1

ATOM g_aHotKey1
static

Definition at line 27 of file menuaccels.c.

Referenced by WndProc(), and wWinMain().

◆ g_aHotKey2

ATOM g_aHotKey2
static

Definition at line 27 of file menuaccels.c.

Referenced by WndProc(), and wWinMain().

◆ g_bShowEdit

BOOL g_bShowEdit = TRUE
static

Definition at line 29 of file menuaccels.c.

Referenced by UpdateEditWnd(), and WndProc().

◆ g_bXlatAccels

BOOL g_bXlatAccels = TRUE
static

Definition at line 30 of file menuaccels.c.

Referenced by UpdateAccelXlatMenu(), WndProc(), and wWinMain().

◆ g_hEdit

HWND g_hEdit
static

Definition at line 26 of file menuaccels.c.

Referenced by DoCreateEditChildren(), UpdateEditWnd(), and WndProc().

◆ g_hHook1

HHOOK g_hHook1
static

Definition at line 28 of file menuaccels.c.

Referenced by HookProcCallWnd(), and wWinMain().

◆ g_hHook2

HHOOK g_hHook2
static

Definition at line 28 of file menuaccels.c.

Referenced by HookProcGetMsg(), and wWinMain().

◆ g_hHook3

HHOOK g_hHook3
static

Definition at line 28 of file menuaccels.c.

Referenced by HookProcMessage(), and wWinMain().

◆ g_hInst

HINSTANCE g_hInst
static

Definition at line 23 of file menuaccels.c.

Referenced by DoCreateEditChildren(), SetMenuString(), and wWinMain().

◆ g_hMsgDump

HWND g_hMsgDump
static

Definition at line 26 of file menuaccels.c.

Referenced by DoCreateEditChildren(), dump_printf(), and WndProc().

◆ szWindowClass

const PCWSTR szWindowClass = L"TESTAPP"
static

Definition at line 24 of file menuaccels.c.

Referenced by MyRegisterClass(), and wWinMain().