비슷한 이유로 dll 에서 dll 내의 리소스를 쓰고자 할때도 AfxGetStaticModuleState 를 해주어야 하지요.
저같은경우는 dll 에서 가속키를 쓰려고 하는데 잘 안되서 찾아보니 아래와같이 해주니 되더군요.
dll 내에다가 translatemessage와 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 을 참고하세요.