MFC

기본(일반, regular) MFC Dll 에서 다이얼로그 박스 등 로딩시 응용프로그램에서 메시지 보내주는 법

디버그정 2008. 9. 8. 16:17
DLL 에  PreTranslateMessage와 OnIdle 관련 함수를 익스포트하고 응용프로그램에서
상기 메시지 처리부에서 보내주는 루틴을 구현하면 된다.
아래 참조)

//main app에서
BOOL CXXXApp::OnIdle(LONG lCount)
{
    // TODO: Add your specialized code here and/or call the base class
    if (CWinApp::OnIdle(lCount))
        return(TRUE);
 
    ProcessDllIdle();
 
    return(FALSE);
}

BOOL CXXXApp::PreTranslateMessage(MSG* pMsg)
{
    // TODO: Add your specialized code here and/or call the base class
    if (CWinApp::PreTranslateMessage(pMsg))
        return(TRUE);
 
    return(FilterDllMsg(pMsg));
}

// dll 에서
BOOL FilterDllMsg(LPMSG lpMsg)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    TRY
    {
        return AfxGetThread()->PreTranslateMessage(lpMsg);
    }
    END_TRY
   
    return FALSE;
}

void ProcessDllIdle()
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    TRY
    {
        // flush it all at once
        long lCount = 0;
        while (AfxGetThread()->OnIdle(lCount))
            lCount++;
    }
    END_TRY
}


자세한건 ms-help://MS.MSDNQTR.2004JAN.1033/vclib/html/_MFCNOTES_TN011.htm 여기를 참고하시고
MFC 예제중에서 DllScreenCap 을 참고하세요.