📄 keydialog.cpp
字号:
// KeyDialog.cpp : implementation file
//
#include "stdafx.h"
#include "dvp.h"
#include "KeyDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CKeyDialog dialog
CKeyDialog::CKeyDialog(CWnd* pParent /*=NULL*/)
: CDialog(CKeyDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CKeyDialog)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CKeyDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CKeyDialog)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CKeyDialog, CDialog)
//{{AFX_MSG_MAP(CKeyDialog)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CKeyDialog message handlers
void CKeyDialog::OnCancel()
{
CDialog::OnCancel();
}
BOOL CKeyDialog::OnInitDialog()
{
CDialog::OnInitDialog();
//设置矩阵键盘显示
m_Keys = new LampArray(this);
m_Keys->LA_SetArraySize(4,4);
m_Keys->LA_SetSize(130,135);
m_Keys->LA_SetLampSpace(13,15);
m_Keys->LA_SetTextOffset(0,15);
m_Keys->SetWindowPos(NULL,20,40,1,100,SWP_NOSIZE);
m_Keys->LA_SetLampSize(15,15);
m_Keys->LA_SetLampStyle(LA_RECTANGLE);
m_Keys->LA_SetBkColor(0X0);
m_Keys->LA_SetLampDarkColor(0xff0011);
m_Keys->LA_SetText(" 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16");
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//处理命令
bool CKeyDialog::DealCmd(const unsigned char * cmd)
{
unsigned char data = cmd[3];
unsigned char tmp1 = 0x01;
unsigned char tmp2 = 0x10;
int col=-1,row=-1;
int i;
if(cmd[0] < 4)
return false;
for(i = 0 ; i < 16 ; i++)//把所有的按钮设置为蓝色
m_Keys->LA_SetLampStatus(i , 0);
//下位机返回的数据格式二进制形式为1000,0100表示为第4行第3列的按钮,这里得到行列值
for(i = 0 ; i < 4 ; i++)
{
if(tmp1 == (unsigned char)(data & tmp1))
col = i;
if(tmp2 == (unsigned char)(data & tmp2))
row = i;
tmp1 = tmp1 << 1;
tmp2 = tmp2 << 1;
}
m_Keys->LA_SetLampStatus(row + (col * 4) , 1); //设置按钮为红色
// m_Keys->LA_SetLampStatus((int)((data % 0x10) / 2) * 4 + (data / 0x10 / 2) - 1 , 1);
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -