hardwarekeysampledlg.cpp

来自「... Samsung’s ARM 900 S3C2440 Specs. Tec」· C++ 代码 · 共 84 行

CPP
84
字号
// HardwareKeySampleDlg.cpp : implementation file
//

#include "stdafx.h"
#include "HardwareKeySample.h"
#include "HardwareKeySampleDlg.h"
#include "STUtil.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CHardwareKeySampleDlg dialog

CHardwareKeySampleDlg::CHardwareKeySampleDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CHardwareKeySampleDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CHardwareKeySampleDlg)
		// 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 CHardwareKeySampleDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CHardwareKeySampleDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CHardwareKeySampleDlg, CDialog)
	//{{AFX_MSG_MAP(CHardwareKeySampleDlg)
	ON_WM_CLOSE()
	ON_WM_KEYUP()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CHardwareKeySampleDlg message handlers

BOOL CHardwareKeySampleDlg::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

	CSTUtil su;
	for (int i=0xc1; i<=0xcf; i++) {
		su.RegisterHotKey(m_hWnd, i, i);
	}
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}



void CHardwareKeySampleDlg::OnClose() 
{
	for (int i=0xc1; i<=0xcf; i++) {
		UnregisterHotKey(m_hWnd, i);
	}
	
	CDialog::OnClose();
}

void CHardwareKeySampleDlg::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	CString strMessage;
	strMessage.Format(_T("Key is presses. Key id: %d"), nChar);
	AfxMessageBox(strMessage);
	
	CDialog::OnKeyUp(nChar, nRepCnt, nFlags);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?