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

📄 imagepreviewstatic.cpp

📁 顾名思义
💻 CPP
字号:
/*
 *	$Header: /ResiEdit/ResiEdit/ResiEdit/ImagePreviewStatic.cpp 1     3/06/04 1:00a Administrator $
 *
 *	$History: ImagePreviewStatic.cpp $
 * 
 * *****************  Version 1  *****************
 * User: Administrator Date: 3/06/04    Time: 1:00a
 * Created in $/ResiEdit/ResiEdit/ResiEdit
 * Basic image preview working.
 */
#include "stdafx.h"
#include "ImagePreviewStatic.h"

// CImagePrieviewStatic
IMPLEMENT_DYNAMIC(CImagePreviewStatic, CStatic)

CImagePreviewStatic::CImagePreviewStatic() : CStatic()
{
	m_img = (Image *) NULL;
	m_graphics = (Graphics *) NULL;
}

CImagePreviewStatic::~CImagePreviewStatic()
{
	delete m_img;
	delete m_graphics;
}

BOOL CImagePreviewStatic::Create()
{
	if (GetSafeHwnd() != HWND(NULL))
	{
		m_img =	new	Image(m_wsFilename);
		m_graphics = new Graphics(GetSafeHwnd());
		return TRUE;
	}

	return FALSE;
}

void CImagePreviewStatic::SetFilename(LPCTSTR szFilename)
{
#ifndef	_UNICODE
	USES_CONVERSION;
#endif

	ASSERT(szFilename);
	ASSERT(AfxIsValidString(szFilename));

	TRACE("%s\n", szFilename);

#ifndef	_UNICODE
	wcscpy(m_wsFilename, A2W(szFilename));
#else
	wcscpy(m_wsFilename, szFilename);
#endif

	delete m_img;
	m_img =	new	Image(m_wsFilename,	FALSE);
	Invalidate();
}

void CImagePreviewStatic::DrawItem(LPDRAWITEMSTRUCT	/*lpDrawItemStruct*/)
{
	Unit  units;
	CRect rect;

	if (m_img != NULL)
	{
		GetClientRect(&rect);

		RectF destRect(REAL(rect.left),	REAL(rect.top),	REAL(rect.Width()),	REAL(rect.Height())),
			srcRect;
		m_img->GetBounds(&srcRect, &units);
		m_graphics->DrawImage(m_img, destRect, srcRect.X, srcRect.Y, srcRect.Width,	srcRect.Height,	UnitPixel, NULL);
	}
}

BEGIN_MESSAGE_MAP(CImagePreviewStatic, CStatic)
END_MESSAGE_MAP()

// CImagePrieviewStatic message handlers

⌨️ 快捷键说明

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