You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kev/Drawer/SSBase/MxnFormat/ProgressThreadBase.h

77 lines
2.0 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

//////////////////////////////////////////////////////////////////////////////
//文件: 在线程中使用进程条对话框基类
//主要功能:
// 在线程中使用进程条
//程序编写:
//日期2011-08-30
//
//
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include "ProgressBase.h"
#include "ProgressThreadCtrl.h"
namespace NProgress
{
class AFX_CLASS_EXPORT CProgressThreadBase
{
public:
CProgressThreadBase(CWnd* pParentWnd = NULL);
virtual ~CProgressThreadBase(void);
///< 判断是否可以启动线程当返回false时将不启动线程
virtual bool IsCanThread() { return true; }
//显示进程条对话框并启动线程
bool DoModal();
//不显示进程条对话框启动线程
bool StartThread();
//设置进程条对话框显示的标题及是否允许取消操作
void SetProgressInfo(LPCTSTR lpszDlgTitle=NULL, bool bAllowCancel=true);
//设置进程条的显示进度及显示信息
bool SetProgressInfo(__int64 cur, __int64 total);
void SetProgressText(LPCTSTR lpszText);
void SetProgressPos(int nPos);
void SetProgressRange(int nLower, int nUpper);
bool IsCanceled(void);
bool IsSucceed(void);
void EnableSucceed(bool bEnable);
CProgressBase* GetProgress() { return m_pProgress; }
//绑定进程条控件后并设置m_bShowDlg状态为false时则使用指定进程条显示
// 如果不进行绑定进程条控件,则不显示进程条并启动线程
void AttachProgressCtrl(CProgressCtrl* pProgressCtrl) { m_threadCtrl.AttachInput(pProgressCtrl); }
enum EProgressMode
{
showNothing = 0, //不显示进程条
showProgressCtrl= 1, //显示进程条为指定控件需要调用AttachProgressCtrl函数
showProgressDlg = 2, //显示进程条对话框
};
void SetProgressShowMode(EProgressMode pm) { m_showMode = pm; }
protected:
void SetProgressWnd(CProgressBase* pProgressWnd) { m_pProgress = pProgressWnd; }
static DWORD WINAPI _ThreadFunc(LPVOID lpVoid);
//需要重写的函数
virtual bool DoThreadWork() = 0; //执行线程处理的工作
private:
CProgressBase* m_pProgress;
CWnd* m_pParentWnd;
LPCTSTR m_lpszDlgTitle;
bool m_bAllowCancel;
CProgressThreadCtrl m_threadCtrl;
EProgressMode m_showMode; //进程条显示模式
};
}//namespace