📄 keybdhookdemodlg.cpp
字号:
// KeybdHookDemoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "KeybdHookDemo.h"
#include "KeybdHookDemoDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CKeybdHookDemoDlg dialog
typedef BOOL (CALLBACK *instkbhook)();
instkbhook InHook, UnHook, InHook2, UnHook2;
CKeybdHookDemoDlg::CKeybdHookDemoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CKeybdHookDemoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CKeybdHookDemoDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CKeybdHookDemoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CKeybdHookDemoDlg)
DDX_Control(pDX, IDC_CHECK2, m_check2);
DDX_Control(pDX, IDC_CHECK1, m_check1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CKeybdHookDemoDlg, CDialog)
//{{AFX_MSG_MAP(CKeybdHookDemoDlg)
ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
ON_BN_CLICKED(IDC_CHECK2, OnCheck2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CKeybdHookDemoDlg message handlers
BOOL CKeybdHookDemoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization here
static HINSTANCE hinstDLL;
if(hinstDLL=LoadLibrary(L"KeybdHook_CE.dll"))
{
InHook = (instkbhook)GetProcAddress(hinstDLL, L"InstallHook");
UnHook = (instkbhook)GetProcAddress(hinstDLL, L"UnHook");
InHook2 = (instkbhook)GetProcAddress(hinstDLL, L"InstallHook2");
UnHook2 = (instkbhook)GetProcAddress(hinstDLL, L"UnHook2");
}
else
{
MessageBox(L"找不到文件MyKbdHook_CE.dll");
OnCancel();
}
return TRUE; // return TRUE unless you set the focus to a control
}
void CKeybdHookDemoDlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void CKeybdHookDemoDlg::OnCheck1()
{
// TODO: Add your control notification handler code here
if(m_check1.GetCheck())
InHook();
else
UnHook();
}
void CKeybdHookDemoDlg::OnCheck2()
{
// TODO: Add your control notification handler code here
if(m_check2.GetCheck())
InHook2();
else
UnHook2();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -