How to override F10 Key default behaviour
James P. Kelleghan -- jpk01@tag.acnet.net
Tuesday, January 07, 1997
Environment: Win 95, MSVC 4.0
Hi,
In attempting to port an MS DOS based app. to Win 95 that uses the function
keys to display different dialogs, I have found that I am unable to
override the default behavior for the F10 key under Windows (Default
behavior is to set the focus to the menu bar).
The F10 key generates a WM_SYSKEYDOWN message (with a scan code of 0X44) to
my app. using Spy++, but when attempting to override the default behavior
using OnSysKeyDown(), OnKeyDown() or OnSysCommand() in my app's. View
and/or MainFrame classes, I find that the message is completely ignored by
the framework.
Can anyone give me a suggestion on how to override this behavior so that
pressing the F10 will call my dialog but selecting it with the mouse will
behave normally?
James P. Kelleghan
jkelleghan@usa.net
jpk01@tag.acnet.net
103245,1031@compuserve.com
Dulepov Dmitry -- dima@ssm6000.samsung.ru
Wednesday, January 08, 1997
[Mini-digest: 4 responses]
[Mailer: "Groupware E-Mail". Version 1.02.051]
Use PreTranslateMessage and look for key you need. Then convert it to appropriate message. Also you may try to use accelerators, this may work too.
Dmitry A. Dulepov
Samsung Electronics Co., Ltd.
Russian Research Center
Phone: +7 (095) 213-9207
Fax: +7 (095) 213-9196
E-mail: dima@src.samsung.ru
====================================
-----------------------------
> [From: James P. Kelleghan
> [Address: jpk01@tag.acnet.net
> [To: Dmitry A. Dulepov
> [Date: Wed Jan 08 11:49:14 1997
>Environment: Win 95, MSVC 4.0
>
>Hi,
>
>In attempting to port an MS DOS based app. to Win 95 that uses the function
>keys to display different dialogs, I have found that I am unable to
>override the default behavior for the F10 key under Windows (Default
>behavior is to set the focus to the menu bar).
>
>The F10 key generates a WM_SYSKEYDOWN message (with a scan code of 0X44) to
>my app. using Spy++, but when attempting to override the default behavior
>using OnSysKeyDown(), OnKeyDown() or OnSysCommand() in my app's. View
>and/or MainFrame classes, I find that the message is completely ignored by
>the framework.
>
>Can anyone give me a suggestion on how to override this behavior so that
>pressing the F10 will call my dialog but selecting it with the mouse will
>behave normally?
>
>
>James P. Kelleghan
>jkelleghan@usa.net
>jpk01@tag.acnet.net
>103245,1031@compuserve.com
-----From: "Julius Hamelberg"
You need to override OnSysKeyDown() in your view class but do _not_ call
the base class CView::OnSysKeyDown(nChar, nRepCnt, nFlags);
Example:
void CYourView::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
switch (nChar)
{
case VK_F10:
// Do your stuff here
return;
default:
break;
}
CView::OnSysKeyDown(nChar, nRepCnt, nFlags);
}
Works for me!
----------
From: Mfc-l@netcom.com
Sent: Wednesday, January 08, 1997 12:29 AM
Subject: How to override F10 Key default behaviou
Environment: Win 95, MSVC 4.0
Hi,
In attempting to port an MS DOS based app. to Win 95 that uses the function
keys to display different dialogs, I have found that I am unable to
override the default behavior for the F10 key under Windows (Default
behavior is to set the focus to the menu bar).
The F10 key generates a WM_SYSKEYDOWN message (with a scan code of 0X44) to
my app. using Spy++, but when attempting to override the default behavior
using OnSysKeyDown(), OnKeyDown() or OnSysCommand() in my app's. View
and/or MainFrame classes, I find that the message is completely ignored by
the framework.
Can anyone give me a suggestion on how to override this behavior so that
pressing the F10 will call my dialog but selecting it with the mouse will
behave normally?
James P. Kelleghan
jkelleghan@usa.net
jpk01@tag.acnet.net
103245,1031@compuserve.com
--------------- End of text item ---------------
-----From: hou@tfn.com (Bing Hou)
James,
You can use the API function HHOOK SetWindowsHookEx(int,
HOOKPROC, HINSTANCE, HTASK)
to install a task-wide(or system-wide if you perfer) keyboard hook handler.
Look into SDK document for descriptions of those two functions.
-Bing
______________________________ Reply Separator _________________________________
Subject: How to override F10 Key default behaviour
Author: "James P. Kelleghan" at Internet
Date: 1/7/97 6:48 PM
Environment: Win 95, MSVC 4.0
Hi,
In attempting to port an MS DOS based app. to Win 95 that uses the function
keys to display different dialogs, I have found that I am unable to
override the default behavior for the F10 key under Windows (Default
behavior is to set the focus to the menu bar).
The F10 key generates a WM_SYSKEYDOWN message (with a scan code of 0X44) to
my app. using Spy++, but when attempting to override the default behavior
using OnSysKeyDown(), OnKeyDown() or OnSysCommand() in my app's. View
and/or MainFrame classes, I find that the message is completely ignored by
the framework.
Can anyone give me a suggestion on how to override this behavior so that
pressing the F10 will call my dialog but selecting it with the mouse will
behave normally?
James P. Kelleghan
jkelleghan@usa.net
jpk01@tag.acnet.net
103245,1031@compuserve.com
-----From: "Swaminthan, Ravi"
Hi,
The F10 key is captured by the system for a default behaviour of
focusing into menu bar. In order to override the system behaviour, you
can override the PreTranslateMessage() function of your app and capture
the F10 key. PreTranslateMessage is called before the accelerator key
handling is done so that u can do some custom behaviour for system keys.
I have not tried it out but i think this should work..
Ravi
----------
From: owner-mfc-l[SMTP:owner-mfc-l@majordomo.netcom.com]
Sent: Tuesday, January 07, 1997 6:48 PM
To: mfc-l
Subject: How to override F10 Key default behaviour
Environment: Win 95, MSVC 4.0
Hi,
In attempting to port an MS DOS based app. to Win 95 that uses the
function
keys to display different dialogs, I have found that I am unable to
override the default behavior for the F10 key under Windows (Default
behavior is to set the focus to the menu bar).
The F10 key generates a WM_SYSKEYDOWN message (with a scan code of 0X44)
to
my app. using Spy++, but when attempting to override the default behavior
using OnSysKeyDown(), OnKeyDown() or OnSysCommand() in my app's. View
and/or MainFrame classes, I find that the message is completely ignored
by
the framework.
Can anyone give me a suggestion on how to override this behavior so that
pressing the F10 will call my dialog but selecting it with the mouse will
behave normally?
James P. Kelleghan
jkelleghan@usa.net
jpk01@tag.acnet.net
103245,1031@compuserve.com
| Вернуться в корень Архива
|