Marshaling a CWnd *

  • Thread starter Thread starter Sam Riggens
  • Start date Start date
S

Sam Riggens

I am experimenting with C# and trying to use an unmanaged C++ dll.
The UMC++ dll has a function defined as follows:

extern "C" bool DllExport ShowLogonDlg(CWnd *pParent, CConfig& cfg);

The function pops up a logon dialog and populates data in the cfg
class.

I have been able to call functions like this using the [DllImport...]
but how can I pass a CWnd* or equvalent (Form.this.Handle?)?

Thanks!

JT
 
Sam,
I have been able to call functions like this using the [DllImport...]
but how can I pass a CWnd* or equvalent (Form.this.Handle?)?

You can't. You'll have to write a C++ wrapper that exposes a more .NET
friendly signature, for example taking a HWND parameter.



Mattias
 
You can't, CWnd* is a pointer to a (MFC) CWnd object, this is NOT a Window
handle.
What you could do is call a function that returns the CWnd* of the parent
window as an IntPtr and use this IntPtr as the argument.

Willy.
 
Back
Top