| View previous topic :: View next topic |
| Author |
Message |
iamok Expert Cheater
Reputation: 0
Joined: 04 Feb 2007 Posts: 247
|
Posted: Thu Jan 10, 2008 8:57 pm Post subject: [Delphi] Opening a local .html file with my browser |
|
|
Okay, so I'm working on something. And what I'd like to do is to open any .html with my default browser, using the menu of my delphi application.
So basically, If I went "File > Open" and selected a .html file, it'd open with my default browser, and not my delphi application.
Thanks.
_________________
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Thu Jan 10, 2008 9:02 pm Post subject: |
|
|
i dont quite get what ur saying...
so u wanna open a .html file from your delphi aplication... like through a button?
or do u mean a file extention? so if u open a .html it opens ur delphi app?
explain beter
_________________
|
|
| Back to top |
|
 |
iamok Expert Cheater
Reputation: 0
Joined: 04 Feb 2007 Posts: 247
|
Posted: Thu Jan 10, 2008 9:10 pm Post subject: |
|
|
I mean say I have a bunch of help files, If I opened my application, but got stuck with something, I could go file > open select a .html file, and it would open in my browser so I could read it.
_________________
|
|
| Back to top |
|
 |
thephoneguy Grandmaster Cheater
Reputation: 1
Joined: 17 Mar 2007 Posts: 873
|
Posted: Thu Jan 10, 2008 9:38 pm Post subject: |
|
|
couldnt you just do an on click event with shellexecute? or maybe i am misunderstanding you.
_________________
If you see me posting referring to an earlier conversation 9/10 times it was in the chatbox at baby .
 |
|
| Back to top |
|
 |
iamok Expert Cheater
Reputation: 0
Joined: 04 Feb 2007 Posts: 247
|
Posted: Thu Jan 10, 2008 9:40 pm Post subject: |
|
|
| ThePhoneGuy wrote: | | couldnt you just do an on click event with shellexecute? or maybe i am misunderstanding you. |
Well if i did that, wouldn't I have to do it for each individual html file anyways. Which would defeat the purpose of using a menu.
_________________
|
|
| Back to top |
|
 |
thephoneguy Grandmaster Cheater
Reputation: 1
Joined: 17 Mar 2007 Posts: 873
|
Posted: Thu Jan 10, 2008 9:45 pm Post subject: |
|
|
lol copy and paste or maybe shell execute with the site being a var and defined by what you type in the menu?
_________________
If you see me posting referring to an earlier conversation 9/10 times it was in the chatbox at baby .
 |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Fri Jan 11, 2008 3:43 am Post subject: |
|
|
ShellExecute will work for this. Use the "open" command with it and point it to the path of the HTML file.
_________________
- Retired. |
|
| Back to top |
|
 |
iamok Expert Cheater
Reputation: 0
Joined: 04 Feb 2007 Posts: 247
|
Posted: Fri Jan 11, 2008 4:20 pm Post subject: |
|
|
Where exactly would I implement shellexecute?
This is what I'm using (from delphibasics)
| Code: |
var
openDialog : TOpenDialog;
begin
openDialog := TOpenDialog.Create(self);
openDialog.InitialDir := GetCurrentDir;
openDialog.Options := [ofFileMustExist];
openDialog.Filter :=
'HTML File|*.html|';
openDialog.FilterIndex := 1;
if openDialog.Execute
then ShowMessage('File : '+openDialog.FileName)
else ShowMessage('Open file was cancelled');
openDialog.Free;
end; |
_________________
|
|
| Back to top |
|
 |
Blader I post too much
Reputation: 2
Joined: 19 Jan 2007 Posts: 2049
|
Posted: Fri Jan 11, 2008 7:05 pm Post subject: |
|
|
ShellExecute with openDialog.FileName as the url paramater?
I'm not sure, I haven't used Delphi before, but that's what I would do for VB
_________________
|
|
| Back to top |
|
 |
iamok Expert Cheater
Reputation: 0
Joined: 04 Feb 2007 Posts: 247
|
Posted: Fri Jan 11, 2008 9:42 pm Post subject: |
|
|
Thanks for your help, I got it in the end.
turns out it was
| Code: |
begin
openDialog1.Filter :=
'HTML File|*.html|';
openDialog1.FilterIndex := 1;
if openDialog1.Execute then
Edit1.text :=(''+openDialog1.FileName);
begin
if Edit1.Text='' then
Application.Initialize
else
Shellexecute(handle,'',PChar(Edit1.Text),'','',SW_NORMAL);
Edit1.Text:='';
end; |
_________________
|
|
| Back to top |
|
 |
iRiot Master Cheater
Reputation: 0
Joined: 03 Jul 2007 Posts: 395 Location: Aka RIOT
|
Posted: Fri Jan 11, 2008 10:18 pm Post subject: |
|
|
| iamok wrote: | Thanks for your help, I got it in the end.
turns out it was
| Code: |
begin
openDialog1.Filter :=
'HTML File|*.html|';
openDialog1.FilterIndex := 1;
if openDialog1.Execute then
Edit1.text :=(''+openDialog1.FileName);
begin
if Edit1.Text='' then
Application.Initialize
else
Shellexecute(handle,'',PChar(Edit1.Text),'','',SW_NORMAL);
Edit1.Text:='';
end; |
|
lol thanks to me
_________________
|
|
| Back to top |
|
 |
|