MFC masking Windows keys

Source: Internet
Author: User

LRESULT CALLBACK lowlevelkeyboardporc (int ncode,wparam wparam,lparam LPARAM)//Real implementation method of shielding keys
{
BOOL featkeystrole = FALSE;
if (NCode = = hc_action)
{
Switch (WParam)
{
Case WM_KEYDOWN:
Case WM_SYSKEYDOWN:
Case WM_KEYUP:
Case WM_SYSKEYUP:
{
Pkbdllhookstruct p = (pkbdllhookstruct) LParam;

if (P->vkcode = = Vk_lwin | | p->vkcode = = vk_rwin)//
{
Featkeystrole = TRUE;
}

Tab + Alt
/* ((P->vkcode = = Vk_tab) && ((P->flags & llkhf_altdown)! = 0))
ESC + Alt
|| ((P->vkcode = = Vk_escape) && ((P->flags & llkhf_altdown)! = 0))
ESC + Ctrl
|| ((P->vkcode = = Vk_escape) && ((Getkeystate (Vk_control) & 0x8000)! = 0))
Ctrl + Space
|| (((Getkeystate (Vk_control) & 0x8000)! = 0) && (p->vkcode = = Vk_space));
*/


}
Break
}
}
Return (Featkeystrole?1:callnexthookex (Null,ncode,wparam,lparam));
}

BOOL Cxxxdlg::installhook (void)
{
HInstance Hins=afxgetinstancehandle ();
Hook = SetWindowsHookEx (Wh_keyboard_ll, (HOOKPROC) lowlevelkeyboardporc,hins,0);
Return (BOOL) Hook;
}

BOOL Cxxxdlg::oninitdialog ()

{

The previous code system defaults,

SetWindowPos (&wndtopmost,0,0,0,0,swp_nomove| swp_nosize);//front-end display after full screen
HWND hwnd =:: FindWindow (_t ("Shell_traywnd"), NULL);//Cancel taskbar, Start menu
HWND Hbutton =::findwindow (NULL, _t ("Start"));//Cancel Start menu, not successful under XP
if (hwnd&& Hbutton)
{
static BOOL bShow = FALSE;
:: ShowWindow (HWnd, sw_hide);
:: ShowWindow (Hbutton,sw_hide);
}

Installhook ();//Load Hook

return TRUE;

}

Unloading

UnhookWindowsHookEx (G_HHKLOWLEVEL,KYBD);//This parameter is not correct

http://blog.csdn.net/eplanet/article/details/1789941

MFC masking Windows keys

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.