⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test6dlg.cpp

📁 WINCE 5.0下矩阵键盘测试程序
💻 CPP
字号:
// test6Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "test6.h"
#include "test6Dlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
volatile IOPreg *v_pIOPRegs;
HANDLE	hKey;
/////////////////////////////////////////////////////////////////////////////
// CTest6Dlg dialog

CTest6Dlg::CTest6Dlg(CWnd* pParent /*=NULL*/)
	: CDialog(CTest6Dlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTest6Dlg)
	m_KeyVal = 0;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CTest6Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTest6Dlg)
	DDX_Text(pDX, IDC_EDIT1, m_KeyVal);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CTest6Dlg, CDialog)
	//{{AFX_MSG_MAP(CTest6Dlg)
	ON_WM_HELPINFO()
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTest6Dlg message handlers

BOOL CTest6Dlg::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
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CTest6Dlg::OnHelpInfo()
{
	// TODO: implement help here
	MessageBox(_T("Help"));
	
}

void CTest6Dlg::OnButton1() 
{
	// TODO: Add your control notification handler code here

}

void CTest6Dlg::OnButton2() 
{
	DWORD	KeyValue;
	DWORD	RecvBuf;
	BOOL		iRet;
	DWORD		iLen = 2;
	int		i;

	hKey = CreateFile(L"PAD1:",GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
	if(hKey == INVALID_HANDLE_VALUE)
	{
		MessageBox(_T("键盘打开失败"));
		return;	
	}

	for (i=0; i<10; i++)
	{
		RecvBuf = 0;
		iRet = ReadFile(hKey,&RecvBuf,iLen,&iLen,NULL);
	//	m_KeyVal = 
		if (iRet && (RecvBuf!= 0XFF)  )
		{
			//MessageBox(_T("KEY value is %x %x"),RecvBuf[0],RecvBuf[1]);
			m_KeyVal = RecvBuf;
			UpdateData(FALSE);
		}
		Sleep(500);
	}
}

void CTest6Dlg::OnButton3() 
{
	CloseHandle(hKey);
}

⌨️ 快捷键说明

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