twebbrowser

How to detect Print command has finished in TWebBrowser?

跟風遠走 提交于 2019-12-01 05:37:18
问题 procedure TForm1.Button1Click(Sender: TObject); var vaIn, vaOut: OleVariant; begin WebBrowser1.Navigate('http://www.google.com'); while WebBrowser1.ReadyState < READYSTATE_COMPLETE do Application.ProcessMessages; WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER, vaIn, vaOut); // HOWTO: WAIT until print <strike>job</strike> dialog is done or canceled // UPDATE (1): WebBrowser1.Enabled := False; WebBrowser1.OnCommandStateChange := WebBrowser1CommandStateChange; end; procedure TForm1

CSS and TWebbrowser delphi

a 夏天 提交于 2019-12-01 00:55:34
I was wondering if it was possible to manipulate the CSS of websites. For example color in the input fields? I had a look at several questions, but its not clear to me if it is possble at all. For Example in Google Chrome, Whenever a field is selected it shows a golden line around the outsite. Is it possible to do this and other things in delphi, with any website. Writing CSS code that gets applied to the website opend in Twebbrowser? Just for personal viewing only Thx Can I change the color of an input field background with this code as well? I can change background colors and change font

How do I set each TWebBrowser to use an independent proxy?

白昼怎懂夜的黑 提交于 2019-11-30 14:18:36
I have found all kind of examples about how to make TWebBrowser use a proxy (like 202.8.128.5:8080). However all those examples are changing the proxy globally for all running instances of TWebBrowser. I have two instances. How do I set a different proxy for each browser? This can be achieved using the following code (public code, not mine): {$DEFINE DELPHI2009_UP} function SetProxy(Server: String): Boolean; // Server z.B. '127.0.0.1:8080' oder '' type INTERNET_PER_CONN_OPTION = record dwOption: DWORD; Value: record case Integer of 1: (dwValue: DWORD); 2: (pszValue: {$IFDEF DELPHI2009_UP

TWebBrowser and FEATURE_BROWSER_EMULATION at runtime

醉酒当歌 提交于 2019-11-30 07:16:36
问题 Has anyone tried creating and destroying a TWebBrowser at runtime and using FEATURE_BROWSER_EMULATION to switch the browser mode before re-creating the TWebBrowser to enable switching the mode without restarting the application? I'm wondering if the setting is only read when starting the app, or when the web browser control is created. 回答1: You don't need to create or destroy a TEmbeddedWB yourself. I made this (see below) to set the correct IE version for an app. Works perfecctly. You must

Application locks while trying to access TWebbrowsers HTML

人走茶凉 提交于 2019-11-30 06:01:29
问题 Edit Narrowed it down to this 1 line, HTML := wb.OleObject.Document.documentElement.innerHTML; which consumes the time... how can that be speed up? Using the following code my application can hang for 1-2 seconds while it tries to access the HTML of a page (Delphi XE). function Button1Click(Sender : TObject); begin wb.navigate('http://10.0.0.154/stats'); // Use a timer to poll the page - dont wait and process app messages timer1.enabled := true; end; procedure Timer1Timer(Sender : TObject);

Image from TWebBrowser to TPicture

萝らか妹 提交于 2019-11-29 12:51:39
How to get an image that has been downloaded in TWebBrowser to a TPicture without copying it to clipboard or looking in to cache contents. ok i made sample with last answer to you : fisrt get image with this function by Id : function GetImgElementById(const Doc: IDispatch; const id : string): IHTMLImgElement; var Document: IHTMLDocument2; // IHTMLDocument2 interface of Doc Body: IHTMLElement2; // document body element Tags: IHTMLElementCollection; // all tags in document body Tag: IHTMLElement; // a tag in document body I: Integer; // loops thru tags in document body begin Result :=nil ; //

Upload a file to a website programmatically?

情到浓时终转凉″ 提交于 2019-11-29 12:38:58
I am using Lazarus I have an app with webbrowser component on it that logs into a website loads a page as below (see html code below), and fills in different inputs. The last input is a file to upload. I would like my app to "click" Browse, select a file i want to, and Open. After that I could do a post the form OR just upload the file and carry on. 1 I have the following html code on the site: <td align="left" class="RequiredInput">File:</td> <td class="datafield"> <form name="frmMain" id="frmMain" action="upload.asp?step=2&output=1" method="post" enctype="multipart/form-data"> <input type=

How do I redirect the TWebBrowser control to a custom URL?

女生的网名这么多〃 提交于 2019-11-29 07:55:04
Example: I navigate to http://www.stackoverflow.com with my web browser control there's a link to FAQ in the top bar, with target https://stackoverflow.com/faq I need to redirect e.g. to the http://math.stackexchange.com when I click the FAQ link TLama The easiest way, as kobik suggested is to use TWebBrowser.OnBeforeNavigate2 event. Here is the example. procedure TForm1.WebBrowser1BeforeNavigate2(ASender: TObject; const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData, Headers: OleVariant; var Cancel: WordBool); begin if URL = 'https://stackoverflow.com/faq' then begin // setting

How can I get HTML source code from TWebBrowser

♀尐吖头ヾ 提交于 2019-11-29 06:34:35
How can I get source code from WebBrowser component? I want to get source code of active page on WebBrowser component and write it to a Memo component. Thanks. You can use the IPersistStreamInit Interface and the save method to store the content of the Webbrowser in a Stream. Uses ActiveX; function GetWebBrowserHTML(const WebBrowser: TWebBrowser): String; var LStream: TStringStream; Stream : IStream; LPersistStreamInit : IPersistStreamInit; begin if not Assigned(WebBrowser.Document) then exit; LStream := TStringStream.Create(''); try LPersistStreamInit := WebBrowser.Document as

How to make TWebBrowser Zoom when using ctrl+mousewheel like Internet Explorer does?

不羁岁月 提交于 2019-11-29 03:59:43
According to http://www.rendelmann.info/blog/CommentView,guid,356fbe68-3ed6-4781-90a4-57070a0141da.aspx and http://msdn.microsoft.com/en-us/library/aa770056(v=vs.85).aspx getting the hosted WebBrowser to zoom using the control key and the mouse wheel should just require calling IWebBrowser2.ExecWB(OLECMDID_OPTICAL_ZOOM, ...) with a pvaIn value of 100 , but after calling it, ctrl+mousewheel still doesn't zoom the content Code I'm using with Delphi 2007: const OLECMDID_OPTICAL_ZOOM = 63; var pvaIn, pvaOut: OleVariant; begin pvaIn := 100; pvaOut := NULL; WebBrowser1.ControlInterface.ExecWB