Solved

TWebBrowser??

Posted on 2001-08-01
4
193 Views
Last Modified: 2010-04-06
I just updated to Delphi 4 standard (from Delphi 2) and am trying out a few things with it.

I saw a short article on the web about adding in the Microsoft Internet Controls so i followed the instructions and now have two new components:

WebBrowser_V11:TWebBrowser_V1
WebBrowser1:TWebBrowser

My problem:

(1) I understand that the TWebBrowser can be used for displaying web pages, etc but what is the other component and the limitations of both of them (ie: can i display html files which contains javascript, graphics, etc?)

(2) Can anyone show me how to use the TWebBrowser to do such things as load html files from disk, display scroll bar if required only, etc.

I am completely new to this.





0
Comment
Question by:foxjax
  • 3
4 Comments
 
LVL 1

Expert Comment

by:h_mohsenian
ID: 6341237
listening ...  :-)


( just say : you can Call IE from your Delphi App that means you can write your HTML file by Delphi App then call IE by this procedure : )


procedure OpenInternetExplorer( sURL : string );
const
  csOLEObjName = 'InternetExplorer.Application';
var
  IE        : Variant;
  WinHanlde : HWnd;
begin
  if( VarIsEmpty( IE ) )then
  begin
    IE := CreateOleObject( csOLEObjName );
    IE.Visible := true;
    IE.Navigate( sURL );
  end else
  begin
    WinHanlde := FindWIndow( 'IEFrame', nil );
    if( 0 <> WinHanlde )then
    begin
      IE.Navigate( sURL );
      SetForegroundWindow( WinHanlde );
    end else
    begin
      // handle error ...
    end;
  end;
end;


best regards
hamed
0
 
LVL 1

Expert Comment

by:h_mohsenian
ID: 6341262
also you can see an standard Delhi demo about your need :

see Delphix\Demos\coolstuf\webbrows

i think it is an complete Demo App for TWebBrowse. although I never saw him until now that I search !;-)

best regards
hamed
0
 
LVL 1

Expert Comment

by:h_mohsenian
ID: 6341267
ops . i told him instead of it ;-)
0
 
LVL 6

Accepted Solution

by:
edey earned 250 total points
ID: 6341340
(1) I understand that the TWebBrowser can be used for displaying web pages, etc but what is the other
component and the limitations of both of them (ie: can i display html files which contains javascript,
graphics, etc?)

It has exactly the same limitations/abilities as Internet Explorer

(2) Can anyone show me how to use the TWebBrowser to do such things as:

a)load html files from disk

webBrowser1.navigate(some_url);
any url is valid, try www.experts-exchange.com or even a local file.  You can even navigate to 'about:blank' or 'about: <html><body>hi<br><b><i><font size=40 color=red>bye</font></i></b></body></html>'

b)display scroll bar if required only, etc.

Hmm, it'll only display the horz scrollbar when needed & I'm sure there's a way to do that for the vert one as well, but I don't know off hand.

You might also want to note that you can access the current document like so:

var
 doc : variant;
begin
 doc := webBrowser1.document;
 doc.write('<p>why hello there</p>');

members.home.com/hfournier is a good place to look for ie with delphi info.  You can also script the control like this:

scriptControl1.addObject('doc',webBrowser1.document,true);
script.eval(edit1.text);

GL
Mike

0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Using idhttp to login to instagram 2 117
Delphi IDE crash without error message ... 7 113
Working with hours 3 72
firemonkey Android Listview Sort items 7 70
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

679 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