Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

To Load a HTML into any object(Made me crazy)!! 1

Status
Not open for further replies.

ozgurtekin

Programmer
Apr 22, 2003
17
TR
Hi
I tried to load a html in my computer into a THTML but it didn't work because the computer tries to connect to the internet. When I cancel it cannot load the page.(the page is on my computer)
I used this
HTML1.RequestDoc('FileName');
 
What are you trying to load the HTML file into?

What are you planning to do with the HTML code?

You can load an HTML file into a TRichEdit using the following line of code:
Code:
RichEdit1.Lines.LoadFromFile('C:\temp\myfile.html');

Hope this helps

Clive [infinity]
Ex nihilo, nihil fit (Out of nothing, nothing comes)
 

I am trying to browse and see how the html looks like in a browser
It is ok if you tell me how to open a html file in the default browser.
 
Drop a TWebBrowser on your form and use this code to show the html page:
Code:
WebBrowser1.Navigate('C:\temp\myfile.html');

Clive [infinity]
Ex nihilo, nihil fit (Out of nothing, nothing comes)
 
This could help if I had Delphi 5.0 or higher
but there is nothing called a web browser in Delphi 4
What can I do.
The thing I am trying to do is to see the html tags in Memo as a proper Page.

 
Use:

Code:
HTML1.RequestDoc(file://localhost/YourFile);

"YourFile" could be, for example:

D:\0Temp\MyFile.html (It must be a whole Path + FileName)

Hope this helps!



 
I tried it but tries to connect to the internet.
Thats why I cant do it

 
Hi

I am a new member.

I posted a reply before, but my reply doesn't appear, so it seems I did it wrong.

Let's see if I do it right this time.

Try this:

HTML1.RequestDoc(file://localhost/YourFileName);

YourFileName can be, for example:

D:\0Temp\Hello.html
(note the difference in slashes!)

You must give the complete Path + FileName.

Once you have loaded the document, if you want to see the Document Source, use a Memo or RichEdit control to do the following:

Memo1.Lines.Clear;
Memo1.Lines.Add(HTML1.SourceText);

I hope this is what you are looking for.
 
That worked (thank you)
BUT
the html item doesnt use the colors of the document instead it uses its own(example: background);

Can you solve this or
if you tell me how to open a html document with the default browser thats fine
 
why dont you simply use

ShellExecute(handle,'open','c:\test.htm',nil,nil,1);


of course add SHELLAPI to your uses clause

:)

 
The incorrect colours could be because the web-page uses css (cascading style sheets) to define its' colours and styles. This data is normally stored in a separate file which you probably don't have access to.

Clive [infinity]
Ex nihilo, nihil fit (Out of nothing, nothing comes)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top