SRL Archive - Delphi/FPC Help and Tutorials

Loading Home Page on StartUp/Pressing Enter to Access a Website


Lacky

2009-02-21 23:18:47

Hey,

I am making this Web Browser in Delphi v7.2 and I have basically completed it apart from images/graphics for it…but I need three more parts to add to it to complete the program.

Done - I was just wondering, how do I make the web browser load the home page when I start it up? At the moment it's white and just stays like that until I make it go to a web page. If I click on the home button it goes to my home page, but apart from that, I can't access it without typing in the URL. - Done

Done - How do I make it automatically load my homepage (Google) when I first start up the browser? - Done

Also, how do I make it so that I can just press Enter to go to the webpage, once I have typed the URL in, so that I don't have to keep clicking on go each time?

Lastly, I want to know how to grey out the back and forward buttons if there is no web pages visited because when I press them and I can't, it comes up with "Unspecified Error". How do I fix this and make the buttons grayed out if I can't go back or forward?

Please explain in very easy to understand noob english language please. This is my first ever application in Delphi. :p

All help is appreciated.

Cheers!

–Lacky.

R0b0t1

2009-02-21 23:36:54

Store the home page in a file and have the program read that on startup. Since I assume there's a WebBrowser.NavigateTo command, just use w/e it is to go to the read address.

You have to check for certain events to get the keypress. If the key is equal to enter, navigate to the page.

Lacky

2009-02-21 23:40:30

From: Lacky
Please explain in very easy to understand noob english language please. This is my first ever application in Delphi. :p


:p

No idea what I have to do. Can you explain it step by step please?

EDIT: OK, I made it load my home page on start. I did it with some on start click button 6 thing or something.

I still need help with the enter thing and the back/forward thing.

Daniel

2009-02-27 23:05:28

procedure TForm1.OnCreate(Sender: TObject);
begin
loadwebpage('http://google.com'); //this may not be your function/procedure, but w/e
end;

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if(StrToInt(Key)=VK_Enter{or VK_Return,forget which one it is}) then
loadwebpage(Form1.Edit1.Text);
end;

NiCbaZ

2009-02-28 02:55:41

[QUOTE=Dan's The Man;552216][scar]procedure TForm1.OnCreate(Sender: TObject);
begin
loadwebpage('http://google.com'); //this may not be your function/procedure, but w/e
end;

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if(StrToInt(Key)=VK_Enter{or VK_Return,forget which one it is}) then
loadwebpage(Form1.Edit1.Text);
end;


wont work is someone types in " a" for example it will give an error " A is not a vaid Integer"

so do this…

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if HiWord(GetKeyState(vk_Return)) > 0 then
loadwebpage(Form1.Edit1.Text);
end;

Lacky

2009-02-28 03:07:25

Which one are you talking about Nic? I take it the second one?

Anyway, will the first one work?

Daniel

2009-02-28 19:34:54

From: NiCbaZ
wont work is someone types in " a" for example it will give an error " A is not a vaid Integer"

so do this…

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if HiWord(GetKeyState(vk_Return)) > 0 then
loadwebpage(Form1.Edit1.Text);
end;

Lol, i forget. haven't coded Delphi in a while.

Lacky

2009-02-28 20:51:57

I just used the OnKeyPress thing for the enter command.