Delphi
--
Questions
--
Followers
Top Experts
kind of like the preview funtion in frontpage. when the user clicks the button "preview" i would like the default brower to open, and preferably refresh every 2 seconds if possible.
keep in mind that i want the file to open, but not save if possible, the i am using filename (string) as the name of the document whether it is "untitled.html" or "whateverelse.html"
also, i tried running the program at school, but the scrollbar doesn't work and the speedbuttons won't
display, any thoughts on why this might happen?
please excuse the small number of points, i don't have a credit card to order more, or enough knowlege to become an expert anyway...
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
I think you know how to execute an .EXE file in delphi (ShellExecute/WinExec/Exec
The solution is executing your .HTML file as an .EXE file.
It means supplying name of .HTML file as a parameter to one of those functions which executes .EXE files.
Also you can examine it by typing name of your .EXE file into run window (Start Menu -> Run) and see what happens.
That's it.
I will expand on what wrote DelphiAssistant (hello ;-)
1) "executing" an URI/URL is perfectly possible but uses the implicit Zindoze file associations to launch the default browser. You ***perhaps*** would like to control more which browser opens for your temporary file, because of the discrepancies between "W3C-Compliant" IE and HTML-Compliant Netscape Navigator (like display table if /table missing, or /td missing, or display FORM if /select missing, etc etc etc).
You perform this by
poubInt:=ShellExecute(Appl
See ShellAPI unit or ShellExecute doc'
2) opening a refreshing "preview" browser is easy :
- if you have a local Apache server with the PHP module, no problemo at all and I will post some code for you, I do this all the time. This can be used on Win32 and on linux.
- if not, then no panic. Javascript can do the trick
Many ideas I have, depending on what you want :
-opening a fixed URL containing a frame that refreshes itself every 2 seconds (that's pretty fast even on localhost, be warned) and the URL/file passed in parameter from inside the Delphi application
-putting the correspondent refresh stuff in the HEADer section of the HTTP response you send to the preview browser. Easy too.
-using PHP is child's play.
3) note also that you could use one of the new components of Delphi >5 that uses an IE OCX or whatever ; that is TWebBrowser I think (never used it)
good luck and tell me the solution you would like me to help you more precisely in ;-)
prodedure speedbutton45click(sender:
begin
filename execute
end;
that is nowhere even close, but i am trying to figure out a simple way to do it, and preferably without saving the file as i would like the user to be able to preview the document and decide where or not they want to save. i think i might go witht the twebbrowser thing if i can figure out how to do it with that. also, this program will be on different computers, so the brower the people use might not be in the same location as mine.
i have practically no experience with delphi, i am actually basing this entire program on the text editor tutorial supplied with the delphi help. i used to do a *very* little pascal, but i was about 10 or 11 then and i forgot all of it but vague basics. thank you.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
(joking)
It's rather easy to perform the ShellExecute command : only one line.
I suggest your delphi program temporarily saves the working file under a fake name (foo.html ? ;-) and then open it for viewing using the shell execute command.
For the auto-refresh (althought I don't recommand it), you can either :
-put an HTML FORM & button or link for the user to manually reload the (temporary) file ; it's basically the same as letting him/her do a "refresh" in the browser
- or insert the usual HTTP_META lines in the HEAD section of the generated HTML file for refresh rate and such
IF I were you, I wouldn't throw the baby with the bath's water
add ShellAPI to your USES clause:
uses
ShellAPI;
Save your html to a temporary file: 'temp.htm'
Then:
ShellExecute(Form1.Handle,
Be sure to check the docs on "ShellExecute" for
info on error returns, etc.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
how should i save as a temporary file? i tried copying the filesave and filesaveas stuff with 2's at the end, but this did not work. i also added temporary to the vars as a string, like i did filename.
thank you so much for your help so far.
MyMemo.Lines.SaveToFile(Ex
This will save the file in the same folder as your App.
i added a speebutton to the form, and then double clicked it, and where the cursor was placed, i typed RichEdit1.Lines.Add.SaveTo






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
//Try this:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender
begin
Memo1.Lines.SaveToFile(Ext
end;
end.
i don't know why it isn't working, but we must be close as we aren't getting an error message, and it compiles just fine.
...now if only i could have a "would you like to save changes you made?" come up like it does on microsoft...i would wnat this when you click save and not onthe preview however.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
this only appears to work when the saved file is in the same directory as my application.
for instance...i was making a webpage, with everything (program, index, and subpages) on my desktop...when i moved them to a different place, they no longer ran when i clicked the preview button, they saved, but would not shell...why is this happening?
Probably best way to handle this is to use the 'FileOpen'
dialog and the 'FileSave' dialog in your application.
Be sure to check the return value of ShellExecute so you can handle any errors appropriately.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
TOpenDialog in the help docs. Also there's plenty of samples in the Demos folder.
for example:
var
sFileName: string;
begin
if OpenDialog1.Execute then { Display Open dialog box }
begin
sFileName := OpenDialog1.FileName;
end;
end;
sFileName contains the full path to the file the user chose in the "Open" dialog.
Delphi
--
Questions
--
Followers
Top Experts
Delphi is the most powerful Object Pascal IDE and component library for cross-platform Native App Development with flexible Cloud services and broad IoT connectivity. It provides powerful VCL controls for Windows 10 and enables FMX development for Windows, Mac and Mobile. Delphi is your choice for ultrafast Enterprise Strong Development™. Look for increased memory for large projects, extended multi-monitor support, improved Object Inspector and much more. Delphi is 5x faster for development and deployment across multiple desktop, mobile, cloud and database platforms including 32-bit and 64-bit Windows 10.