[英]load a default url delphi
i would like to load a default URL on form create event, i can load a url using a button click but i want it to load the URL when the app loads, when i run the program it wont load the url. 我想在表单创建事件中加载默认URL,我可以使用按钮单击来加载URL,但是我希望它在应用程序加载时加载URL,在我运行程序时它不会加载该URL。
here is my code : 这是我的代码:
unit launcher;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Imaging.pngimage, Vcl.ExtCtrls,
Vcl.StdCtrls, Vcl.OleCtrls, SHDocVw;
type
TForm1 = class(TForm)
Image1: TImage;
Button1: TButton;
WebBrowser1: TWebBrowser;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Webbrowser1.Navigate('http://www.digitalxeon.net');
end;
procedure TForm1.Button1Click(Sender: TObject);
close;
end;
end.
What you report is not the whole story. 您报告的内容并非全部。 Take the following steps:
请执行以下步骤:
TWebBrowser
component to the automatically generated form. TWebBrowser
组件添加到自动生成的表单中。 OnCreate
event handler named FormCreate
that is associated with the OnCreate
event. OnCreate
命名事件处理程序FormCreate
与该关联OnCreate
事件。 WebBrowser1.Navigate
into the body of the FormCreate
method. FormCreate
WebBrowser1.Navigate
的调用放入FormCreate
方法的主体中。 In other words, something else in your application is blocking this. 换句话说,您的应用程序中的其他内容阻止了此操作。 Perhaps the
OnCreate
event handler is not assigned to FormCreate
. 也许
OnCreate
事件处理程序未分配给FormCreate
。 Or perhaps something else is wrong. 也许还有其他问题。 However, you can follow the steps above to prove to yourself that navigating from
OnCreate
works. 但是,您可以按照上述步骤向自己证明从
OnCreate
导航是OnCreate
。 Then all the remains is to diagnose where your application differs. 然后所有剩下的就是诊断您的应用程序与众不同之处。
The bottom line is that calling Navigate
from an OnCreate
event is sufficient to show a web page on form startup. 最重要的是,从
OnCreate
事件调用Navigate
足以在表单启动时显示网页。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.