www.pudn.com > MyImageDB(imageobject).rar > ResultImageDlg.cpp


// ResultImageDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "myimagedb.h" 
#include "ResultImageDlg.h" 
#include "include\imageobject.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CResultImageDlg dialog 
 
 
CResultImageDlg::CResultImageDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CResultImageDlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CResultImageDlg) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
	isImageOk = FALSE; 
} 
 
void CResultImageDlg::SetImage(BYTE* indata, INT width, INT height) 
//ÉèÖÃͼÏñ£» 
{ 
	myImageobject.CreateDIBFromBits(width, height, indata); 
	CWnd* myMatrix = GetDlgItem(IDC_RESULTIMAGE); 
	CRect matrixrect; 
	myMatrix->GetClientRect(matrixrect); 
	myMatrix->ClientToScreen(matrixrect); 
	ScreenToClient(matrixrect); 
	 
	CClientDC dc(this); 
	 
	myImageobject.DrawToHdc( dc.GetSafeHdc(), matrixrect.left 
		, matrixrect.top, matrixrect.right-matrixrect.left 
		, matrixrect.bottom-matrixrect.top); 
	isImageOk = TRUE; 
} 
 
void CResultImageDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CResultImageDlg) 
	DDX_Control(pDX, IDC_RESULTIMAGE, myResultImage); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CResultImageDlg, CDialog) 
	//{{AFX_MSG_MAP(CResultImageDlg) 
	ON_WM_SIZE() 
	ON_WM_PAINT() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CResultImageDlg message handlers 
 
void CResultImageDlg::OnSize(UINT nType, int cx, int cy)  
{ 
	CDialog::OnSize(nType, cx, cy); 
	if (isImageOk) 
	{ 
		CWnd* myMatrix = GetDlgItem(IDC_RESULTIMAGE); 
		CRect matrixrect; 
		myMatrix->GetClientRect(matrixrect); 
		myMatrix->ClientToScreen(matrixrect); 
		ScreenToClient(matrixrect); 
		 
		CClientDC dc(this); 
		 
		myImageobject.DrawToHdc( dc.GetSafeHdc(), matrixrect.left 
			, matrixrect.top, matrixrect.right-matrixrect.left 
			, matrixrect.bottom-matrixrect.top);	 
	}	 
} 
 
void CResultImageDlg::OnPaint()  
{ 
	CPaintDC dc(this); // device context for painting 
	if (isImageOk) 
	{ 
		CWnd* myMatrix = GetDlgItem(IDC_RESULTIMAGE); 
		CRect matrixrect; 
		myMatrix->GetClientRect(matrixrect); 
		myMatrix->ClientToScreen(matrixrect); 
		ScreenToClient(matrixrect); 
		 
		CClientDC dc(this); 
		 
		myImageobject.DrawToHdc( dc.GetSafeHdc(), matrixrect.left 
			, matrixrect.top, matrixrect.right-matrixrect.left 
			, matrixrect.bottom-matrixrect.top);	 
	}	 
	// Do not call CDialog::OnPaint() for painting messages 
}