title: View Web Console When Using TWebBrowser
body: <p>I am using a <code>TWebBrowser</code> 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 <code>TWebBrowser</code>. I am looking for a way to access the web console or dev tools from within Delphi when displaying a <code>TWebBrowser</code> so that I can determine what exactly is preventing functionality of a page from working.</p>
  <p>I have tried to implement a <code>TDeveloperConsoleMessageReceiver</code> class that uses the <code>IDeveloperConsoleMessageReceiver</code> interface. This class is created when the <code>TWebBrowser</code> is initialized. Then on <code>TWebBrowserDocumentComplete</code> I implemented the following function:</p>
  <pre><code>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;
  </code></pre>
  <p>Where <code>DeveloperConsole</code> is the <code>DeveloperConsoleMessageReceiver</code> class created on initialization. When the above function is run I get an access violation on the <code>Exec</code>.</p>
  <p>How would I properly utilize <code>DeveloperConsoleMessageReceiver</code> or is there another way to debug a <code>TWebBrowser</code> from within Delphi?</p>