#include #include // #begin.第1步.使用GDI+ #include using namespace Gdiplus; //#pragma comment(lib, "gdiplus.lib") // #end class CMyApp: public CWinApp { public: virtual BOOL InitInstance(); // #begin第2步.使用GDI+ private: Gdiplus::GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; // #end public: virtual int ExitInstance(); }; class CMainWindow : public CFrameWnd { public: CMainWindow(); protected: afx_msg void OnPaint(); DECLARE_MESSAGE_MAP(); public: int m_nLowwer; int m_nUpper; CString m_strVar; LONG m_lAspectN; LONG m_lAspectD; INT HorzRes; INT VertRes; CRect m_rect; //COLORREF m_clrCurrentLine; //COLORREF m_clrCurrentBack; //COLORREF m_clrCurrentFore; public: COLORREF m_clrFore; // 前景色 COLORREF m_clrLine; // 线色 COLORREF m_clrBack; // 背景色 COLORREF m_clrFill; // 填充色 LOGFONT m_logfont; // 字体 CString m_strLineType; // 线型 int m_nLineWidth; // 线宽 CString m_strCaption; // 静态文本 BOOL m_bVariant; // 是否是变量r BOOL m_bDynShow; // 是否动态显示 CString m_strDynShow; // 动态显示条件 BOOL m_bLocked; BOOL m_bAligned; // 用来等距排列的标志位 // 动态参数 COLORREF m_clrDynFore; // 前景色 CString m_strDynForeCon; COLORREF m_clrDynBack; CString m_strDynBackCon; COLORREF m_clrDynLine; CString m_strDynLineCon; BOOL m_bDynFore; BOOL m_bDynBack; BOOL m_bDynLine; int m_nFillMode; CString m_strHoriPos; CString m_strHoriSize; CString m_strVertiPos; CString m_strVertiSize; BOOL m_bVertiSize; BOOL m_bVertiPos; BOOL m_bHorizSize;//注意: 为真时 报警背景闪烁 BOOL m_bHorizPos; int m_nHorAlign; int m_nVerAlign; // 动态值 CRect m_rctCurrent; COLORREF m_clrCurrentFore; COLORREF m_clrCurrentBack; COLORREF m_clrCurrentLine; CString m_strCurrentCaption; BOOL m_bShow; float m_fCurrentValue; BOOL m_bShowtemp;//chn add 为了GIF,flasg,OCX的隐藏和显示 public: void InitCLR(); void Draw(CDC *pDC); void DrawFace(CDC *pDC); public: typedef struct ST_WATCHDIAL // 表盘属性; { float wd_fRadian; // 表盘张开的弧度; int wd_nTypeShow; // 显示类型;(0==居中,1==左轴,2==右轴); float wd_fMin; // 表盘范围最小值; float wd_fMax; // 表盘范围最大值; CString wd_strUnit; // 表盘量程单位; int wd_nRadius[3]; // 表盘内弧半径; int wd_nTable; // 表盘每段大刻度格子数(小刻度); int wd_nScale; // 表盘大刻度段数(); int wd_nIndicator; // 指针粗细; COLORREF wd_clIndicator; // 指针颜色; COLORREF wd_clBk; // 表盘背景色; COLORREF wd_clArc; // 表盘弧线色; COLORREF wd_clScale; // 表盘段色; COLORREF wd_clTable; // 表盘格子色; COLORREF wd_clRange; // 表盘量程值字体颜色; CFont wd_ftRange; // 表盘量程值字体; COLORREF wd_clUnit; // 表盘单位字体颜色; CFont wd_ftUnit; // 表盘单位字体; COLORREF wd_clInfo; // 表盘内容字体颜色; CFont wd_ftInfo; // 表盘内容字体; }; void DrawWatch( CDC *pDC, CRect &Wrect, float fMin, // 最小范围值; float fMax, // 最大范围值; const float &fValue, // 当前值; CString strUnit, // 量程单位; const float &fRadian, // 范围弧度大小; int nRadius[3], // 内弧半径; const int &nTable, // 大刻度数; const int &nScale // 小刻度数; ); };