Click here to Skip to main content
12,550,593 members (42,082 online)
Click here to Skip to main content
Articles » Multimedia » GDI+ » Applications » Downloads


59 bookmarked

GDI+ Plot ActiveX Control

, 5 Sep 2013 LGPL3
GDI+ 2D plot ActiveX control
// (C) Copyright 2008 - 2009 by CCTEC ENGINEERING CO., LTD
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted, 
// provided that the above copyright notice appears in all copies and 
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting 
// documentation.

#if !defined(AFX_GDIPLUSPLOTCTL_H__80277A03_B015_441F_8E85_B50C79EE828B__INCLUDED_)
#define AFX_GDIPLUSPLOTCTL_H__80277A03_B015_441F_8E85_B50C79EE828B__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

// GDIPlusPlotCtl.h : Declaration of the CGDIPlusPlotCtrl ActiveX Control class.

// CGDIPlusPlotCtrl : See GDIPlusPlotCtl.cpp for implementation.

#include <list>     // for std::list template ʹ��˫������ģ��

// point abstruct data type �������������
typedef struct point_s 
    double	x;
    double	y;
} point_t;

// element abstruct data type ���������������
typedef struct element_s 
	short				index;
	Gdiplus::Color		color;
	BOOL				visible;
	std::list<point_t>	pointlist;
} element_t;

class CGDIPlusPlotCtrl : public COleControl

// Constructor

// Overrides
	// ClassWizard generated virtual function overrides
	virtual void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid);
	virtual void DoPropExchange(CPropExchange* pPX);
	virtual void OnResetState();

// Implementation

	DECLARE_OLECREATE_EX(CGDIPlusPlotCtrl)    // Class factory and guid
	DECLARE_OLETYPELIB(CGDIPlusPlotCtrl)      // GetTypeInfo
	DECLARE_PROPPAGEIDS(CGDIPlusPlotCtrl)     // Property page IDs
	DECLARE_OLECTLTYPE(CGDIPlusPlotCtrl)		// Type name and misc status

	// Subclassed control support
	BOOL IsSubclassedControl();
	LRESULT OnOcmCommand(WPARAM wParam, LPARAM lParam);

// Message maps
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);

// Dispatch maps
	afx_msg BSTR GetCaption();
	afx_msg void SetCaption(LPCTSTR lpszNewValue);
	afx_msg BOOL GetXTime();
	afx_msg void SetXTime(BOOL bNewValue);
	afx_msg BSTR GetXLabel();
	afx_msg void SetXLabel(LPCTSTR lpszNewValue);
	afx_msg BSTR GetYLabel();
	afx_msg void SetYLabel(LPCTSTR lpszNewValue);
	afx_msg short GetInterval();
	afx_msg void SetInterval(short nNewValue);
	afx_msg BSTR GetAnnolabel();
	afx_msg void SetAnnolabel(LPCTSTR lpszNewValue);
	afx_msg BOOL GetXTrack();
	afx_msg void SetXTrack(BOOL bNewValue);
	afx_msg void PlotXY(double xValue, double yValue, short index);
	afx_msg void SetRange(double xMin, double xMax, double yMin, double yMax);
	afx_msg void PlotY(double newValue, short index);
	afx_msg void ClearGraph();
	afx_msg void AddElement(short color);
	afx_msg void IsElementVisible(short index, BOOL visible);
	afx_msg void SetXCursorPos(double xValue);
	afx_msg double GetQuadrantWidth();

// Event maps

// Dispatch and event IDs
	enum {
	dispidCaption = 1L,
	dispidXTime = 2L,
	dispidXLabel = 3L,
	dispidYLabel = 4L,
	dispidInterval = 5L,
	dispidAnnolabel = 6L,
	dispidXTrack = 7L,
	dispidPlotXY = 8L,
	dispidSetRange = 9L,
	dispidPlotY = 10L,
	dispidClearGraph = 11L,
	dispidAddElement = 12L,
	dispidIsElementVisible = 13L,
	dispidSetXCursorPos = 14L,
	dispidGetQuadrantWidth = 15L,

// Attribute ����
	ULONG_PTR						m_gdiplusToken;
	Gdiplus::Graphics				*m_MemoryGraphics;
	BOOL							m_xTime, m_xTrack;
	BSTR							m_caption, m_xLabel, m_yLabel, m_annolabel;
	int								m_xMin, m_xMax, m_yMin, m_yMax, m_QuadrantX, m_QuadrantY, 
									m_QuadrantWidth, m_QuadrantHeight, m_CursorX, m_TrackX, 
	short							m_ElementCount;
	std::list<element_t>			m_ElementList;

// Operation ����
	void m_DrawCaption(CRect rcBounds);
	void m_DrawXLabel(CRect rcBounds);
	void m_DrawYLabel(CRect rcBounds);
	void m_DrawQuadrant(CRect rcBounds);
    void m_DrawXScale();
    void m_DrawYScale();
    void m_DrawPlotXY();
    void m_DrawCursor(int x);
    void m_DrawXTimeCursor();
	void m_DrawCurve(short index);
    int m_GetPointY(int PointX, std::list<point_t> pointlist);

// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_GDIPLUSPLOTCTL_H__80277A03_B015_441F_8E85_B50C79EE828B__INCLUDED)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


About the Author

Leslie Zhai
China China
An individual human existence should be like a river - small at first, narrowly contained within its banks, and rushing passionately past boulders and over waterfalls. Gradually the river grows wider, the banks recede, the waters flow more quietly, and in the end, without any visible break, they become merged in the sea, and painlessly lose their individual being.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161021.1 | Last Updated 6 Sep 2013
Article Copyright 2009 by Leslie Zhai
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid