Solved

Communication between Delphi Application and the Default Web Browser

Posted on 2004-08-25
6
397 Views
Last Modified: 2010-04-05
Hello Experts,

How does a Delphi application communicate with the Default web browser? Let me explain the scenario. I use TIdHTTP from the Delphi app to submit variables to a PHP script called "test.php" located in 'http://anywhere/", which in turn dynamically creates the HTML code for display of a web page. This part works fine. Now the jackpot question: How do I open the DEFAULT WEB BROWSER (IE , Netscape, Opera, whatever) with the web page dynamically created by test.php? I cannot use the TWebBrowser component because it only caters for IE and therefore eliminates users with any other web browser besides IE. I have a feeling that ShellAPI or something similar could be used for this, but it probably wouldn't be straightforward. If ShellAPI is somehow the answer, I would need some example code to see the syntax.

Can anybody help?
0
Comment
Question by:JDJVR
6 Comments
 
LVL 12

Assisted Solution

by:Ivanov_G
Ivanov_G earned 100 total points
ID: 11892634
save the HTML generated by test.php to TEMP file and open in default web browser using ShellExecute...
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 11892656
0
 

Expert Comment

by:BaTy_GiRl
ID: 11893253

add to uses list ShellAPI

First you need to find out where is the path of you Iexplorer, or netscape my path is in Program Files

then the syntax of shell execute is


if ShellExecute(Self.Handle, nil, 'C:\Program Files\Internet Explorer\IEXPLORE.EXE','C:\readme.htm', nil, SW_SHOWMAXIMIZED) <= 32 then
    Application.MessageBox('Couldn''t execute the application','Error', MB_ICONEXCLAMATION);

where  the C:\readme.html is the file i want to open, if you want to open a file from http, just quit the C:\

Best Wishes
   B@ty



0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:JDJVR
ID: 11897489
Thanks - the TEMP file solution should work, but is there any way to avoid having to save a TEMP file and still use ShellExecute?
0
 
LVL 12

Accepted Solution

by:
Lee_Nover earned 100 total points
ID: 11899891
I'd setup a HTTP server in my app (just add a TIdHTTPServer compo and set a "random" port)
get the php returned page, save it (in memory) then ShellExecute with the url having the ID of this page like: 'http://localhost:someport/?id=someid'
in the request handler of the http server just check for the id and stream the result back :)

avoiding saving to a file but will have to provide an open port
don't see any other alternatives (yet)

:)
0
 

Author Comment

by:JDJVR
ID: 11900166
Thank you, everybody. I think I will be able to do what I need to with the feedback you have given me. I'll split the points between Ivanov G and Lee Nover. I have another question which is about communication from the web page back to the Delphi app via PHP (I think I may have an idea how to do it) but I will post it as a separate question later if needed.

Cheers!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now