Click here to Skip to main content
15,885,985 members
Articles / Containers / Virtual Machine

An extendable report editor

Rate me:
Please Sign up or sign in to vote.
5.00/5 (11 votes)
3 Sep 2008CPOL3 min read 41K   2K   35  
An extendable report editor. You can simply add your own controls without recompiling the program or writing annoying plug-ins.
// Canvas.h: interface for the CCanvas class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_CANVAS_H__31413FAA_DC0C_4694_AF72_F7B77FEA8316__INCLUDED_)
#define AFX_CANVAS_H__31413FAA_DC0C_4694_AF72_F7B77FEA8316__INCLUDED_

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

#include "common.h"
#include <OLECTL.H>

/**********
������ô��Ϊ�����еĻ�ͼ����һ������ľ�����Ļ��
��������ʾ������ͼ��ֻ�����������Ļ�ϵ�һ���֣�Ҳ
����һ��View,�������attached_dc��ô�Ͱ����DC����
��ǰ��View, �������attached_dc��ô��this->hdc����
��ǰ��view.
**********/

class CCanvas{
public:
    HWND hparent;
    HDC hdc;
    HBITMAP hbitmap,old_hbitmap;
    HPEN hpen,old_pen;
    HBRUSH hbrush,old_brush;
    HFONT hfont,old_font;
	int offx,offy;
	int left,top,width,height;
	bool is_attached_hdc;
public:
	int SetBrush(UINT style,COLORREF color,LONG hatch);
	int UpdateParent();
	int SetTransparentBkMode();
	int AttachDC(HDC hdc);
	COLORREF GetPixel(int x,int y);
	int SetStockFont(int fnObject);
	int SetFont(LOGFONT *logfont);
	int SetTextColor(COLORREF color);
	int SetTextBkColor(COLORREF color);
	int SetPen(int fnPenStyle,int nWidth,COLORREF crColor);
	int SetHatchBrush(int fnStyle,COLORREF clrref);
	int SetSolidBrush(COLORREF clrref);
	int TextOut(int x,int y,char *str);
	int TextOutF(int x,int y,char *szFormat, ...);
	int TextOutEx(int x,int y,RECT &r,char *str);
	int FillRect(int l,int t,int w,int h);
	int DrawRect(COLORREF color);
	int DrawRect(int l,int t,int w,int h,COLORREF color);
	int DrawRect(int l,int t,int w,int h);
	int LoadBitMap(DWORD bmp_id);
	int LineTo(int x,int y);
	int CCanvas::Ellipse(int l,int t,int r,int b);
	int Arc(int nLeftRect,int nTopRect,int nRightRect,int nBottomRect,int nXRadial1,int nYRadial1,int nXRadial2,int nYRadial2);
	int MoveTo(int x,int y);
	int DrawToScreen();
	int Clear();
	int StretchToDC(HDC hdc_des,int width,int height);
	int SaveBmp(char *fn);
	int SetX(int x);
	int SetY(int y);
	int DrawTextEx(char *str,RECT r,UINT dwDTFormat,LPDRAWTEXTPARAMS lpDTParams);
	int SetPixel(int x,int y,COLORREF color);
	int Copy(HDC hdc_src);
	int Paste(HDC hdc_des);
	int SetParent(HWND hp);
	int SetPos(int l,int t);
	int SetSize(int w,int h);
	int CreateCompatibleDC(HDC hdc);
    CCanvas();
    virtual ~CCanvas();
    int Init();
    int Destroy();
    int Copy(CCanvas *p);
    int Comp(CCanvas *p);
    int Print();
    int InitBasic();
};
/////////////////////////////////////////////
class CDiBMP{
public:
    BITMAPFILEHEADER * pbmfh ;
    int width;
    int height;
public:
	int DibLoadImage (PTSTR pstrFileName);
	int Paste(HDC hdc_des);
    CDiBMP();
    virtual ~CDiBMP();
    int Init();
    int Destroy();
    int InitBasic();
};
/////////////////////////////////////////////
//CoInitialize() and CoUninitialize() must 
//be called before use CJpeg
/////////////////////////////////////////////
class CJepg{
public:
    IStream * pStream;
    IPicture * pPicture;
	HGLOBAL hmem;
	HDC i_hdc;
public:
	int SetIDC(HDC hdc);
	int Draw(int x,int y);
	int Draw(int x,int y,int w,int h);
	int Draw(RECT r);
	int GetHeight();
	int GetWidth();
	int LoadFromFile(char *fn);
    CJepg();
    virtual ~CJepg();
    int Init();
    int Destroy();
    int InitBasic();
};
/////////////////////////////////////////////
#endif // !defined(AFX_CANVAS_H__31413FAA_DC0C_4694_AF72_F7B77FEA8316__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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
China China
26 years old, 2 years work experience.

Comments and Discussions