屏蔽键盘上特定按键,其它键的屏蔽已经实现了,就只有这两个屏蔽不了,用的技术是hook,但好像对这两个键没有作用!不知道为什么?请高手帮忙!是否可以用其他方法实现

解决方案 »

  1.   

    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命令!
      

  2.   

    LRESULT WINAPI KeyboradProc(int nCode,WPARAM wParam,LPARAM lParam)
    {
    if(lParam==0x3b0001) return 1;// Disable F1
    ...
    }
      

  3.   

    zhuwenzheng(我是谁):这个方法好像对F1没有作用,对其他的键还行
      

  4.   

    zhuwenzheng(我是谁)
    我的程序如下: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键却屏蔽了!
      

  5.   

    你用SPY++看一下,按下F1  lParam是什么值,是否与0x3b0001相同
      

  6.   

    zhuwenzheng(我是谁) lParam中应该存放的是一个组合信息,而且这个信息对一个键在不同情况下应该是不一样的(我自己的理解),可以用lParam来判断是否按下F1键么?另外,我已经捕获到了F1键,并且return,但还是会执行之,代码如下: char szTemp1[256];
    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,没有继续往下执行,但还是会弹出帮助信息.
      

  7.   

    判断wparam没有用,按键包括键按下和弹起,用 wparam只能知道按的键的VK_CODE,而用lparam 就可以,他包括键的按下和弹起你用spy++看了吗?不可以吗?我的可以
      

  8.   

    哦,那我只能挨个取要屏蔽键的lParam么,但还是有其它键成功了的,
    还有怎样判断是按下还是弹起呢?哈哈,不好意思,
    spy++不会用,不知道怎么看
      

  9.   

    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. 
      

  10.   

    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. 
      

  11.   

    哦,我vc不熟请问怎样解析lParam 参数
      

  12.   

    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);
    }