I have Epic Editor which returns a handle to the window (see Java code from plugin_1 below):
int handle = com.arbortext.epic.Application.getActiveWindow().getNativeHandle();
In fact, this handle is CWnd *
pointer. Its direct transfer to the native plugin_2 does not work. Instead, we have to use dll with MFC support with the call
HWND __stdcall GetHandle(CWnd *cp)
{
HWND hWnd = cp->GetSafeHwnd();
return hWnd;
}
How can I rewrite this code in Delphi without MFC? I mean the extraction of window handle from the pointer to the CWnd
object.
You can't write this in Delphi in a safe way. That's because CWnd
is a C++ class and you can't import C++ classes into Delphi code. I suppose you could reverse engineer the memory layout of CWnd
but I'd be very sceptical about the wisdom of talking that approach. My recommendation would be to stick with the MFC DLL.