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

📄 resultimagedlg.cpp

📁 这是一个分水岭程序
💻 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
}

⌨️ 快捷键说明

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