Jump to content

TUniURLFrame in VCLMode


HDowns

Recommended Posts

I'll answer myself.

 

1. Search a child window of the Frame.VCLContainer.Handle with the 'Internet Explorer_Server' class.

2. Get IHTMLDocument2 and IWebbrowser2 interfaces using the following code:

 

function GetIEFromHWND(WHandle: HWND; var pDoc: IHTMLDocument2; var IE: IWebbrowser2): HRESULT;
var
  hInst: HWND;
  lRes: DWORD;
  Msg: Integer;
  ObjectFromLresult: TObjectFromLresult;
begin
  hInst := LoadLibrary('Oleacc.dll');
  if hInst=0 then
   begin
    Result := GetLastError;
    exit;
   end;

  @ObjectFromLresult :=  GetProcAddress(hInst, 'ObjectFromLresult');
  if @ObjectFromLresult <> nil then
  begin
    try
      lRes := 0;
      Msg := RegisterWindowMessage('WM_HTML_GETOBJECT');
      if SendMessageTimeOut(WHandle, Msg, 0, 0, SMTO_ABORTIFHUNG, 1000, @lRes)<>0 then
       begin
        Result := ObjectFromLresult(lRes, IHTMLDocument2, 0, pDoc);
        if Result = S_OK then
          (pDoc.parentWindow as IServiceprovider).QueryService(IWebbrowserApp,
            IWebbrowser2, IE);
       end
      else
       Result := GetLastError;
    finally
      FreeLibrary(hInst);
    end;
  end
  else
   Result := GetLastError;
end;

It allows you fully control the web frame from the VCL mode.

 

Note: The 'Internet Explorer_Server' child window will be available only after you'll load something to the frame.

  • Upvote 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...