Board index » cppbuilder » Disable ALT and ALT+<letter>

Disable ALT and ALT+<letter>


2004-06-04 02:35:24 AM
cppbuilder20
Hi all,
Is there a way to prevent the ALT key from activating a form's menu bar
and is it also possible to disable ALT+<letter>menu shortcuts?
Thanks.
PS: I already posted this on the nativeapi group, probably not the right
place
 
 

Re:Disable ALT and ALT+<letter>

Hi,
I assume you want to do that for *all* applications. Not only for your
application.
If so, you'll probably have to use the SetWindowsHookEx Win32 API
function in order to hook keys before Windows passes them to
applications. And because you'll need to set a system-wide hook, you
must put your hook code in a dll.
Hope this helps.
Olivier
Patrick Rotsaert wrote:
Quote
Hi all,

Is there a way to prevent the ALT key from activating a form's menu bar
and is it also possible to disable ALT+<letter>menu shortcuts?

Thanks.

PS: I already posted this on the nativeapi group, probably not the right
place
 

Re:Disable ALT and ALT+<letter>

Hi Olivier,
No, I only want it for my own application, in fact only for the active
control.
I am writing a component, similar to THotKey (because I'm not satisfied
with THotKey). Controlling the behaviour of THotKey is not possible,
because it is just a wrapper around a Windows common control.
I managed to trap all the keys I need, even the ALT key (combined or
not), but the side effect of the ALT key is very annoying :-(
I already tried the trick with
SystemParametersInfo(SPI_SCREENSAVERRUNNING, ...), but it does not work
on NT or 2000.
Thanks,
Patrick.
Olivier Bertini wrote:
Quote
Hi,

I assume you want to do that for *all* applications. Not only for your
application.

If so, you'll probably have to use the SetWindowsHookEx Win32 API
function in order to hook keys before Windows passes them to
applications. And because you'll need to set a system-wide hook, you
must put your hook code in a dll.

Hope this helps.

Olivier

Patrick Rotsaert wrote:

>Hi all,
>
>Is there a way to prevent the ALT key from activating a form's menu bar
>and is it also possible to disable ALT+<letter>menu shortcuts?
>
>Thanks.
>
>PS: I already posted this on the nativeapi group, probably not the
>right place


 

{smallsort}

Re:Disable ALT and ALT+<letter>

Oh I see! I wrote a such component some years ago. I've sent it to you
by email. I think it should do the work for you. But if you want to
catch only one key and not a combination of two or more keys you'll
probably need to modify it a bit. If you want to prevent the single key
Alt to activate the menu, add a Key = 0 in the OnKeyUp event handler.
When used in combination with others keys this problem don't exist.
Regards,
Olivier Bertini
Patrick Rotsaert wrote:
Quote
Hi Olivier,

No, I only want it for my own application, in fact only for the active
control.
I am writing a component, similar to THotKey (because I'm not satisfied
with THotKey). Controlling the behaviour of THotKey is not possible,
because it is just a wrapper around a Windows common control.
I managed to trap all the keys I need, even the ALT key (combined or
not), but the side effect of the ALT key is very annoying :-(
I already tried the trick with
SystemParametersInfo(SPI_SCREENSAVERRUNNING, ...), but it does not work
on NT or 2000.

Thanks,
Patrick.

Olivier Bertini wrote:

>Hi,
>
>I assume you want to do that for *all* applications. Not only for your
>application.
>
>If so, you'll probably have to use the SetWindowsHookEx Win32 API
>function in order to hook keys before Windows passes them to
>applications. And because you'll need to set a system-wide hook, you
>must put your hook code in a dll.
>
>Hope this helps.
>
>Olivier
>
>Patrick Rotsaert wrote:
>
>>Hi all,
>>
>>Is there a way to prevent the ALT key from activating a form's menu bar
>>and is it also possible to disable ALT+<letter>menu shortcuts?
>>
>>Thanks.
>>
>>PS: I already posted this on the nativeapi group, probably not the
>>right place
>
>
>
 

Re:Disable ALT and ALT+<letter>

Thanks for the example. Your code is more or less the same as mine :-D
The instruction Key = 0 (in KeyUp as well as KeyDown), I already did,
but it is not enough. In your code I found the real hack that does the
trick: send a WM_LBUTTONDOWN to the control in the KeyDown event. It
works great!
Best,
Patrick.
Olivier Bertini wrote:
Quote
Oh I see! I wrote a such component some years ago. I've sent it to you
by email. I think it should do the work for you. But if you want to
catch only one key and not a combination of two or more keys you'll
probably need to modify it a bit. If you want to prevent the single key
Alt to activate the menu, add a Key = 0 in the OnKeyUp event handler.
When used in combination with others keys this problem don't exist.

Regards,
Olivier Bertini

Patrick Rotsaert wrote:

>Hi Olivier,
>
>No, I only want it for my own application, in fact only for the active
>control.
>I am writing a component, similar to THotKey (because I'm not
>satisfied with THotKey). Controlling the behaviour of THotKey is not
>possible, because it is just a wrapper around a Windows common control.
>I managed to trap all the keys I need, even the ALT key (combined or
>not), but the side effect of the ALT key is very annoying :-(
>I already tried the trick with
>SystemParametersInfo(SPI_SCREENSAVERRUNNING, ...), but it does not
>work on NT or 2000.
>
>Thanks,
>Patrick.
>
>Olivier Bertini wrote:
>
>>Hi,
>>
>>I assume you want to do that for *all* applications. Not only for
>>your application.
>>
>>If so, you'll probably have to use the SetWindowsHookEx Win32 API
>>function in order to hook keys before Windows passes them to
>>applications. And because you'll need to set a system-wide hook, you
>>must put your hook code in a dll.
>>
>>Hope this helps.
>>
>>Olivier
>>
>>Patrick Rotsaert wrote:
>>
>>>Hi all,
>>>
>>>Is there a way to prevent the ALT key from activating a form's menu bar
>>>and is it also possible to disable ALT+<letter>menu shortcuts?
>>>
>>>Thanks.
>>>
>>>PS: I already posted this on the nativeapi group, probably not the
>>>right place
>>
>>
>>
>>