HOWTO: Disable the Mnemonic on a Disabled Static Text ControlID: Q66946
|
Disabling a static text control that contains a mnemonic does not prevent
the control from responding to that key. For more information on static
text controls with mnemonics, query in this Knowledge Base on the word
"mnemonic".
To keep a static text control from processing mnemonics, it must be
subclassed. When the control is disabled, WM_GETTEXT messages must be
intercepted and the subclass procedure should return an empty string in
response to the message.
When a static text control with a mnemonic is disabled using
EnableWindow(), it turns gray but it does not stop responding to the
mnemonic. This can cause problems because Windows processes the
mnemonic by setting the focus to the next nonstatic, enabled control.
It is necessary to resort to subclassing to prevent the static control
from processing the mnemonic. The subclass procedure should process
the WM_GETTEXT message as follows:
...
// Windows asks the control, hChild, for its text.
case WM_GETTEXT:
if (!IsWindowEnabled(hChild))
{
*(LPSTR)(lParam) = 0; // A null terminated empty string
return 0L;
}
break;
....
Additional query words: WIN16SDK
Keywords : kbCtrl kbNTOS kbStaticCtrl kbGrpUser kbWinOS
Version :
Platform :
Issue type : kbhowto
Last Reviewed: March 6, 1999