📄 test.cpp
字号:
int nButtom=nScreenY*4/5;
int nLeft=nScreenX*3/10;
int nTop=nScreenY*3/8;
int nRight=nScreenX*5/8;
if(strOutputStatus[0]=='0')
theApp.memDC.DrawText("关",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
else
theApp.memDC.DrawText("开",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*5/12;
if(strOutputStatus[1]=='0')
theApp.memDC.DrawText("关",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
else
theApp.memDC.DrawText("开",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*11/24;
if(strOutputStatus[2]=='0')
theApp.memDC.DrawText("关",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
else
theApp.memDC.DrawText("开",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY/2;
if(strOutputStatus[3]=='0')
theApp.memDC.DrawText("关",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
else
theApp.memDC.DrawText("开",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
if(strOutputStatus[4]=='0')
theApp.memDC.DrawText("关",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
else
theApp.memDC.DrawText("开",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*7/12;
if(strOutputStatus[5]=='0')
theApp.memDC.DrawText("关",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
else
theApp.memDC.DrawText("开",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nLeft=nScreenX*11/20;
nTop=nScreenY*3/8;
if(strOutputStatus[6]=='0')
theApp.memDC.DrawText("关",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
else
theApp.memDC.DrawText("开",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*5/12;
if(strOutputStatus[7]=='0')
theApp.memDC.DrawText("关",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
else
theApp.memDC.DrawText("开",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*11/24;
if(strOutputStatus[8]=='0')
theApp.memDC.DrawText("关",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
else
theApp.memDC.DrawText("开",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY/2;
if(strOutputStatus[9]=='0')
theApp.memDC.DrawText("关",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
else
theApp.memDC.DrawText("开",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
if(strOutputStatus[10]=='0')
theApp.memDC.DrawText("关",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
else
theApp.memDC.DrawText("开",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*7/12;
if(strOutputStatus[11]=='0')
theApp.memDC.DrawText("关",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
else
theApp.memDC.DrawText("开",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
DrawScreen();
}
// 移动输出外设光标
void CTestCxp::ChangeCursorItem(UINT Index)
{
int nScreenX=theApp.nScreenX;
int nScreenY=theApp.nScreenY;
//虚函数并不调用父类的构造函数,故需显式的设置绘图环境
int nButtom=nScreenY*4/5;
int nLeft,nTop;
int nRight=nScreenX*5/8;
// 首先将所有"*"清空
for(int i=0;i<6;i++){
nLeft=nScreenX/4;
nTop=nScreenY*(i+9)/24;
theApp.memDC.DrawText(" ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nLeft=nScreenX/2;
theApp.memDC.DrawText(" ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
}
if(Index==0){
nLeft=nScreenX/4;
nTop=nScreenY*3/8;
theApp.memDC.DrawText("*",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
}
if((Index>0)&&(Index<6)){
nLeft=nScreenX/4;
nTop=nScreenY*(Index+9)/24;
theApp.memDC.DrawText("*",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
}
if(Index==6){
nLeft=nScreenX/2;
nTop=nScreenY*3/8;
theApp.memDC.DrawText("*",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
}
if((Index>6)&&(Index<=11)){
nLeft=nScreenX/2;
nTop=nScreenY*(Index+3)/24;
theApp.memDC.DrawText("*",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
}
DrawScreen();
}
// 改变输出外设状态
void CTestCxp::ChangeOutputStatus(UINT Index)
{
switch(Index){
case 0:
if(strOutputStatus[0]=='0')
strOutputStatus[0]='1';
else
strOutputStatus[0]='0';
break;
case 1:
if(strOutputStatus[1]=='0'){
strOutputStatus[1]='1';
} else {
strOutputStatus[1]='0';
}
break;
case 2:
if(strOutputStatus[2]=='0'){
strOutputStatus[2]='1';
} else {
strOutputStatus[2]='0';
}
break;
case 3:
if(strOutputStatus[3]=='0')
strOutputStatus[3]='1';
else
strOutputStatus[3]='0';
break;
case 4:
if(strOutputStatus[4]=='0')
strOutputStatus[4]='1';
else
strOutputStatus[4]='0';
break;
case 5:
if(strOutputStatus[5]=='0')
strOutputStatus[5]='1';
else
strOutputStatus[5]='0';
break;
case 6:
if(strOutputStatus[6]=='0')
strOutputStatus[6]='1';
else
strOutputStatus[6]='0';
break;
case 7:
if(strOutputStatus[7]=='0')
strOutputStatus[7]='1';
else
strOutputStatus[7]='0';
break;
case 8:
if(strOutputStatus[8]=='0')
strOutputStatus[8]='1';
else
strOutputStatus[8]='0';
break;
case 9:
if(strOutputStatus[9]=='0')
strOutputStatus[9]='1';
else
strOutputStatus[9]='0';
break;
case 10:
if(strOutputStatus[10]=='0')
strOutputStatus[10]='1';
else
strOutputStatus[10]='0';
break;
case 11:
if(strOutputStatus[11]=='0')
strOutputStatus[11]='1';
else
strOutputStatus[11]='0';
break;
}
DrawOutputStatus();
SendMessage(theApp.m_pMainWnd->m_hWnd,WM_OPTION_FINISH,CXP_OUTPUT_CHANGE,0);
}
// 设置缺省输出设备状态
void CTestCxp::DefineOutputStatus()
{
memset(strOutputStatus,0,14);
memset(strOutputStatus,'0',12);
strOutputStatus[RAIN_GREEN]='0';
strOutputStatus[RAIN_RED]='1';
strOutputStatus[INDICATION_GREEN]='0';
strOutputStatus[INDICATION_RED]='1';
strOutputStatus[AUTO_RAIL_OPEN]='0';
strOutputStatus[AUTO_RAIL_CLOSE]='1';
strOutputStatus[AMBER_DEVICE]='0';
}
// 获取测试设备
UINT CTestCxp::TestItem()
{
return nTestItem;
}
// 获取输出外设的状态
void CTestCxp::GetOutputStatus(char *pRetStr)
{
memmove(pRetStr,strOutputStatus,12);
}
UINT CTestKey::nStatus;
CTestKey::CTestKey()
{
}
// 处理按键
BOOL CTestKey::ProcessKeyboard(UINT nChar)
{
BOOL bLegalityFlag=FALSE;
switch(nStatus){
case SHOW_KEY_MENU:
bLegalityFlag=ProcessKey(nChar);
break;
}
if(CScreen::ProcessKeyboard(nChar))
bLegalityFlag=TRUE;
return bLegalityFlag;
}
BOOL CTestKey::ProcessKey(UINT nChar)
{
int nScreenX=theApp.nScreenX;
int nScreenY=theApp.nScreenY;
//虚函数并不调用父类的构造函数,故需显式的设置绘图环
int nLeft=nScreenX/3;
int nTop=nScreenY*13/24;
int nButtom=nScreenY*4/5;
int nRight=nScreenX*5/8;
theApp.memDC.DrawText(" ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*11/24;
switch(nChar){
case ZERO_KEY:
theApp.memDC.DrawText("0 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("0 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
case ONE_KEY:
theApp.memDC.DrawText("1 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("1 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
case TWO_KEY:
theApp.memDC.DrawText("2 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("2 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
case THREE_KEY:
theApp.memDC.DrawText("3 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("3 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
case FOUR_KEY:
theApp.memDC.DrawText("4 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("4 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
case FIVE_KEY:
theApp.memDC.DrawText("5 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("5 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
case SIX_KEY:
theApp.memDC.DrawText("6 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("6 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
case SEVEN_KEY:
theApp.memDC.DrawText("7 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("7 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
case EIGHT_KEY:
theApp.memDC.DrawText("8 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("8 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
case NINE_KEY:
theApp.memDC.DrawText("9 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("9 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
/* case START_KEY:
theApp.memDC.DrawText("A ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("上班 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
case END_KEY:
theApp.memDC.DrawText("B ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("下班 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
*/
case UP_KEY:
theApp.memDC.DrawText("C ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("上箭头 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
/* case GROUP_KEY:
theApp.memDC.DrawText("D ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("车队 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
*/
case MONTH_KEY:
theApp.memDC.DrawText("E ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("月票键",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
case FREE_KEY:
theApp.memDC.DrawText("F ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("免征键",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
case DOWN_KEY:
theApp.memDC.DrawText("H ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("下箭头 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
case REPEAT_PRINT_KEY:
theApp.memDC.DrawText("I ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("重打票 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
case TICKET_KEY:
theApp.memDC.DrawText("J ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("定额票键 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
case HAS_GO_KEY:
theApp.memDC.DrawText("K ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("车已走 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
/*
case FIND_KEY:
theApp.memDC.DrawText("L ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("查询键 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
*/
case CODING_KEY:
theApp.memDC.DrawText("M ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("编码切换键 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
// case ERROR_CARD_KEY:
// theApp.memDC.DrawText("N ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
// nTop=nScreenY*13/24;
// theApp.memDC.DrawText("备用键",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
// break;
case COME_KEY:
theApp.memDC.DrawText("O ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("备用键 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
case GO_KEY:
theApp.memDC.DrawText("P ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
nTop=nScreenY*13/24;
theApp.memDC.DrawText("备用键 ",CRect(nLeft,nTop,nRight,nButtom),DT_LEFT|DT_TOP);
break;
case FAST_KEY:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -