HDowns Posted February 19, 2013 Share Posted February 19, 2013 I load a HTML page to the TUniURLFrame component in VCL mode. I would catch "onclick" events on some objects of the loaded HTML page in my program. Is it possible? Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted February 19, 2013 Administrators Share Posted February 19, 2013 VCL mode is no longer maintained or supported. Quote Link to comment Share on other sites More sharing options...
HDowns Posted February 19, 2013 Author Share Posted February 19, 2013 But may be, is it possible in the current version in any kind? Quote Link to comment Share on other sites More sharing options...
HDowns Posted February 20, 2013 Author Share Posted February 20, 2013 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. 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.