📄 mxa_mep_small.cpp
字号:
// MXA_MEP_SMALL.cpp : implementation file
//
#include "stdafx.h"
#include "HMIcan_usb.h"
#include "MXA_MEP_SMALL.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMXA_MEP_SMALL dialog
CMXA_MEP_SMALL::CMXA_MEP_SMALL(CWnd* pParent /*=NULL*/)
: CDialog(CMXA_MEP_SMALL::IDD, pParent)
{
//{{AFX_DATA_INIT(CMXA_MEP_SMALL)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CMXA_MEP_SMALL::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMXA_MEP_SMALL)
DDX_Control(pDX, IDC_STATIC_TIP_CANCEL, m_tip_CANCEL);
DDX_Control(pDX, IDC_STATIC_TIP_ENTER, m_tip_ENTER);
DDX_Control(pDX, IDC_STATIC_TIP_SORS, m_tip_SORS);
DDX_Control(pDX, IDC_STATIC_TIP_AORB, m_tip_AORB);
DDX_Control(pDX, IDC_DG1, m_Dg1);
DDX_Control(pDX, IDC_DG2, m_Dg2);
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMXA_MEP_SMALL, CDialog)
//{{AFX_MSG_MAP(CMXA_MEP_SMALL)
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMXA_MEP_SMALL message handlers
BOOL CMXA_MEP_SMALL::PreTranslateMessage(MSG* pMsg)
{
//下移动
if(pMsg->message==WM_KEYDOWN && (pMsg->wParam==VK_DOWN))
{
index++;
if(index==4) index=0;
if(index==0)
{
m_static_AORB.SetFocus();
m_static_AORB.bkColor( bk1 );
m_static_CANCEL.bkColor( bk );
m_tip_AORB.ShowWindow(SW_SHOW);
m_tip_CANCEL.ShowWindow(SW_HIDE);
return TRUE;
}
if(index==1)
{
m_static_1.SetFocus();
m_static_1.bkColor( bk1 );
m_static_AORB.bkColor( bk );
m_tip_SORS.ShowWindow(SW_SHOW);
m_tip_AORB.ShowWindow(SW_HIDE);
return TRUE;
}
if(index==2)
{
m_static_ENTER.SetFocus();
m_static_ENTER.bkColor( bk1 );
m_static_1.bkColor( bk );
m_tip_ENTER.ShowWindow(SW_SHOW);
m_tip_SORS.ShowWindow(SW_HIDE);
return TRUE;
}
if(index==3)
{
m_static_CANCEL.SetFocus();
m_static_CANCEL.bkColor( bk1 );
m_static_ENTER.bkColor( bk );
m_tip_CANCEL.ShowWindow(SW_SHOW);
m_tip_ENTER.ShowWindow(SW_HIDE);
return TRUE;
}
}
//上移动
if(pMsg->message==WM_KEYDOWN && (pMsg->wParam==VK_UP))
{
index--;
if(index<0) index=3;
if(index==0)
{
m_static_AORB.SetFocus();
m_static_AORB.bkColor( bk1 );
m_static_1.bkColor( bk );
m_tip_AORB.ShowWindow(SW_SHOW);
m_tip_SORS.ShowWindow(SW_HIDE);
return TRUE;
}
if(index==1)
{
m_static_1.SetFocus();
m_static_1.bkColor( bk1 );
m_static_ENTER.bkColor( bk );
m_tip_SORS.ShowWindow(SW_SHOW);
m_tip_ENTER.ShowWindow(SW_HIDE);
return TRUE;
}
if(index==2)
{
m_static_ENTER.SetFocus();
m_static_ENTER.bkColor( bk1 );
m_static_CANCEL.bkColor( bk );
m_tip_ENTER.ShowWindow(SW_SHOW);
m_tip_CANCEL.ShowWindow(SW_HIDE);
return TRUE;
}
if(index==3)
{
m_static_CANCEL.SetFocus();
m_static_CANCEL.bkColor( bk1 );
m_static_AORB.bkColor( bk );
m_tip_CANCEL.ShowWindow(SW_SHOW);
m_tip_AORB.ShowWindow(SW_HIDE);
return TRUE;
}
}
//左右移动
if(pMsg->message==WM_KEYDOWN && (pMsg->wParam==VK_LEFT)||
pMsg->message==WM_KEYDOWN && (pMsg->wParam==VK_RIGHT))
{
if(CMXA_MEP_SMALL::GetFocus() == GetDlgItem(IDC_STATIC_AORB))
{
CString temp1;
m_static_AORB.GetWindowText(temp1);
if(temp1=="A")
m_static_AORB.SetWindowText("B");
else
m_static_AORB.SetWindowText("A");
m_static_AORB.RedrawWindow();
return TRUE;
}
if(CMXA_MEP_SMALL::GetFocus() == GetDlgItem(IDC_STATIC_STARORSTOP))
{
CString temp1;
m_static_1.GetWindowText(temp1);
if(temp1=="启动")
{
m_static_1.SetWindowText("停止");
m_Dg1.SetLed(CLed::LED_COLOR_RED,0,65);//65是方形模式
}
else
{
m_static_1.SetWindowText("启动");
m_Dg1.SetLed(CLed::LED_COLOR_GREEN,0,65);//65是方形模式
}
m_static_1.RedrawWindow();
return TRUE;
}
}
//响应回车键
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_RETURN)
{
if(CMXA_MEP_SMALL::GetFocus() == GetDlgItem(IDC_STATIC_ENTER))
{
// return TRUE;
}
else if(CMXA_MEP_SMALL::GetFocus() == GetDlgItem(IDC_STATIC_CANCEL))
{
}
else //除了焦点在确定和取消外的情况
{
index=2;
m_static_ENTER.SetFocus();
m_static_ENTER.bkColor( bk1 );
m_static_AORB.bkColor( bk );
m_static_1.bkColor( bk );
m_static_CANCEL.bkColor( bk );
m_tip_ENTER.ShowWindow(SW_SHOW);
m_tip_AORB.ShowWindow(SW_HIDE);
m_tip_SORS.ShowWindow(SW_HIDE);
m_tip_CANCEL.ShowWindow(SW_HIDE);
return TRUE;
}
}
//响应ESCAPE键
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_ESCAPE)
{
if(CMXA_MEP_SMALL::GetFocus() == GetDlgItem(IDC_STATIC_CANCEL))
{
// return TRUE;
}
else //除了焦点在确定和取消外的情况
{
index=3;
m_static_CANCEL.SetFocus();
m_static_CANCEL.bkColor( bk1 );
m_static_AORB.bkColor( bk );
m_static_1.bkColor( bk );
m_static_ENTER.bkColor( bk );
m_tip_CANCEL.ShowWindow(SW_SHOW);
m_tip_AORB.ShowWindow(SW_HIDE);
m_tip_SORS.ShowWindow(SW_HIDE);
m_tip_ENTER.ShowWindow(SW_HIDE);
return TRUE;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
HBRUSH CMXA_MEP_SMALL::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (pWnd == this)
{
return m_brBk;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
BOOL CMXA_MEP_SMALL::OnInitDialog()
{
CDialog::OnInitDialog();
//设置背景
m_bmpBg.LoadBitmap(IDB_BITMAP_MXA_MEP_BorS);
m_brBk.CreatePatternBrush(&m_bmpBg);
m_bmpBg.DeleteObject();
m_bmp.LoadBitmap(IDB_BITMAP_);
//字体设置
lstrcpy((LPSTR)logfont.lfFaceName,(LPSTR)"Arial bold");
logfont.lfWeight=800;
logfont.lfWidth=8;
logfont.lfHeight=16;
logfont.lfEscapement=0;
logfont.lfUnderline=FALSE;
logfont.lfItalic=FALSE;
logfont.lfStrikeOut=FALSE;
logfont.lfCharSet=GB2312_CHARSET;
lstrcpy((LPSTR)logfont1.lfFaceName,(LPSTR)"Arial bold");
logfont1.lfWeight=800;
logfont1.lfWidth=8;
logfont1.lfHeight=20;
logfont1.lfEscapement=0;
logfont1.lfUnderline=FALSE;
logfont1.lfItalic=FALSE;
logfont1.lfStrikeOut=FALSE;
logfont1.lfCharSet=GB2312_CHARSET;
//静态框,编辑框颜色,背景设置
bk = RGB(0, 0, 110);
bk1 = RGB(255, 255, 0);
tx = RGB(0, 255, 255);
tx1 = RGB(255, 0, 255);
//设置静态文本
m_static_1.SubclassDlgItem( IDC_STATIC_STARORSTOP, this );
m_static_1.bkColor( bk );
m_static_1.textColor( tx );
m_static_1.setFont(&logfont );
m_static_2.SubclassDlgItem( IDC_STATIC1, this );
m_static_2.bkColor( bk );
m_static_2.textColor( tx );
m_static_2.setFont(&logfont );
m_static_3.SubclassDlgItem( IDC_STATIC2, this );
m_static_3.bkColor( bk );
m_static_3.textColor( tx );
m_static_3.setFont(&logfont );
m_static_ENTER.SubclassDlgItem( IDC_STATIC_ENTER, this );
m_static_ENTER.bkColor( bk );
m_static_ENTER.textColor( tx1 );
m_static_ENTER.setFont(&logfont1 );
m_static_CANCEL.SubclassDlgItem( IDC_STATIC_CANCEL, this );
m_static_CANCEL.bkColor( bk );
m_static_CANCEL.textColor( tx1 );
m_static_CANCEL.setFont(&logfont1 );
m_static_AORB.SubclassDlgItem( IDC_STATIC_AORB, this );
m_static_AORB.bkColor( bk1 );
m_static_AORB.textColor( tx1 );
m_static_AORB.setFont(&logfont1 );
m_static_NUM.SubclassDlgItem( IDC_STATIC_NUM, this );
m_static_NUM.bkColor( bk );
m_static_NUM.textColor( tx1 );
m_static_NUM.setFont(&logfont1 );
//为上下按键做准备
index=0;
//显示操作项
m_tip_AORB.ShowWindow(SW_SHOW);
//亮灯
// m_Dg1.SetLed(CLed::LED_COLOR_GREEN,0,65);//65是方形模式
m_Dg2.SetLed(CLed::LED_COLOR_GREEN,0,65);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -