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

📄 progress.cpp

📁 canon SDK 开发包
💻 CPP
字号:
// Progress.cpp : implementation file
//

#include "stdafx.h"
#include "RDSDK SampleApp.h"
#include "Progress.h"

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

/* Prototype declaration */
cdUInt32 cdSTDCALL DevelopProgressFunc(cdUInt32				Progress,
										cdProgressStatus	Status );

/* Global variable definition */
cdUInt32	g_dwRetPrg;


/* The definition of the callback function for progress */
cdUInt32 cdSTDCALL DevelopProgressFunc(cdUInt32				Progress,
										cdProgressStatus	Status,
										cdContext			Context )
{
	CProgress	*CpThis;
	
	CpThis = (CProgress*)Context;
	CpThis->SetProgressPos(Progress);
	return	g_dwRetPrg;
}

/* The function performed by the thread */
DWORD WINAPI	DevelopThreadProc(LPVOID lpParameter)
{
	CProgress *CpThis;
		
	CpThis = (CProgress*)lpParameter;
	CpThis->err = RDDevelop(CpThis->m_hRAW,
							CpThis->m_Action,
							CpThis->m_TgtFormat,
							CpThis->m_pAreaAndRatio,
							&CpThis->m_StgMedium,
							DevelopProgressFunc,
							(cdContext)CpThis,
							cdPROG_REPORT_PERIODICALLY );

	CpThis->PostMessage(CpThis->m_ThreadEndMessage);
	return	0;
}

/////////////////////////////////////////////////////////////////////////////
// CProgress dialog


CProgress::CProgress(CWnd* pParent /*=NULL*/)
	: CDialog(CProgress::IDD, pParent)
{
	//{{AFX_DATA_INIT(CProgress)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CProgress::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CProgress)
	DDX_Control(pDX, IDC_PROGRESS, m_CProgress);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CProgress, CDialog)
	//{{AFX_MSG_MAP(CProgress)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CProgress message handlers

BOOL CProgress::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	g_dwRetPrg = cdOK;
	err = cdOK;

	/* Progress control is changed the first stage. */
	m_CProgress.SetRange(0, 100);
	SetProgressPos(0);

	/* Negatives are developed using a thread. */
	AfxBeginThread((AFX_THREADPROC)DevelopThreadProc, this);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

LRESULT CProgress::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
	// TODO: Add your specialized code here and/or call the base class
	if(m_ThreadEndMessage == message)
	{
		EndDialog(IDOK);
		return	TRUE;
	}
	
	return CDialog::WindowProc(message, wParam, lParam);
}

void CProgress::SetProgressPos(int iPos)
{
	m_CProgress.SetPos(iPos);
}

BOOL CProgress::StartDevelop(cdHRAW				hRAW,
							cdDevT_DevAction	Action,
							cdDevTgtFormat		TgtFormat,
							cdDevT_Dimension*	pAreaAndRatio,
							cdStgMedium			StgMedium)
{
	/* Data is set. */
	m_hRAW = hRAW;
	m_Action = Action;
	m_TgtFormat = TgtFormat;
	m_pAreaAndRatio = pAreaAndRatio;
	m_StgMedium = StgMedium;
	
	m_ThreadEndMessage = RegisterWindowMessage("Information of a thread end");
	if(m_ThreadEndMessage == 0)
	{
		return	FALSE;
	}
	
	/* A progress dialog is displayed and developed. */
	if( DoModal() != IDOK )
	{
		return	FALSE;
	}
	
	return	TRUE;
}

⌨️ 快捷键说明

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