C++ and C# findwindow and sendmessage

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stevus06
    New Member
    • Sep 2008
    • 1

    C++ and C# findwindow and sendmessage

    I have two projects in Visual Studio 2008: One a C# app, the other a c++ dll.

    I have figured out to get my dll started from the c# app and can confirm it is running along with the C# GUI.

    The C++ is using several SendMessage(... ) statements and I have setup a WndProc(ref Message m) { } in my C#.

    My problem is the C# code does not seem to be receiving any of my SendMessages from the C++.

    I am calling this line first in the C++:

    HWND hWnd = ::FindWindow(NU LL, _T("Window name"));

    and then using

    ::SendMessage(h Wnd, WM_COPYDATA, (WPARAM)hTable, (LPARAM)&cds);

    to send the message to c#. But how does the C++ know anything about my c# window? Do I need to do something else?
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    You are trying to use windows message loops to talk back and forth?
    Send the c++.DLL the hWND handle of your c# window and use that to send c++ to C#. Sending from C# to C++ will require that a handle from c++ be sent to c# for the message system.

    Comment

    Working...