MFC全域性函式開局 AfxGetApp解剖

2021-09-03 01:24:45 字數 1433 閱讀 7336

mfc中有不少的全域性函式,方便在不同物件中獲取不同的內容或建立不同的物件。主要全域性函式有:

afxwininit() afxbeginthread() afxendthread() afxformatstring1() afxformatstring2()

afxregisterclass()

這些函式從名稱上可見豹斑(功能)。

在afxwin.h中是這麼定義的:

afxgetmodulestate返回的是乙個:afx_module_state類的指標(afxstat_.h):

afx_module_state* afxapi afxgetmodulestate();

在afx_module_state類中定義了如下的成員變數:

// initialize cwinthread state

afx_module_state* pmodulestate = _afx_cmdtarget_getstate();   //看,宣告了乙個指標

afx_module_thread_state* pthreadstate = pmodulestate->m_thread;

assert(afxgetthread() == null);

pthreadstate->m_pcurrentwinthread = this;

assert(afxgetthread() == this);

m_hthread = ::getcurrentthread();

m_nthreadid = ::getcurrentthreadid();

// initialize wait cursor state

m_nwaitcursorcount = 0;

m_hcurwaitcursorrestore = null;

// initialize current printer state

m_hdevmode = null;

m_hdevnames = null;

m_nnumpreviewpages = 0;     // not specified (defaults to 1)

// initialize dao state

m_lpfndaoterm = null;   // will be set if afxdaoinit called

// other initialization

m_bhelpmode = false;

m_nsafetypoolsize = 512;        // default size

}#ifdef _afxdll

#define _afx_cmdtarget_getstate() (m_pmodulestate)

#else

#define _afx_cmdtarget_getstate() (afxgetmodulestate())

#endif

MFC全域性函式開局 AfxGetApp解剖

mfc中有不少的全域性函式,方便在不同物件中獲取不同的內容或建立不同的物件。主要全域性函式有 afxwininit afxbeginthread afxendthread afxformatstring1 afxformatstring2 afxregisterclass 這些函式從名稱上可見豹斑 ...

MFC全域性函式 AfxBeginThread

函式功能描述 建立新的執行緒 函式原型 cwinthread afxbeginthread afx threadproc pfnthreadproc,lpvoid pparam,int npriority thread priority normal,uint nstacksize 0,dword ...

MFC全域性函式 AfxBeginThread

cwinthread afxbeginthread cruntimeclass pthreadclass,int npriority thread priority normal,uint nstacksize 0,dword dwcreateflags 0,lpsecurity attribute...