MFC CWinThread Class成员变量及成员函数
来源:互联网 发布:淘宝买衣服肩宽怎么量 编辑:程序博客网 时间:2024/06/08 10:28
一、概要
CWinThread类封装了对线程的操作,一个CWinThread对象代表在应用程序中一个线程的执行。在MFC应用程序中,主执行线程是CWinThread派生类CWinApp的派生类对象。由CWinApp类派生的新类都是用户界面线程。
二、类图位置
三、多线程的实现方法
四、CWinThread头文件
class CWinThread : public CCmdTarget{DECLARE_DYNAMIC(CWinThread)friend BOOL AfxInternalPreTranslateMessage(MSG* pMsg);public:// ConstructorsCWinThread();/// 开始一个CWinThread对象的执行BOOL CreateThread(DWORD dwCreateFlags = 0, UINT nStackSize = 0,LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL);///常用的启动线程的方法///※① CreateThread()///※② _beginThread _beginThreadEx()///※③ AfxBeginThread() MFC全局函数// Attributes///保存指向应用程序的主窗口的指针CWnd* m_pMainWnd; // main window (usually same AfxGetApp()->m_pMainWnd)///指向容器应用程序的主窗口,当一个OLE服务器被现场激活时 CWnd* m_pActiveWnd; // active main window (may not be m_pMainWnd)///指定线程结束时是否要销毁对象 BOOL m_bAutoDelete; // enables 'delete this' after thread termination// only valid while running////当前线程的句柄HANDLE m_hThread; // this thread's HANDLEoperator HANDLE() const;/// 当前线程的ID DWORD m_nThreadID; // this thread's ID/// 获取当前线程的优先级 int GetThreadPriority();/// 设置当前线程的优先级 BOOL SetThreadPriority(int nPriority);// Operations/// 增加一个线程的挂起计数/// 当线程的挂起计数大于0时,该线程将暂停执行,称之为挂起状态。DWORD SuspendThread();///减少一个线程的挂起计数/// 当线程的挂起计数减少到0时,恢复线程的执行。DWORD ResumeThread();/// 向另外的CWinThread对象传递一条消息 BOOL PostThreadMessage(UINT message, WPARAM wParam, LPARAM lParam);// Overridables// thread initialization///重载以实现线程实例的初始化virtual BOOL InitInstance();// running and idle processing///线程的具有消息收发功能的控制函数,可重载以定制缺省的消息循环virtual int Run();///在消息被发送到Windows函数TranslateMessage和DispatchMessage之前过滤消息virtual BOOL PreTranslateMessage(MSG* pMsg);virtual BOOL PumpMessage(); // low level message pump///重载以进行线程特定的空闲操作virtual BOOL OnIdle(LONG lCount); // return TRUE if more idle processing///检测特定的消息 virtual BOOL IsIdleMessage(MSG* pMsg); // checks for special messages// thread termination/// 重载以进行线程终止时的清理工作virtual int ExitInstance(); // default will 'delete this'// Advanced: exception handling///截获线程消息和命令处理函数出现的所有未处理的异常 virtual LRESULT ProcessWndProcException(CException* e, const MSG* pMsg);// Advanced: handling messages sent to message filter hook///在特定的消息到达应用程序之前截获消息virtual BOOL ProcessMessageFilter(int code, LPMSG lpMsg);// Advanced: virtual access to m_pMainWnd//// 查询指向线程主窗口的指针virtual CWnd* GetMainWnd();// Implementationpublic:virtual ~CWinThread();#ifdef _DEBUGvirtual void AssertValid() const;virtual void Dump(CDumpContext& dc) const;#endifvoid CommonConstruct();virtual void Delete();// 'delete this' only if m_bAutoDelete == TRUEpublic:// constructor used by implementation of AfxBeginThreadCWinThread(AFX_THREADPROC pfnThreadProc, LPVOID pParam);// valid after constructionLPVOID m_pThreadParams; // generic parameters passed to starting functionAFX_THREADPROC m_pfnThreadProc;// set after OLE is initializedvoid (AFXAPI* m_lpfnOleTermOrFreeLib)(BOOL, BOOL);COleMessageFilter* m_pMessageFilter;protected:BOOL DispatchThreadMessageEx(MSG* msg); // helpervoid DispatchThreadMessage(MSG* msg); // obsolete};
0 0
- MFC CWinThread Class成员变量及成员函数
- MFC CWinApp Class成员变量及成员函数
- MFC CCmdTarget Class成员变量及成员函数
- class 的static成员变量和 static 成员函数
- CWinThread类成员
- static成员函数成员变量
- 成员变量与成员函数
- 静态成员变量成员函数
- 常成员变量、常成员函数及常对象
- static 成员函数及变量整理
- static 成员函数及变量整理
- java中对象多态时成员变量,普通成员函数及静态成员函数的调用情况
- Java中class的修饰及成员变量的修饰
- C++ 成员函数成员变量 静态成员函数和变量
- 静态成员及变量
- MFC中的m_hWnd成员变量
- VS2005 MFC 对话框 全局函数访问成员变量
- MFC线程函数中访问成员变量的方法
- 欧拉工程第13题 找出100个50位数之和的前十位数字
- JavaWeb文件上传、下载
- dagger2 让你爱不释手:基础依赖注入框架篇
- How to install Desktop Environments on CentOS 7?
- AlarmManager
- MFC CWinThread Class成员变量及成员函数
- background-size的属性以及ie兼容方法
- poj 2299 Ultra-QuickSort(树状数组求逆序数)
- Spark函数详解系列之RDD基本转换
- EXT2/EXT3/EXT4 文件的读取与日志式文件系统概念的引入
- Spark的stage & job & task 到底是什么 ,以及划分原理
- Spark常用函数讲解之键值RDD转换
- 常用到的导入导出oracle
- Spark常用函数讲解之Action操作