Question

UPDATE: This is a .NET Client making a call to the regular DLL. I have also got another extension DLL which exports some class and is used in the regular DLL.

I have got a third party DLL which takes a WindowHandle and a user defined message as a parameter and starts sending messages to the passed on window, but I don't see any message coming to my window. Below is API call format:

StartMessaging(<WindowHandle>,WM_MESSAGE_API);

I needed a regular MFC Regular DLL which will create a hidden CFrameWnd window just for receiving the messages. I am also using AFX_MANAGE_STATE() at all the entry point to the DLL.

Constructor code in my CFrameWnd derived class:

Create(NULL,"MYWINDOW"); hWndFrame = this->m_hWnd;

Message Maps:

LRESULT CMyDerivedWnd::OnMsgApi( WPARAM wParam, LPARAM lParam )
{
 OutputDebugString("OnMsgApi");
 return (LRESULT)0;
}

My Main class where the StartMessaging is called: In Constructor I instantiate the CFrameWnd object:

myDerivedWnd = new CMyDerivedWnd(this);

and then InitiateMessaging is called:

void CMain::InitiateMessaging()
 {
  TCHAR szBuf[80];
  ::GetWindowText(myDerivedWnd->m_hWnd,szBuf,80);
  OutputDebugString((LPSTR)(LPCTSTR)szBuf); //This displays MYWINDOW
  StartMessaging(myDerivedWnd->m_hWnd,WM_MESSAGE_API);
 }

My GetWindowText function returns the correct Window name, but I am unable to trap WM_MESSAGE_API message in this class. I have also tried using extension DLL but same result.

No correct solution

OTHER TIPS

I found the problem, not the answer yet. It was threading on C# side causing the event not to show up.If the call to C++ Interop is on the main thread, event works, but I need the call to be on a separate thread. I am planning to post another question to find an answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top