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/ProgressThreadCtrl.h

76 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-11-15
//
//
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include "progressbase.h"
#include "AttachBase.h"
#include "ProcessThread.h"
namespace NProgress
{
class AFX_CLASS_EXPORT CProgressThreadCtrl
: public CProgressBase
, public CAttachBase
{
public:
CProgressThreadCtrl(void);
~CProgressThreadCtrl(void);
virtual bool AttachInput(void* pProgressCtrl, bool bAutoDelete = false); //参数为CProgressCtrl对象
virtual void SetProgressText(LPCTSTR lpszText);
virtual void SetProgressPos(int nPos);
virtual void SetProgressRange(int nLower, int nUpper);
virtual void SetProgressInfo(__int64 cur, __int64 total);
virtual bool IsCanceled(void);
virtual bool IsSucceed(void);
virtual void EnableSucceed(bool bEnable);
virtual void ThreadFinished(bool bSucceed); //线程执行结束调用该函数关闭线程
CProgressCtrl* GetProgress() { return (CProgressCtrl*)GetInput(); }
CProcessThread& GetThread() { return m_thread; }
//启动线程
bool RunThread() { return m_thread.Run(); }
bool RunAndWaitForDone(); //运行线程并等待线程结束
//取消线程
void CancelThread();
void SetThreadFunc(LPTHREAD_START_ROUTINE lpThreadFunc, void* pParameter);
//仅在不显示进程条对话框时使用
void SetProgressWndNull() { m_threadData.m_pProgressWnd = NULL; }
public:
struct AFX_CLASS_EXPORT PROGRESS_THREAD_DATA
{
//进程条对话框由CProgressBase类派生的类对象
// 可以为CProgressThreadDlg对象CProgressThreadCtrl对象
CProgressBase* m_pProgressWnd;
LPVOID m_pUserThreadParameter; //用户定义参数
};
//static int m_static_count; //ggff
protected:
CProcessThread m_thread;
PROGRESS_THREAD_DATA m_threadData;
static DWORD WINAPI __ThreadFunc__(LPVOID lpVoid); //该函数内调用用户定义的线程函数
private:
LPTHREAD_START_ROUTINE m_pUserThreadFunc; //外部定义的线程函数
};
}//namespace