CWinApp::OnHelp afx_msg void OnHelp( );ResYou must add an ON_COMMAND( ID_HELP, OnHelp ) statement to your CWinApp class message map to enable this member function. Usually you will also add an accelerator-key entry for the F1 key. Enabling the F1 key is only a convention, not a requirement.If enabled, called by the framework when the user presses the F1 key.The default implementation of this message-handler function determines the Help context that corresponds to the current window, dialog box, or menu item and then calls WINHELP.EXE. If no context is currently available, the function uses the default context.Override this member function to set the Help context to something other than the window, dialog box, menu item, or toolbar button that currently has the focus. Call WinHelp with the desired Help context ID.CWinApp Overview | Class Members | Hierarchy Chart 故,屏蔽F1你可以转化为屏蔽ID_HELP命令!
search keyboardprocfrom msdn:lParam: [in] Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag. This parameter can be one or more of the following values. Value Description 0–15 Specifies the repeat count. The value is the number of times the keystroke is repeated as a result of the user's holding down the key. 16–23 Specifies the scan code. The value depends on the original equipment manufacturer (OEM). 24 Specifies whether the key is an extended key, such as a function key or a key on the numeric keypad. The value is 1 if the key is an extended key; otherwise, it is 0. 25–28 Reserved. 29 Specifies the context code. The value is 1 if the ALT key is down; otherwise, it is 0. 30 Specifies the previous key state. The value is 1 if the key is down before the message is sent; it is 0 if the key is up. 31 Specifies the transition state. The value is 0 if the key is being pressed and 1 if it is being released.
Keystroke Message Flags The lParam parameter of a keystroke message contains additional information about the keystroke that generated the message. This information includes the repeat count, the scan code, the extended-key flag, the context code, the previous key-state flag, and the transition-state flag. The following illustration shows the locations of these flags and values in the lParam parameter. An application can use the following values to manipulate the keystroke flags.Value Meaning KF_ALTDOWN Manipulates the ALT key flag, which indicated if the ALT key is pressed. KF_DLGMODE Manipulates the dialog mode flag, which indicates whether a dialog box is active. KF_EXTENDED Manipulates the extended key flag. KF_MENUMODE Manipulates the menu mode flag, which indicates whether a menu is active. KF_REPEAT Manipulates the repeat count. KF_UP Manipulates the transition state flag.
哦,我vc不熟请问怎样解析lParam 参数
BOOL CKkkDlg::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_F1) { MessageBox("Hello"); } return CDialog::PreTranslateMessage(pMsg); }
afx_msg void OnHelp( );ResYou must add an ON_COMMAND( ID_HELP, OnHelp ) statement to your CWinApp class message map to enable this member function. Usually you will also add an accelerator-key entry for the F1 key. Enabling the F1 key is only a convention, not a requirement.If enabled, called by the framework when the user presses the F1 key.The default implementation of this message-handler function determines the Help context that corresponds to the current window, dialog box, or menu item and then calls WINHELP.EXE. If no context is currently available, the function uses the default context.Override this member function to set the Help context to something other than the window, dialog box, menu item, or toolbar button that currently has the focus. Call WinHelp with the desired Help context ID.CWinApp Overview | Class Members | Hierarchy Chart
故,屏蔽F1你可以转化为屏蔽ID_HELP命令!
{
if(lParam==0x3b0001) return 1;// Disable F1
...
}
我的程序如下:LRESULT WINAPI KeyboradProc(int nCode,WPARAM wParam,LPARAM lParam)
{
if(lParam==0x3b0001) return 1;// Disable F1
....return CallNextHookEx (glhKeyboradHook, nCode, wParam, lParam);
}在98下就是不能屏蔽F1键,而F2键却屏蔽了!
sprintf(szTemp1,"xxx, i=%d",(int)wParam);
if ( (int)wParam == (int)VK_F1)
{
MessageBox(NULL, szTemp1,"xx", MB_OK);
return 1;
} if ( (int)wParam == 44)//print screen
{
MessageBox(NULL, szTemp1,"xx", MB_OK);
return 1;
}
MessageBox(NULL, "test","xxxx", MB_OK);当按下F1或Print Screen键时都执行title是xx的MessageBox,没有继续往下执行,但还是会弹出帮助信息.
还有怎样判断是按下还是弹起呢?哈哈,不好意思,
spy++不会用,不知道怎么看
[in] Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag. This parameter can be one or more of the following values. Value Description
0–15 Specifies the repeat count. The value is the number of times the keystroke is repeated as a result of the user's holding down the key.
16–23 Specifies the scan code. The value depends on the original equipment manufacturer (OEM).
24 Specifies whether the key is an extended key, such as a function key or a key on the numeric keypad. The value is 1 if the key is an extended key; otherwise, it is 0.
25–28 Reserved.
29 Specifies the context code. The value is 1 if the ALT key is down; otherwise, it is 0.
30 Specifies the previous key state. The value is 1 if the key is down before the message is sent; it is 0 if the key is up.
31 Specifies the transition state. The value is 0 if the key is being pressed and 1 if it is being released.
The lParam parameter of a keystroke message contains additional information about the keystroke that generated the message. This information includes the repeat count, the scan code, the extended-key flag, the context code, the previous key-state flag, and the transition-state flag. The following illustration shows the locations of these flags and values in the lParam parameter. An application can use the following values to manipulate the keystroke flags.Value Meaning
KF_ALTDOWN Manipulates the ALT key flag, which indicated if the ALT key is pressed.
KF_DLGMODE Manipulates the dialog mode flag, which indicates whether a dialog box is active.
KF_EXTENDED Manipulates the extended key flag.
KF_MENUMODE Manipulates the menu mode flag, which indicates whether a menu is active.
KF_REPEAT Manipulates the repeat count.
KF_UP Manipulates the transition state flag.
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_F1)
{
MessageBox("Hello");
}
return CDialog::PreTranslateMessage(pMsg);
}