I've converted a DLL from 32 bit to 64 bit having no problem, but when I load this DLL from a 64 bit application that occupies a large amount of memory the application crashes and closes itself when DLL is loaded.
The DLL is a simple form with a TWebBrowser on it. I use Delphi 10 Seattle.
After debugging I found a 64 bit conversion problem in the vcl unit "Vcl.OleCtrls.pas" solved in this way:
procedure TOleControl.HookControlWndProc;
var
WndHandle: HWnd;
begin
if (FOleInPlaceObject <> nil) and (WindowHandle = 0) then
begin
WndHandle := 0;
FOleInPlaceObject.GetWindow(WndHandle);
if WndHandle = 0 then raise EOleError.CreateRes(@SNoWindowHandle);
WindowHandle := WndHandle;
//DefWndProc := Pointer(GetWindowLong(WindowHandle, GWL_WNDPROC));//OLD
DefWndProc := Pointer(GetWindowLongPtr(WindowHandle, GWL_WNDPROC));
CreationControl := Self;
//SetWindowLong(WindowHandle, GWL_WNDPROC, Longint(@InitWndProc));//OLD
SetWindowLongPtr(WindowHandle, GWL_WNDPROC, LONG_PTR(@InitWndProc));
SendMessage(WindowHandle, WM_NULL, 0, 0);
end;
end;
This solves the crash issue, but TWebBrowser events are not fired anymore and happens on 64bit only.
How can I fix TWebBrowser events firig?
Have you find similar issue or workaroud to fix events?
Thanks