⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 createfromdcview.cpp

📁 主要介绍vc++6.0的编程过程
💻 CPP
字号:
// CreateFromDCView.cpp : implementation of the CCreateFromDCView class
//

#include "stdafx.h"
#include "CreateFromDC.h"

#include "CreateFromDCDoc.h"
#include "CreateFromDCView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CCreateFromDCView

IMPLEMENT_DYNCREATE(CCreateFromDCView, CView)

BEGIN_MESSAGE_MAP(CCreateFromDCView, CView)
	//{{AFX_MSG_MAP(CCreateFromDCView)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCreateFromDCView construction/destruction

CCreateFromDCView::CCreateFromDCView()
{

	m_bSaved = FALSE;

}

CCreateFromDCView::~CCreateFromDCView()
{
}

BOOL CCreateFromDCView::PreCreateWindow(CREATESTRUCT& cs)
{
	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CCreateFromDCView drawing

void CCreateFromDCView::OnDraw(CDC* pDC)
{
	CCreateFromDCDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	RECT Rect;
	GetClientRect( &Rect );

	for( int y=0; y<Rect.bottom; y++ ){
		int nRed = ( 256 * y ) / Rect.bottom;
		int nGreen = ( 384 * y ) / Rect.bottom;
		int nBlue = ( 512 * y ) / Rect.bottom;
		CPen Pen( PS_SOLID, 1,
			RGB( nRed, nGreen, nBlue ) );
		CPen *pOldPen = pDC->SelectObject( &Pen );
		pDC->MoveTo( 0, y );
		pDC->LineTo( Rect.right, y );
		pDC->SelectObject( pOldPen );
		}

	if( !m_bSaved ){
		m_bSaved = TRUE;

		CImageObject *pImage = new CImageObject( pDC, 0, 0,
			Rect.right, Rect.bottom );

		if( pImage != NULL ){
			pImage->ChangeFormat( 8 );
			pImage->Save( "Test.gif" );
			delete pImage;
			}

		pImage = new CImageObject( pDC, 0, 0,
			Rect.right, Rect.bottom );
		if( pImage != NULL ){
			pImage->ChangeFormat( 24 );
			pImage->Save( "Test.jpg" );
			delete pImage;
			}

		}

}

/////////////////////////////////////////////////////////////////////////////
// CCreateFromDCView diagnostics

#ifdef _DEBUG
void CCreateFromDCView::AssertValid() const
{
	CView::AssertValid();
}

void CCreateFromDCView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CCreateFromDCDoc* CCreateFromDCView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCreateFromDCDoc)));
	return (CCreateFromDCDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CCreateFromDCView message handlers

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -