📄 digitaldevice.h
字号:
/////////////////////////////////////////////////////////
// 数码式测量设备DigitalDevice封装类
// 版本:1.06
// 最后修改日期:2002.1.25
/////////////////////////////////////////////////////////
#if !defined(AFX_DIGITALDEVICE_H__1CFA7C26_1B47_4CCE_9D54_AC20EE425705__INCLUDED_)
#define AFX_DIGITALDEVICE_H__1CFA7C26_1B47_4CCE_9D54_AC20EE425705__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DigitalDevice.h : header file
//
//定义类中使用的字模的参数
#define FONT_MAXNUM 14 //字模中含有的字数
#define FONT_LENGTH 9 //字模中每个字的最大笔划数目
//下面两个宏定义了仪表的工作模式
#define DD_NUMBER 0 //要显示的是数值
#define DD_STRING 1 //要显示的是字符串
//下面两个宏定义仪表的显示模式
#define DD_LED 0 //要显示的是LED数字仪表
#define DD_TEXT 1 //要显示的是文字
//下面的宏定义了仪表的当前状态
#define DD_TEST 0 //仪表的自检状态,数字自动变化
#define DD_WORK 1 //仪表的工作状态,等待数值或字符串的变化
#define DD_SHUTDOWN 2 //仪表的关闭状态,不作任何动作
/////////////////////////////////////////////////////////////////////////////
// DigitalDevice window
class DigitalDevice : public CStatic
{
// Construction
public:
DigitalDevice(CWnd *parent);
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(DigitalDevice)
//}}AFX_VIRTUAL
// Implementation
public:
void DD_SetDisMode(UINT mode);
void DD_SetBdColor(COLORREF lightcolor, COLORREF darkcolor);
void DD_SetBkColor(COLORREF color);
void DD_SetBorderWidth(UINT width);
void DD_SetBorderStyle(UINT left, UINT top, UINT right, UINT bottom);
void DD_SetBits(UINT bits);
void DD_SetTextDarkColor(COLORREF color);
void DD_SetTextLightColor(COLORREF color);
void DD_SetCurrentNumber(double num);
void DD_SetStatus(UINT status);
void DD_SetCurrentString(CString string);
void SetCurrentNumber(double num);
void DD_SetWorkMode(UINT mode);
void DD_SetTextPos(int x, int y);
void DD_SetTextStyle(UINT charwidth, UINT charheight, UINT charthick, UINT charspace);
void DD_Update(void);
void DD_SetSize(UINT width, UINT height);
void DD_MoveWindow(int x, int y);
virtual ~DigitalDevice();
// Generated message map functions
protected:
//{{AFX_MSG(DigitalDevice)
afx_msg void OnPaint();
afx_msg void OnTimer(UINT nIDEvent);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
void DrawText();
void ShowFont(CDC *pDC, CRect rect, int XSize, int YSize, COLORREF TextColor, COLORREF BKColor, CString strVal);
UINT DD_Width; //仪表的宽度
UINT DD_Height; //仪表的高度
UINT DD_Status; //仪表的当前状态
UINT DD_WorkMode; //仪表的工作方式(显示数字还是字串)
UINT DD_DisMode; //仪表的显示方式(显示文字还是当作LED仪表)
UINT DD_Bits; //仪表的输出位数
UINT DD_Font[FONT_MAXNUM][FONT_LENGTH]; //内部使用的字模数组
double DD_CurrentNumber; //当前要显示的数字
COLORREF DD_BkColor; //仪表的背景颜色
CPoint DD_TextPos; //文字相对于仪表左上角的坐标
CString DD_CurrentString; //仪表当前要显示的字串
UINT DD_BorderWidth; //边界的宽度
UINT DD_BorderBottom; //表示是否画底部的边界
UINT DD_BorderRight; //表示是否画右边的边界
UINT DD_BorderTop; //表示是否画顶部的边界
UINT DD_BorderLeft; //表示是否画左边的边界
COLORREF DD_BdLightColor; //边界的亮边(右和下)颜色
COLORREF DD_BdDarkColor; //边界的暗边(左和上)颜色
UINT DD_CharWidth; //字体宽度
UINT DD_CharHeight; //字体高度
UINT DD_CharThick; //字体笔划的粗细
UINT DD_CharSpace; //文字之间的水平距离
COLORREF DD_TextDarkColor; //字体亮颜色
COLORREF DD_TextLightColor; //字体暗颜色
void PutChar(CDC *dc, char c, int pos_x, int pos_y, COLORREF color); //在dc上的指定位置绘制指定字符
void DrawFace(void); //该函数绘制仪表的界面
double GetMaxNumber(); //该函数获取仪表所能显示的最大数字
COLORREF GetNextColor(COLORREF current_color, int delta);
COLORREF GetNextColor(COLORREF color, double ratio);
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DIGITALDEVICE_H__1CFA7C26_1B47_4CCE_9D54_AC20EE425705__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -