这两页是讲解AfxWinInit的,具体如下:我想你已經清楚看到了,AfxWinInit 是繼 CWinApp 建構式之後的第㆒個動作。以㆘是它
的動作摘要(節錄自 APPINIT.CPP):
BOOL AFXAPI AfxWinInit(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow)
{
ASSERT(hPrevInstance == NULL);
// set resource handles
AFX_MODULE_STATE* pState = AfxGetModuleState();
pState->m_hCurrentInstanceHandle = hInstance;
pState->m_hCurrentResourceHandle = hInstance;
// fill in the initial state for the application
CWinApp* pApp = AfxGetApp();
if (pApp != NULL)
{
// Windows specific initialization (not done if no CWinApp)
pApp->m_hInstance = hInstance;
pApp->m_hPrevInstance = hPrevInstance;
pApp->m_lpCmdLine = lpCmdLine;
pApp->m_nCmdShow = nCmdShow;
pApp->SetCurrentHandles();
}
// initialize thread specific data (for main thread)
if (!afxContextIsDLL)
AfxInitThread();
return TRUE;
}
其㆗呼叫的 AfxInitThread 函式的動作摘要如㆘(節錄自THRDCORE.CPP):
void AFXAPI AfxInitThread()
{
if (!afxContextIsDLL)
{
// attempt to make the message queue bigger
for (int cMsg = 96; !SetMessageQueue(cMsg) && (cMsg -= 8); )
;
// set message filter proc
_AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
ASSERT(pThreadState->m_hHookOldMsgFilter == NULL);
pThreadState->m_hHookOldMsgFilter = ::SetWindowsHookEx(WH_MSGFILTER,
_AfxMsgFilterHook, NULL, ::GetCurrentThreadId());
// intialize CTL3D for this thread
_AFX_CTL3D_STATE* pCtl3dState = _afxCtl3dState;
if (pCtl3dState->m_pfnAutoSubclass != NULL)
(*pCtl3dState->m_pfnAutoSubclass)(AfxGetInstanceHandle());
// allocate thread local _AFX_CTL3D_THREAD just for automatic termination
_AFX_CTL3D_THREAD* pTemp = _afxCtl3dThread;
}
}
//红色部分我完全不懂了,哪位过来人给我推荐个书的某个章节之类,针对的补下,谢谢了。

解决方案 »

  1.   

    2楼的混分行为很可耻……我有限的英语告诉我,这里是关于消息队列和钩子的(不懂,只听说过)
    // attempt to make the message queue bigger
    for (int cMsg = 96; !SetMessageQueue(cMsg) && (cMsg -= 8); )
    ;
    // set message filter proc
    _AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
    ASSERT(pThreadState->m_hHookOldMsgFilter == NULL);
    pThreadState->m_hHookOldMsgFilter = ::SetWindowsHookEx(WH_MSGFILTER,
    _AfxMsgFilterHook, NULL, ::GetCurrentThreadId());但是下面这些是什么,我出于茫茫然中……请高手指点,哪本书哪个章节之类的可以针对的看下。
    // intialize CTL3D for this thread
    _AFX_CTL3D_STATE* pCtl3dState = _afxCtl3dState;
    if (pCtl3dState->m_pfnAutoSubclass != NULL)
    (*pCtl3dState->m_pfnAutoSubclass)(AfxGetInstanceHandle());
    // allocate thread local _AFX_CTL3D_THREAD just for automatic termination
    _AFX_CTL3D_THREAD* pTemp = _afxCtl3dThread;
    }