Note: For now you must turn off integrated debugging to use the beta versions of Microsoft's Internet controls. To turn off integrated debugging, select Tools | Options, and click off Integrated Debugging in the Debugging Section of the Preferences tab.
Bake (hit the F9 key) approximately 3-5 seconds or until the browser
is golden brown. Serve warm with the fresh blackberries and the
cold beverage of your choice. Type an URL into the ComboBox and
hit the Enter key. Navigate around the web. Drop down the ComboBox
arrow and notice that the browser is saving unique URL's in the
ComboBox list of items.
Yield:
One Blackberry Internet Browser per developer.
Variations:
Fresh Blueberry Internet Browser: Substitute one cup blueberries
for the blackberries.
Fresh Blackberry Internet Browser OLE Automation Server and Controller: Delphi 2.0 supports both OLE Automation Servers and Controllers. What better way to illustrate this than by extending the browser to be an OLE Automation Server and then build an Automation Controller to drive it. Use the following cooking instructions to add the
server support and create the controller.
Simmer the fresh blackberry browser: From Delphi choose File | SaveAll. Save the unit file as Mainunit. Save the project file as WebApp.
Fold an automation object into the browser: Choose File | New
to bring up the object repository. Double-Click on the Automation
Object (brings up the OLE Automation Server Expert). Type TAppObject
into the class name edit box (the OLE class name will be filled
in automatically as WebApp.TAppObject). Type in a description
for your blackberry browser. Leave the Instancing ComboBox set
to Multiple Instance. Click the OK button to close the expert.
Blend in the declaration of the automation method: Add a method
declaration to the automated section of the TAppObject class declaration:
procedure GotoPage (PageName: string);
The automated section contains the methods and properties we want
to expose through OLE Automation. The line of code above creates
a GotoPage method that will select a given HTML page.
Toss in the code to implement the method: After the Implementation
keyword add the following lines of code:
uses Mainunit;
procedure TAppObject.GotoPage(PageName: string);
begin
Form1.HTML1.RequestDoc(PageName);
end;
Simmer (hit the F9 key) the OLE Automation Server enhanced Fresh
Blackberry Internet Browser: Your server automatically enters
itself in the system registry and is running and ready to be controlled.
Beat in an OLE Automation Controller for the Browser: From Delphi,
File | SaveAll the browser server project. Save the automation unit file as Autounit. Choose File | New Application to start the browser automation controller. Shrink the form down to a size small enough to hold a Button and an Edit box. Drop down an Edit box at the top center of the form. Widen the Edit box to taste. Clear the Text property of the Edit box. Drop down a Button below the Edit box. Change the Button caption to 'Goto'. Double Click on the Button to add the event handling code. Add the following lines to make the implementation of the Button click method look like the following:
procedure TForm1.Button1Click(Sender: TObject);
var
Browser: Variant;
begin
Browser := CreateOleObject('WebApp.AppObject');
Browser.GotoPage(Edit1.Text);
end;
Sprinkle a little sugar on the controller: Add a uses OleAuto;
statement right after the unit's implementation keyword.
Bake (hit the F9 key) the OLE Automation Controller: type a URL
into the Edit box. Click the Goto Button and watch the Fresh
Blackberry Internet Browser Automation Server display that page.

Look for further additions to the cookbook in future editions
of Sip from the Firehose (or SipFH as some of you are
calling it in your email correspondence). Maybe I should create
my own Sunday morning "Cooking with Betty Hacker" TV
show? If you have developer recipes of your own, send them along.
Happy Cooking!
davidi@inprise.com
|