Hi
I have a dll & its client application.
The dll is a Regular MFC dll & the client is an SDI MFC application.
I am having trouble posting message from the dll to the client application.
The dll is implicitly linked to the client application. The exported function <DisplayMsgBox1()> is being called from the client side.
From within the <DisplayMsgBox1()> function on the dll side, a message is posted to the client but it never reaches the client app.
Code on the dll side : <DisplayMsgBox1()>
Code:
#define WM_MSG_FROM_DLL WM_APP+100
extern "C" __declspec(dllexport) BOOL CFindFile::DisplayMsgBox1()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
AfxMessageBox("DisplayMsgBox() of the dll called!");
HWND hWnd = FindWindow(NULL, "VC++");
if(hWnd)
{
AfxMessageBox("Window is found!");
BOOL ret = 0;
ret = PostMessage(hWnd, WM_MSG_FROM_DLL, 0, 0);
}
else
AfxMessageBox("Window not found!");
return 0;
}
When the control comes inside the <DisplayMsgBox1()> function, the FindWindow() returns success but PostMessage() is failing.
Code on the client side:
Code:
#define WM_MSG_FROM_DLL WM_APP+100
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_MESSAGE(WM_MSG_FROM_DLL, OnMsgFromDll)
//}}AFX_MSG_MAP
// Global help commands
END_MESSAGE_MAP()
//This function is called in response to the user pressing the Edit->Call dll //function sub menu item
void CMainFrame::OnEditCalldllsfunction()
{
CFindFile obj;
obj.DisplayMsgBox1();
}
LRESULT CMainFrame::OnMsgFromDll(WPARAM wParam, LPARAM lParam)
{
AfxMessageBox("Message from DLL");
return 0;
}
Please suggest where am i going wrong
waiting for suggestions
Regards