I am using a TWebBrowser to display a web page that is created in Vue, but I currently have no way to debug situations where functionality of the page works in a browser (IE and Chrome) but does not work from the TWebBrowser. I am looking for a way to access the web console or dev tools from within Delphi when displaying a TWebBrowser so that I can determine what exactly is preventing functionality of a page from working.
I have tried to implement a TDeveloperConsoleMessageReceiver class that uses the IDeveloperConsoleMessageReceiver interface. This class is created when the TWebBrowser is initialized. Then on TWebBrowserDocumentComplete I implemented the following function:
procedure TTTWebBrowser.WebBrowserDocumentCompleted(ASender: TObject; const pDisp: IDispatch; const URL: OleVariant);
var
Target : IOleCommandTarget;
Action : Cardinal;
Params : OleVariant;
const
IDM_ADDCONSOLEMESSAGERECEIVER = 3800;
CGID_MSHTML: TGUID = '{DE4BA900-59CA-11CF-9592-444553540000}';
begin
CallUserDocumentCompletedEvent(pDisp, URL);
if Assigned(WebBrowser.Document) then begin
Target := IOleCommandTarget(WebBrowser.Document);
Action := IDM_ADDCONSOLEMESSAGERECEIVER;
Params := EmptyParam;
Target.Exec(@CGID_MSHTML, Action, OLECMDEXECOPT_DODEFAULT, IDeveloperConsoleMessageReceiver(DeveloperConsole), Params);
end;
end;
Where DeveloperConsole is the DeveloperConsoleMessageReceiver class created on initialization. When the above function is run I get an access violation on the Exec.
How would I properly utilize DeveloperConsoleMessageReceiver or is there another way to debug a TWebBrowser from within Delphi?