Correctly updating UI state to hide keyboard accelerator underlines

Tech-Archive recommends: Speed Up your PC by fixing your registry



Hi all,

I'm trying to understand how to correctly implement the showing and
hiding of access keys for an application which does not use any native
Win32 controls. I've been following the docs at <http://
msdn.microsoft.com/en-us/library/ms646335(VS.
85).aspx#_win32_UI_State>. Here is what I've been doing:

On initialization, I call SystemParametersInfo with
SPI_GETKEYBOARDCUES in order to determine whether or not to show the
cues, which returns false (correct). After calling CreateWindowEx, I
send WM_QUERYUISTATE to the newly created window in order to determine
the initial UI state for the window. This call *always* returns 0, no
matter if the window has been invoked via a keyboard command or using
the mouse. I also handle WM_UPDATEUISTATE in the window proc like
this:

case WM_UPDATEUISTATE:
{
short action = LOWORD(wParam);
short state = HIWORD(wParam);
switch (action) {
case UIS_SET:
if (state & UISF_HIDEACCEL)
mShowAccelerators = PR_FALSE;
break;
case UIS_CLEAR:
if (state & UISF_HIDEACCEL)
mShowAccelerators = PR_TRUE;
break;
case UIS_INITIALIZE:
{
HWND parent = ::GetParent(mWnd);
if (parent)
::SendMessageW(parent, WM_CHANGEUISTATE, wParam, 0);
}
break;
}
Invalidate(PR_FALSE);
}
break;

But no matter which keys pressed (Alt, Tab, arrow keys), I never get
WM_UPDATEUISTATE, so the above code actually never executes. When
drawing, I use mShowAccelerators (which is always true in my case) to
determine whether to show the accelerators or not. This results the
application to always show the underlines for accelerators, which is
not desirable.

Can anyone shed some light on how these messages are supposed to work,
and what do I need to do in order to handle them properly, so that I
get the native-equivalent behavior?

Thanks!
Ehsan
.



Relevant Pages

  • Re: [PATCH] ncurses based config V2
    ... Fixed segfaults in help window. ... Added hot keys support. ... Optimized for 80x24 terminals. ... ESC prefix, I don't know). ...
    (Linux-Kernel)
  • Re: [PATCH] ncurses based config V2
    ... Fixed segfaults in help window. ... Removed the instructions window, made the instructions appear as a button ... Added hot keys support. ... ESC prefix, I don't know). ...
    (Linux-Kernel)
  • Re: Menu Not Available from Keyboard
    ... The Alt-menu keys all work as expected. ... which is used for the client area of the docking window. ... Q117500 and my accelerator keys now work when one of the child dialog box ... > "Jonathan Wood" wrote in message ...
    (microsoft.public.vc.mfc)
  • Re: SSH with PuTTY - Home/End keys dont work
    ... all is fine; the Home and End keys work. ... However, when I login from a Windows machine using the PuTTY client, ... Use tic -x scoansi-dm-cjc.ti to compile it into your terminfo database ... Close window on exit: ...
    (alt.os.linux.suse)
  • Re: [PATCH] ncurses based config V2
    ... Fixed segfaults in help window. ... Added hot keys support. ... of readability. ... ESC prefix, I don't know). ...
    (Linux-Kernel)