Reputation: 3
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.
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.
Upvotes: 0
Views: 270
Reputation: 613542
What you report is not the whole story. Take the following steps:
TWebBrowser
component to the automatically generated form.OnCreate
event handler named FormCreate
that is associated with the OnCreate
event.WebBrowser1.Navigate
into the body of the FormCreate
method.In other words, something else in your application is blocking this. Perhaps the OnCreate
event handler is not assigned to FormCreate
. Or perhaps something else is wrong. However, you can follow the steps above to prove to yourself that navigating from OnCreate
works. 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.
Upvotes: 3