File Explorer header  
Version version number
Software Software copyright
www.capesoft.com
Updated 16 November 2005
     
   
fe browser icon

FeBrowser

   
Contents
   
 
 
bullet small The FeBrowser Object
 

Methods - Functional Reference Listed by Usage (New)
Methods - Alphabetized Quick Reference
Events
 

bullet small The Templates
 

Overview
 

bullet small Useful References
 

Summary of callback events (Updated)

How to load and print a page in the background and then close the FE window

Radio buttons - how to determine which one is currently selected on a page.

Leveraging the power of the HTML DOM with JavaScript and FileExplorer (New)

How to open Word document inside Internet Explorer, and hence inside FileExplorer (New)

How to remove parts of a loaded page before displaying it to the user (New)

 
     

horizontal rule

bullet File Explorer Classes - FeBrowser

HTML browser icon Formerly known as the Html3 (or Html1 using COM) file type / object, the FeBrowser Object is used to browse html pages. This object acts in the same manner as Internet Explorer, so most things that work in IE work well with the feBrowser object. For example you can load a PDF into the feBrowser the same as you would in Internet Explorer.

bullet smallFeBrowser - Methods

Functional Reference - Methods Listed by Usage
  This list organizations the above methods by their functional use and describes them briefly. See the list below for an alphabetized quick reference.
Navigation and Loading  
Back Go to the previously loaded page - navigates to the previous page on the navigation stack.
Forward Go forward through the navigation stack (only applies if Back() has been used at least once.
Load Loads an URL or file into the control
Refresh Refreshes the currently loaded page and provides control over how the refresh is done
Reload Load the currently loaded page or file again
Stop Stops the current navigation
LoadFromStream (New!) Loads the Browser from memory
Home Navigates to the Home page set in the Internet Explorer settings
   
Event Handling  
EventCallback This gets called with each event that the Browser control fires. There are also individual callback methods for handling specific events. See Summary of callback events for more information.
TranslateEventID Translates an Event ID passed to the EventCallback method into a string that describes the event. This is done automatically in the specific event callback methods. See Summary of callback events.
   
Control Management  
HideControl Hides the Browser control. Hiding the Clarion Region control populated by the template will have no affect on the browser control.
UnhideControl Unhides the Browser control.
Resize Resizes the browser control. If you are populating the control using the template (the normal method of using the Browser control) then this is called for you when the window resizes if you have enable resizing in the template settings.
SetFocus Sets the focus to the window and the Browser.
   
Browser Management  
GetInfo Retrieves a property of the Browser, such as the contents of the loaded document, the title of the page etc.
Update Updates a property of the Browser
   
Maintenance  
Init Intialises the Browser control
Kill Disposes the Browser and cleans up the interface and all handles etc.
   
Frames  
NameOfFrame Returns the name of a frame that is part of the frameset in an HTML page.
NumberOfFrames Returns the number of frames in an HTML page.
   
HTML DOM (Document Object Model) Methods to allow the objects in an HTML page to manipulated. This allows each tag, input, button etc. to be treated as an "object" on the page and hence controlled.
ClickByName Click on any object on the page based on the object name. Not all tags are named, this uses the Name attribute and will only work for named tags.
ClickByRecordNumber "Clicks" on any object on the page based on it's record number in the queue of object populated by calling .GetElementQ(). This allows anything on the page to be clicked on, regardless of whether it has a name or ID.
GetElementQ Populates a queue of all element (objects) on a page. This queue contains all the HTML tags and their values. For elements such as form inputs that may contain a large amount of data this method is limited in the amount of data that it retrieves. The entire value regardless of size can be retrieved using GetValueByID and GetValueByName.
GetValueByID Retrieved the value of an element using the element name to locate it.
GetValueByName Retrieved the value of an element using the element ID to locate it.
SetValueByID Sets the value of an element on the page, the ID is used to locate the element.
SetValueByName Sets the value of an element on the page, the name is used to locate the element.
SubmitForm Submits a particular form on an page. The SetValue methods allow forms to be filled and this submits the form without the ClickByName or ClickByID methods having to be used and the form submission method determined.
   
Tool functions  
SearchPage Searches the page for a string
Edit Provides access to the Edit command such as Cut, Copy, Paste etc.
PrintMe Prints the currently loaded page, either with out without user interaction. See How to load and print a page in the background and then close the FE window for an example.
GetHtmlGraphicsInfo Retrieves a list of all image used in a loaded page, including their paths.
   
 
     


Quick Reference
 
Back LoadFromStream (New!)
ClickByName NameOfFrame
ClickByRecordNumber NumberOfFrames
Edit PrintMe
EventCallback Refresh
Forward Reload
GetElementQ Resize
GetHtmlGraphicsInfo SearchPage
GetInfo SetFocus
GetValueByID SetValueByID
GetValueByName SetValueByName
HideControl Stop
Home SubmitForm
Init TranslateEventID
Kill UnhideControl
Load Update
 
     


 

horizontal rule

Back     ( ) ,byte,proc

ThisViewer.Back()

  • Same effect as the "Back" button in Internet Explorer.
  • Returns a byte indicating success (1) or failure (0).

up icon

horizontal rule

ClickByName     ( string ElementName, long FrameNumber=0, long NameInstance=0) ,byte,proc

ThisViewer.ClickByName('Button1')
ThisViewer.ClickByName ('Button1', 2)

  • See the GetElementQ method to understand the context of this method.
  • Use this method when you have a button in an html page that you want to be able to "click" from within your own code (cool!).
  • To see this code in action, have a look at the "Advanced_feBrowser_DOM" example in the feabc.app example application.
  • Use the NameInstance parameter to specify which button to click if there is more than one button with the same name in the same frame.  If you do not use this parameter then the first button found which matches the ElementName parameter will be used.

up icon

horizontal rule

ClickByRecordNumber     ( long pRecordNumber, long pFrameNumber=0 ) ,byte,proc

ThisViewer.ClickByRecordNumber (5)

  • See the GetElementQ method to understand the context of this method.
  • Use this method when you have an image (IMG) in an html page that you want to "click", but the image has no NAME (which is normally the case).  Use the GetElementQ method to find the element's RecordNumber, which can then be used in this method to "click" the image from your code...
  • NOTE: This method should also work with Input elements, although this has not been extensively tested.
  • To see this code in action, have a look at the "Advanced_feBrowser_DOM" example in the feabc.app example application.

up icon

horizontal rule

Edit     (long EditType, long pAction = 0, <string pValue>) , byte, proc

The Edit method is used to call various "Editing" commands. These range from command that are in the Edit menu of the browser such as "Copy", "Paste", "Cut", "Undo" and so on to those that are in the File menu, such as "Save", "Print", "Close" and so on.

Parameters

long EditType

An equate that specifies what action the Edit method needs to perform. The values for this equate are as follows:

fe:Browser_Save The same as the File->Save command, saves the contents of the Browser control to a file. This has no effect on the Browse control unless the contents of the page have been modified
fe:Browser_SaveAs File->Save As. The same as the Save command, but with the opportunity to set the file name, and to optionally to prompt the user for a file name (dependant on the value of the pAction parameter, see below). Note: unfortunately the Web Browser control always displays a dialog box, and ignores the value of the pValue parameter passed. We have implemented this interface with support for the parameters, however unless the MS control is modified it will continue to behave in this fashion.
fe:Browser_Print File->Print. Prints the document, again the behaviour of the print command and whether the print options dialog is displayed is controlled by the pAction parameter.
fe:Browser_PrintPreview File->Print Preview. Displays the Print Preview dialog box. This has been greatly improved with IE7.
fe:Browser_PageSetup File->Page Setup. Displays the Page Setup dialog box.

fe:Browser_Properties

File->Properties. Displays information about the currently loaded page.

fe:Browser_Cut

Edit->Cut (not exposed in IE itself). Cuts the current selection (removes it from the browser and places it on the clipboard). Unlike a standard browser, the FE browser actually allows you to remove content from a document.

fe:Browser_Copy

Edit->Copy. Copies the current selection to the clipboard.
fe:Browser_Undo Edit->Undo (not exposed in IE itself). Undoes the last action, typically not used for the Browser control, unless you are using the Cut or Delete actions (which are not typically used with the Html Browser).
fe:Browser_Redo Edit->Redo (not exposed in IE itself). Redoes the last action that was undone using the Undo command. If no Undo has been performed this has no effect whatsoever. You can cycle through the "undo" list using the Undo and Redo commands to move back and forth through the performed actions.
fe:Browser_SelectAll Edit->Select All. Selects everything within the browser control.
fe:Browser_ClearSelection Edit->Clear Selection. Deselects everything, so that nothing in the control is selected.
fe:Browser_Find Edit->Find. Displays the Find dialog and allows the user to type a string to locate within the loaded document. Each time the Find button is pressed the next instance of the string is located and selected.
fe:Browser_Delete Edit->Delete (not exposed in IE itself). Deletes the current selection (removes it from the document).
fe:Browser_StopDownloading Equivalent to pressing the Stop button in IE. This stops the current document from loading.
fe:Browser_CloseDocument File->Exit (no exact equivalent command in IE). Closes the current document, in the case of FileExplorer this does not close the Window that the FE control is on, it simply closes the loaded document and displays a blank page.

 

long pAction = 0 (optional)

The optional second parameter allows you to specify how the command is executed for commands that normally require user feedback. For example the fe:Browser_SaveAs action normally displays a Save As dialog box, you can circumvent the display of the dialog by passing pAction as fe:OLECMDEXECOPT_DONTPROMPTUSER as the second parameter.

There are four possible values for this parameter:

fe:OLECMDEXECOPT_DODEFAULT (0)
Prompt the user for input or not, whichever is the default behavior.

fe:OLECMDEXECOPT_PROMPTUSER (1)
Execute the command after obtaining user input.

fe:OLECMDEXECOPT_DONTPROMPTUSER (2)
Execute the command without prompting the user. For example, clicking the Print toolbar button causes a document to be immediately printed without user input.

fe:OLECMDEXECOPT_SHOWHELP (3)
Show help for the corresponding command, but do not execute.

string pValue (optional)

The third parameter allows a value to be passed for those actions that require one, or can optionally use one. For example the SaveAs action allows the file name to save the document to, and in combination with the pAction set to fe:OLECMDEXECOPT_DONTPROMPTUSER this would save the document to a specific file name, without prompting the user.

Currently supported actions:

fe:Browser_SaveAs - is documented as supporting this property, however the implementation of the COM object does not use the passed path unfortunately, and does not respect the value of the pAction parameter (a dialog is always displayed).

Return Values

Returns a byte indicating success (1) or failure (0).

Example:

    !--- Copy the entire loaded document onto the clipboard
    ThisViewer.Edit(fe:Browser_SelectAll)
    ThisViewer.Edit(fe:Browser_Copy)        

    !--- Note that the below example could be done simply by calling the feBrowser.PrintMe() method:

    !--- Print the document without displaying the "print" dialog box
    ThisViewer.Edit(fe:Browser_Print, fe:OLECMDEXECOPT_DONTPROMPTUSER)    

              

up icon

horizontal rule

EventCallback     ( long EventID, *cstring EventString, <*cstring Parm1>, <*cstring Parm2>, <*cstring Parm3>, <*cstring Parm4>, <*cstring Parm5>, <*cstring Parm6>, <*cstring Parm7> ) ,long

Typically you would never use this method, FileExplorer provides a number of callback method for you to embed code in that provide a neat and clear approach to responding the events that the Browser control produces. See Summary of callback events for more information. For an example of using a callback method see the "How to Print a web page in the Background" example at the end of this document.

    Technical Information:

    Because File Explorer uses COM (not the Clarion OLE control) for this object, callback functionality is not implemented using the standard Clarion "callback embeds".  Instead we have made this method, which you can simply override (the templates do this for you).  The method is then "called" by File Explorer each time a callback event fires.  The logic flow is as follows:

  1. Internet Explorer fires an event
  2. File Explorer "catches" that event, and the File Explorer dll calls the FeBrowser::EventCallback method
  3. Any code in your app, before the call to parent.EventCallback runs
  4. File Explorer processes the code inside the FeBrowser::EventCallback method (you have no control over this)
  5. Any code in your app, after the call to parent.EventCallback runs
  6. Your app returns from the EventCallback (virtual) method, and depending on the value of "ReturnVar" which your app returns, File Explorer will act accordingly
  • Things you can do with this functionality include knowing when a page has finished loading, when a user clicks on something on a page, implementing a status bar etc etc etc.
  • Have a look at the "Advanced_feBrowser_SimpleCallbacks" procedure in the feabc.app example application to see how this works.
  • For more info on the various events and associated parameters, click here.
  • NOTE:  In order to implement Event Callbacks you need to activate them from the Viewer Control's properties tab.
  • See Summary of callback events for more information

up icon

horizontal rule

Forward     ( ) ,byte,proc

ThisViewer.Forward()

  • Same effect as the "Forward" button in Internet Explorer.
  • Returns a byte indicating success (1) or failure (0).

up icon

horizontal rule

GetElementQ     ( <string TagName>, fe:QParam_Type QParm, long FrameNumber=0 )

ThisViewer.GetElementQ ('input', locMyQ )  ! scan for all "input" elements
ThisViewer.GetElementQ ( , locMyQ )  ! scan for all elements
  • This method then scans though the loaded html page for all elements (think "objects") which have TagNames (think "the catagory of the elements") which match the parameter you passed as "TagName".  So if you pass "input" for instance, it will pick up all the "input" elements in the html.
  • Once it has scanned the loaded html document for all elements (objects) of the type you passed as "TagName", it then populates this information (a list of the elements that were found) into a queue, which you pass as the second parameter, "QParm".  You can then process this queue from your own code to get whatever data you need.
  • So to summarize, you pass this method two things.  First there is a cstring which contains the TagName you're searching the loaded document for.  This could be something like "input", "form", "meta" or whatever.  If you omit this parameter, then all elements (objects) are looked for.  The second parameter is the name of the queue (which you must create in your app) which is to receive the list of elements.  This queue should be declared as type "fe:QParam_Type" which is declared in fe.inc as follows:

    fe:QParam_Type   queue,type
    RecordNumber         long
    ElementName          string(256)
    ElementID            string(256)
    ElementType          string(256)
    TagName              string(256)
    ElementValue         string(2048)
    ElementValue2        string(2048)
    ElementValue3        string(2048)
    ElementValue4        string(2048)
    ElementValue5        string(2048)
    CheckedStatus        byte
                     end
  • The FrameNumber parameter can be used if you have a loaded document which contains frames.  This parameter is passed as 0 (zero / false) by default, indicating that the document contains no frames.  If the document which you're working on does contain frames, pass this value as a number to work with any one of the frames.  For instance, passing "1" will work with the first frame, "2" with the second frame and so on.  Use the "Advanced_feBrowser_DOM" example mentioned below to test a page to see which frame number relates to which frame.
  • The RecordNumber field (returned in the queue) is simply an auto-incrementing long.. The first element that File Explorer finds will be "1", then next one will be "2" and so on..  Don't use this field in your code as if the html page ever changes then these numbers could also change (element "4" could become element "5" for instance).
  • The ElementName field (returned in the queue) is the name of the element, assuming the element has a name
  • The ElementID field (returned in the queue) is the ID (number) of the element, assuming that it has one
  • The ElementType field (returned in the queue) is the element's "Type".  e.g. "text", or "hidden"
  • The TagName field (returned in the queue) is the name of the html tag surrounding the element, e.g. "META" or "IMG"
  • There are also five ElementValue fields (returned in the queue), which return useful data for each element.
  • The CheckedStatus field (returned in the queue) only applies to check boxes and returns their checked status.
  • To see this in action, have a look at the "Advanced_feBrowser_DOM" procedure in the feabc.app example application.

up icon

horizontal rule

GetHtmlGraphicsInfo     ( *string HtmlSource ) , string

ThisViewer.GetInfo()  ! updates ThisViewer.Source
TempString = ThisViewer.Source  ! needed only for the next line
ThisViewer.GetHtmlGraphicsInfo (TempString)  ! updates the Source and Graphics list properties
ThisEmailSend.MessageHtml = ThisViewer.Source
ThisEmailSend.EmbedList = ThisViewer.GraphicsList

  • This method was written primarily to make it easier to use File Explorer with NetTalk, to create and send emails.
  • The idea is that you use File Explorer to create / view an email (html).
  • To send this email (using NetTalk), you need to set several NetTalk properties.  Two of these properties are a comma separated list of graphics in the html (ThisEmailSend.EmbedList), and a modified version of the html code (ThisEmailSend.MessageHtml), where image paths are changed from qualified paths to paths prefixed with "cid".
  • This File Explorer method simply updates two File Explorer properties, self.Source and self.GraphicsList.
  • Also look at the notes below on the "RootFolder" property.
  • The code above gives a rough idea how this works, for a detailed example see the fenetalk.app example that ships with File Explorer.

up icon

horizontal rule

GetInfo     (  )
or
GetInfo     ( string Parm1, long FrameNumber=0 ) ,*cstring,proc

( see below for examples )
  • This method is used to find things out about the loaded document.  The method works by either updating a class property, or by returning a pointer to a cstring which contains information, or sometimes by doing both.
  • If you call the method without passing any parameters ( ThisViewer.GetInfo( ) ), then the method will update all the properties that it supports (not recommended).
  • If you call this method and pass something in the Parm1 parameter, then only one property (determined by what you pass as this parameter) will be updated (recommended).  Below follows a list of equates which you can pass, along with the name of the property that will be updated:
    • fe:LocationURL  - ThisViewer.GetInfo_LocationURL  (and ThisViewer.URL for backward compatibility)
    • fe:LocationName  - ThisViewer.GetInfo_PageTitle  (and ThisViewer.PageTitle for backward compatibility)
    • fe:DocumentType  - ThisViewer.GetInfo_DocumentType  (and ThisViewer.DocumentType for backward compatibility)
    • fe:BusyStatus  - ThisViewer.Busy
    • fe:InnerText - ThisViewer.GetInfo_InnerText
    • fe:OuterText - ThisViewer.GetInfo_OuterText
    • fe:InnerHTML - ThisViewer.GetInfo_InnerHTML
    • fe:OuterHTML - ThisViewer.GetInfo_OuterHTML

    The following equates / properties are not currently supported:

    • fe:ClassName - ThisViewer.GetInfo_ClassName
    • fe:ID - ThisViewer.GetInfo_ID
    • fe:TagName - ThisViewer.GetInfo_TagName
    • fe:Language - ThisViewer.GetInfo_Language
    • fe:Lang - ThisViewer.GetInfo_Lang
    • fe:offsetLeft
    • fe:offsetTop
    • fe:offsetWidth
    • fe:offsetHeight

    Note that in addition to these properties being updated, the values which they are updated with are also returned an a *cstring.  So the following code does the same thing ( i.e. The three messages below will all show the same result ):

    ThisViewer.GetInfo ( fe:LocationURL )
    message (ThisViewer.URL )

    or:

    Loc:CStringPointer  &CSTRING
    ...
    Loc:CStringPointer &= ThisViewer.GetInfo ( fe:LocationURL )
    message ( ThisViewer.GetInfo_LocationURL )
    message ( Loc:CStringPointer )

    Note that you should never write to a cstring which is returned to you, or to any of the properties (above): these values should be treated as read-only.  Note also that you do not need to "new" or "dispose" anything here, all the "new-ing" and "dispose-ing" is taken care of for you inside the library.

  • Note that the GetInfo method is getting information about the loaded document at a moment in time.  So if you want to get the same information ( say the name of the loaded document ) every 5 seconds, you should call GetInfo every 5 seconds to make sure you have the latest information.
  • The FrameNumber parameter can be used if you have a loaded document which contains frames.
  • To see this method in action, have a look at the "Advanced_feBrowser_GetInfo" procedure in the feabc.app example application.

up icon

horizontal rule

GetValueByID     ( string ElementID ) ,*cstring

MyCStringPtr &= ThisViewer.GetValueByID ('id5')

  • See the GetElementQ method to understand the context of this method.
  • Use this method when you know the ElementID (each element (think "object") in an html page has its own ElementID), and want to establish its value.  For instance, if you have loaded an html page which has an entry field on it where users enter their last names, so long as you know that entry field's ElementID you can use this method to "read" the value from that field.  To elaborate, if you have an entry field in an html page as follows...
<input id="id5" type="text" name="LastName" size="20">
  • ... you could actually read what the user types into this html field by using the code at the top of this section.
  • To see this code in action, have a look at the Advanced_feBrowser_DOM procedure in the feabc.app example application.

up icon

horizontal rule

GetValueByName     ( string ElementName, long FrameNumber=0 ) ,*cstring

MyCStringPtr &= ThisViewer.GetValueByName ('LastName')

  • See the GetElementQ method to understand the context of this method.
  • Use this method when you know the ElementName (each element (think "object") in an html page has its own ElementName), and want to establish its value.  For instance, if you have loaded an html page which has an entry field on it where users enter their last names, so long as you know that entry field's ElementName you can use this method to "read" the value from that field.  To elaborate, if you have an entry field in an html page as follows...
<input id="id5" type="text" name="LastName" size="20">
  • ... you could actually read what the user types into this html field by using the code at the top of this section.
  • To see this code in action, have a look at the Advanced_feBrowser_DOM procedure in the feabc.app example application.

up icon

horizontal rule

HideControl     ( )

ThisViewer.HideControl ()

  • Hides the File Explorer viewer control.  Note: ?feControl{prop:hide} = true will not work.

up icon

horizontal rule

Home     ( ) ,byte,proc

ThisViewer.Home()

  • Same effect as the "Home" button in Internet Explorer.
  • Returns a byte indicating success (1) or failure (0).

up icon

horizontal rule

Init     (long ParentControl, <string LoadPath>, long Handle1=0, long Handle2=0, byte SkipCallbacks=false) ,byte,proc

ThisViewer.Init (?feControl)
ThisViewer.Init (?feControl, 'www.CapeSoft.com',,,true)

  • Handles initialization for the object, must be called before you call any other methods.
  • The ParentControl parameter is your File Explorer window control.
  • Four of the five parameters are optional.
    • The LoadPath parameter will load a document into the object once initialization is complete
    • The Handle1 and Handle2 parameters should not be passed.
    • The SkipCallbacks parameter determines whether the object will be initialized with callback function support.
  • This method returns a byte indicating success (1) or failure (0).

up icon

horizontal rule

Kill    ( byte level=0 ) ,byte,proc

ThisViewer.Kill()

  • Handles the "closing down" of the feBrowser object.
  • Must be called (typically) as the window which hosts the object is closed.
  • Do not pass anything as the "level" parameter, leave it to default to 0.
  • This method returns a byte indicating success (1) or failure (0).

up icon

horizontal rule

Load  (string CurrentPath, <long CurrentControl>, <string pFlags>, <string pTargetFrameName>, <string pPostData>, <string pHeaders> ) ,byte,proc

Loads a document (passed as the CurrentPath parameter) into the html viewer control.

Parameters

  • string CurrentPath: The URL to navigate to. This can be the address of a web site, the path to a document on disk etc.
  • long currentControl: (Optional) The control to load the document into. If the CurrentControl parameter is omitted, the control which you passed in the Init() method is used.
  • long pFlags: Currently unsupported. (Optional) Specifies whether to add the resource to the history list, whether to read from or write to the cache, and whether to display the resource in a new window
  • string pTargetFrameName: (Optional) Used to set which frame the document will load into. Have a look in the feabc.app example, in the procedure called "Advanced_feBrowser_Frames1" to see how this is implemented.  Possible values are:

_BLANK: Load the link into a new unnamed window.
_PARENT: Load the link into the immediate parent of the document the link is in.
_SELF: Load the link into the same window the link was clicked in.
_TOP: Load the link into the full body of the current window.
<WINDOW_NAME>: A named HTML frame. If no frame or window exists that matches the specified target name, a new window is opened for the specified link.

  • string pPostData: Currently unsupported. (Optional) Specifies data to send with the HTTP POST transaction. If you omit this parameter File Explorer does a HTTP GET. Support for this parameter is currently not working and will be added to a future release of File Explorer.
  • string pHeaders: (Optional) Used to send HTTP headers to the server, which will be added to the default Microsoft Internet Explorer headers.

Return Value

Returns a byte indicating success (1) or failure (0).

Examples

ThisViewer.Load('www.CapeSoft.com')
ThisViewer.Load('
www.CapeSoft.com',,, '_top')
ThisViewer.Load('
www.CapeSoft.com',,, 'BannerFrame')

up icon

horizontal rule

LoadFromStream  (*cstring szHtml)

Loads the Browser control from a string in memory. This can be used to load web pages stored in BLOB, HTML contents directly back into the browser and using .GetInfo() to retrieve the content, modifying it, and then .LoadFromStream() to update the contents of the browser etc.

Parameters

*cstring szHtml: A cstring (null terminated string) that contains the HTML to load. This parameter is passed by address, but is not modifying by the function.

Return Value

This method has no return value.

Note: If an error occurs then the error information will be output to the system debug log (this and all other debug information can be viewed using SysInternals DebugView, available from www.sysinternals.com.)

Examples

htmlData       cstring(4096)  
! Note: Typically the string should be dynamically allocated unless the exact size is known.
  code
    htmlData = '<html><head><title>Loaded From Memory</title></head>' |
               & '<body bgcolor="white"><h1>Hello World</h1>' |
               & '<p>Loaded from memory!</p></html>'

    feWebBrowser.LoadFromStream(htmlData)

up icon

horizontal rule

NameOfFrame     ( long FrameNumber ) ,string

frameName  STRING(20)
  code
   
frameName  = ThisViewer.NameOfFrame(2) ! returns the name of frame 2

  • Returns the name of a frame.
  • See the Advanced_feBrowser_GetInfo procedure in the feabc.app example application to see this method being used.

up icon

horizontal rule

NumberOfFrames     ( ) ,long

totalFrames      long
  code
    totalFrames = ThisViewer.NumberOfFrames()

  • Returns the number of frames in the currently loaded document.
  • See the Advanced_feBrowser_GetInfo procedure in the feabc.app example application to see this method being used.

up icon

horizontal rule

PrintMe     ( byte ShowDialog=true ) ,byte,proc

  ThisViewer.PrintMe()
or
  ThisViewer.PrintMe(false)

  • Prints the loaded document.
  • If you pass true (1) as the ShowDialog parameter, the "Print Options" dialog window is called.  If you pass false (0), the document is printed immediately.
  • Returns a byte indicating success (1), or failure (0).

up icon

horizontal rule

Refresh (byte Level = fe:Browser_RefreshLevel_Default), byte, proc

Provides the same effect as the "Refresh" button in Internet Explorer. This forces the control to reload the page from the server, the parameter will determine how the refresh is done (for example whether a cached version of the page can be used etc.)

Parameters

Optionally, you can pass this method a byte (Level), which will determine the "type" / "level" or refreshing you want done.  This can be one of the following values:

fe:Browser_RefreshLevel_Normal

Refresh that does not include sending the HTTP "pragma:nocache" header to the server. The server may return a cached version of the page.

fe:Browser_RefreshLevel_Default

Behaves in the same manner as fe:Browser_RefreshLevel_Normal.

fe:Browser_RefreshLevel_IfExpired

Refresh that occurs if the page has expired. This refreshes the page, and if the cached version has expired then a new version will be fetched.

fe:Browser_RefreshLevel_Completely

Refresh that includes sending a "pragma:nocache" header to the server (HTTP URLs only). This refreshes the actual page, and asks the server not to returned a cached version. This is potentially the slowest (the most data needs to be transferred) however it ensures the current version of the actual page is retrieved.

Return Values

Returns a byte, indicating success (1), or failure (0)

 

up icon

horizontal rule

Reload     (<long CurrentControl>)

ThisViewer.Reload()

  • This method reloads the last document which you loaded into the object.  (i.e. The last documented loaded using the Load method).
  • If you omit the CurrentControl parameter, the same control which you used in the Init method is used.

up icon

horizontal rule

Resize     ( <long ParentControl>, long XMargin=0, long YMargin=0, long WidthAdjust=0, long HeightAdjust=0 )

ThisViewer.Resize()

  • In one sentence:  This method handles the resizing of the object ("viewer control") on the window, and should be called whenever the window resizes ( the templates will do this for you by generating code in the WindowResizeClass::Resize method ).
  • In many sentences:  The object you see on the window is not actually created "inside" the ParentControl (see the Init method).  We actually use the parent control to get the coordinates for the object, then create the object "on top" of those coordinates!  So if the parent control resizes, the File Explorer object needs to know about that so that it too can resize to appear to resize "with" the parent control.  The templates call this method for you in the WindowResizeClass's "Resize" method.  If you "manually" resize the parent control (hand code), you'll need to call File Explorer's Resize method to keep the object "in synch" with the parent control, as shown above.

up icon

horizontal rule

SearchPage     ( ) ,byte,proc

ThisViewer.SearchPage()

  • Loads the default (Internet Explorer) search page.
  • Returns an (optional) byte indicating success (1), or failure (0).
  • Note that this purely loads a page, if you need to locate a specific string of text in a loaded document use the feBrowser.Edit() method.

up icon

horizontal rule

SelectElementByID     ( string ElementID )

ThisViewer.SelectElementByID(3)

  • Use this method to select the contents of an element (field), where you do not know the name of the element (in which case it is better to use the SelectElementByName method), but where you know the ID (number) of the element (note: this number is provided by File Explorer, and will change if fields are added or removed to the html page you are dealing with).
  • To see this code in action, have a look at the Advanced_feBrowser_DOM procedure in the feabc.app example application.

up icon

horizontal rule

SelectElementByName     ( string ElementName, long FrameNumber=0, long NameInstance=0 )

ThisViewer.SelectElementByName ('MyField1')
ThisViewer.SelectElementByName ('MyField1', 3)

  • Use this method to select the contents of an element (field), where you know the name of the element (field).
  • The FrameNumber parameter can be used if you have a loaded document which contains frames.
  • To see this code in action, have a look at the Advanced_feBrowser_DOM procedure in the feabc.app example application.

Note: Certain elements (e.g.. FileInputElements) are marked read-only, and cannot be set using methods such as SetValueByName.  The following code does work, but is a bit of a hack..  Provided here as an additional example:

ThisViewer.SetFocus()
ThisViewer.SelectElementByName ('MyField1')
presskey(TabKey)
presskey(ShiftTab)
presskey(CtrlA)
presskey(DeleteKey)
press('Hello!')

up icon

horizontal rule

SetFocus     ( )

ThisViewer.SetFocus()

  • Sets the focus to the Window that contains the feBrowser object.

up icon

horizontal rule

SetValueByID     ( string ElementID, string ElementValue)

ThisViewer.SetValueByID ('id5', 'James')

  • See the GetElementQ method to understand the context of this method.
  • Use this method when you want to set a field's value in an html document, where you know the field's ("element's" / "object's") ElementID (each element (think "object") in an html page has its own ElementID)  For instance, if you have loaded an html page which has an entry field on it where users enter their last names, so long as you know that entry field's ElementID you can set the value for that field from your own (Clarion) code.  To elaborate, if you have an entry field in an html page as follows...
<input id="id5" type="text" name="LastName" size="20">
  • ... you could actually set the value in that field by using the code at the top of this section.
  • To see this code in action, have a look at the "Advanced_feBrowser_DOM" example in the feabc.app example application.

up icon

horizontal rule

SetValueByName     ( string ElementName, string ElementValue, long FrameNumber=0, long NameInstance=0 )

ThisViewer.SetValueByName ('LastName', 'James')

  • See the GetElementQ method to understand the context of this method.
  • Use this method when you want to set a field's value in an html document, where you know the field's ("element's" / "object's") ElementName (each element (think "object") in an html page has its own ElementName)  For instance, if you have loaded an html page which has an entry field on it where users enter their last names, so long as you know that entry field's ElementName you can set the value for that field from your own (Clarion) code.  To elaborate, if you have an entry field in an html page as follows...
    <input id="id5" type="text" name="LastName" size="20">
  • Here's another useful example:
    ! This example shows how to write to a field if there is
    ! more than one field with the same name! In this example
    ! there were two fields bothe names "zip", and we are
    ! writing different values to those two fields.
    ! ThisViewer1.SetValueByName ('zip', 'First ZIP Field', 0, 1)
    ! ThisViewer1.SetValueByName ('zip', 'Second ZIP Field', 0, 2)
  • ... you could actually set the value in that field by using the code at the top of this section.
  • The FrameNumber parameter can be used if you have a loaded document which contains frames.
  • To see this code in action, have a look at the "Advanced_feBrowser_DOM" example in the feabc.app example application.

up icon

horizontal rule

Stop     ( ) ,byte,proc

ThisViewer.Stop()

  • Same effect as the "Stop" button in Internet Explorer.
  • Returns a byte indicating success (1), or failure (0).

up icon

horizontal rule

SubmitForm     ( <string FormName>, long FrameNumber=0 )

ThisViewer.SubmitForm()
ThisViewer.SubmitForm ('form2')

  • If there is a form in the html page which you are browsing, and the form has a "submit" button, this method will trigger that button.  Very cool!
  • What's more, if you have a page that contains more than one form, you can specify which form to "submit" using the "FormName" parameter.
  • To see this in action, have a look at the Advanced_feBrowser_DOM procedure in the feabc.app example application.

up icon

horizontal rule

TranslateEventID     ( long EventID ) ,string

TempString  STRING(40)
...
TempString = ThisViewer1.TranslateEventID (SomeEventID)

  • See the EventCallback method for background info.
  • The EventCallback method allows you to see EventID's as callback events are fired.  These longs are explained in the Useful References section of this document, along with the actual name (string) of each event that the longs represent.  The TranslateEventID method takes the long (EventID) as a parameter, and returns the name of the event (string) if the event number is known.
  • See the Advanced_feBrowser_SimpleCallbacks procedure in the feabc.app example application to see this method in action.

up icon

horizontal rule

UnhideControl     ( )

ThisViewer.UnhideControl()

  • Unhides the File Explorer viewer control.  Note: ?feControl{prop:hide} = false will not work.

up icon

horizontal rule

Update     ( string Property, string PropValue, byte FrameNumber=0 )

ThisViewer1.Update ('PrinterHeader', 'This is my header')
ThisViewer1.Update ('PrinterFooter', 'This is my footer')
ThisViewer1.Update ('PrinterOrientation', 'Landscape')
ThisViewer1.Update ('PrinterOrientation', 'Portrait')
ThisViewer1.Update ('SilentMode', true)

  • Use this method to update various "properties" / "values" for the object.  Some times these "values" are actual properties of the File Explorer class, sometimes not.  The reason you use this method and don't just change the properties "directly" is because using this method results in the changes being implemented "immediately", and not for instance only coming into effect the next time you load a document into the object which is often the "default" behaviour.
  • The Property parameter can be one of the following:
    • PrinterHeader
    • PrinterFooter
    • PrinterOrientation
    • OuterHtml  - not yet working, still busy with this...
    • SilentMode  - (see "Note 2" below)
    • Offline
    • RegisterAsBrowser
    • RegisterAsDropTarget
    • TheaterMode
    • AddressBar
    • MenuBar
  • NOTE 1:
    For backward compatibility, this method still supports "Html1PrinterHeader" and "Html1PrinterFooter" as the Property parm.  Please change your code to use "PrinterHeader" and "PrinterFooter" instead if you have hand-coded this anywhere.  Not urgent, just more tidy.
  • NOTE 2: SilentMode
    The SilentMode property is used to set whether dialog boxes can be shown or not.  You can call the update method to set this property to either true or false any time after you've called the Init method.  By default this property is set to false, so dialog boxes will be shows (script errors etc).  Setting it to true (as in the code example above) will result in dialog boxes not being shown (so you won't see script error messages etc).  You could also set this property to say true before loading a certain page, then back to false again once you've finished on that page...

up icon

horizontal rule

bullet smallFeBrowser - Properties (alphabetical)

Busy (Byte) Holds true (1) if a page is still being loaded, or false (0) if not.  See the GetInfo method.
DocumentType (String) Holds a description of the type of document which you have loaded.  See the GetInfo method.
GraphicsList (String) See the notes on the GetHtmlGraphicsInfo method.  This property contains the list of graphic files found in the loaded html document.
NewWindow (Byte) By default this property is set to false (0).  Setting it to true (1) prior to calling the Load method results in the url you are loading being loaded into a new window ( your default browser will load and the file will be loaded into that window ).  Note that this property will not affect browsing: if you click on a hyperlink the new page will still be loaded into the parent window, unless the hyperlink properties are set to open the page in a new window.
OuterText (CString) Holds the currently loaded page's text content.  See the GetInfo method.
PageTitle (String) The title of the page being displayed, e.g. 'CapeSoft Accessories Home Page'.  See the GetInfo method.  Note that this property will only hold a title if the page you are viewing has one!  If not this property will hold the same thing that the Url property does.
RootFolder (String) This property is used in the GetHtmlGraphicsInfo method, for the following purpose.  When you are trying to establish the list of graphics in an html document ( primarily useful for when you are using NetTalk to send an email written using File Explorer - see the GraphicsList property ) there may be graphics with paths such as " /MySubfolder/MyImage.gif ".  The problem arises that when you pass NetTalk a graphic path like that ( to embed the graphic into the email at send-time ), it fails as the path is not "valid". File Explorer handles this problem as follows:  If you have first set the HtmlRootFolder property, before calling the GetHtmlGraphicsInfo method, then File Explorer automatically constructs valid paths for these graphics, using the HtmlRootFolder property to establish valid paths for these files.  Example...

Example:
ThisViewer1.RootFolder = "c:\My Documents\Website1"
! Here we set this property with the folder that contains the actual html page we're working with.  Any graphics in this html file that have no path ( Image1.gif ) or an "incomplete" path ( /Subfoler/Image.gif ) will be assumed to be in this folder or have this folder as their root.
ThisViewer1.GetHtmlGraphicsInfo()


If you do not set the RootFolder property before calling the GetHtmlGraphicsInfo method, File Explorer will assume that such graphics stem from the exe directory.
Source  (CString) Holds the html component (source / text) of the loaded page.  Updates when you call the GetInfo or the GetHtmlGraphicsInfo methods.
Url (String) e.g. http://www.capesoft.com/accessories/index.htm.  Holds the URL of the page currently displayed.  See the GetInfo method.
 

bullet smallFeBrowser - Events

See the FeBrowser - Summary of callback Events below, which now lists every single callback method, along with the parameters which are passed to it and a full description of what the method does and when it is called.

 

horizontal rule

bulletFeBrowser - Templates

At this time there is quite an overlap in terms of multiple File Explorer classes being implemented by the same templates.  In the future we may revisit this, but for now all templates are covered in the main (FileExplorer.htm) help document, please click here.

 

horizontal rule

bulletFeBrowser - Summary of callback events

See the FeBrowser_Callbacks procedure in the feabc.app example application for more info. This is still a work in progress, we will be adding support for additional callback events as well as improving the existing callbacks. The FE Class has specific callback methods for the events, you can override these methods to implement specific behaviour for callbacks. This is a far easier and cleaner way of responding to callbacks than embedding code directly in the EventCallback() method and checking which equate was passed (although this is still supported if you prefer to take this approach).

Note: For methods that take a pDisp parameter that points to the object that the event relates to it is not advised that this variable is used within your code, it is an internal FE pointer.

Event Name: Equate Description:
BeforeNavigate fe:WBEvt_BeforeNavigate

This is sent before navigation to give a chance to abort.

Remarks

This event is obsolete. Use the BeforeNavigate2 event instead.

BeforeNavigate2 fe:WBEvt_BeforeNavigate2

Fired before navigate occurs, as in when a hyperlink is clicked on, a url is entered, or the back or forward buttons are pressed.

Syntax

The FeBrowser.EventBeforeNavigate2 method is called:

FeBrowser.EventBeforeNavigate2 (long pDisp, string pURL, long pFlags, string pTargetFrameName, string pPostData, string pHeaders, byte pCancel)

Parameters

  • pDisp
    Object that evaluates to the top level or frame WebBrowser object corresponding to the navigation. Used internally by FE, do not modify this property (applies to all methods that take a pDisp parameter).
  • url
    String expression that evaluates to the URL to which the browser is navigating.
  • Flags
  • TargetFrameName
    String expression that evaluates to the name of the frame in which the resource will be displayed, or Null if no named frame is targeted for the resource.
  • PostData
    Data to send to the server if the HTTP POST transaction is being used.
  • Headers
    Value that specifies the additional HTTP headers to send to the server (HTTP URLs only). The headers can specify such things as the action required of the server, the type of data being passed to the server, or a status code.
  • Cancel
    Boolean value that the container can set to True to cancel the navigation operation, or to False to allow it to proceed.

Remarks

The BeforeNavigate2 event replaces the BeforeNavigate and FrameBeforeNavigate events, which should no longer be used. The pDisp parameter that specifies the corresponding WebBrowser object clearly identifies where the navigation is to occur. Microsoft Internet Explorer 3.0 required the FrameBeforeNavigate and a target frame name to identify the target of navigation. However, this solution was potentially ambiguous as frame names are not unique.

Note Internet Explorer 4.0 and later continue to fire the BeforeNavigate and FrameBeforeNavigate events for compatibility with Internet Explorer 3.0.

The pDisp parameter specifies the WebBrowser object of the top-level frame corresponding to the navigation. Navigating to a different URL could happen as a result of external automation, internal automation from a script, or the user clicking a link or typing in the address bar. The processing of this navigation can be modified by setting the Cancel parameter to True and either ignoring or reissuing a modified navigation method to the WebBrowser object.

When reissuing a navigation for the WebBrowser object, the Stop method must first be executed for pDisp. This prevents the display of a web page that declares a cancelled navigation from appearing while the new navigation is being processed.

ClientToHostWindow fe:WBEvt_ClientToHostWindow

Fired to request client sizes be converted to host window sizes.

CommandStateChange fe:WBEvt_CommandStateChange

Fires when the enabled state of a command changes. The FeBrowser.EventCommandStateChange method is called:

Syntax

FeBrowser.EventCommandStateChange(long pCommand, bool pEnable)

Parameters

  • pCommand
    CommandStateChangeConstants enumeration value that specifies the command that changed. This can have one of three values:

CSC_UPDATECOMMANDS (0FFFFFFFFh)
    Enabled state of a toolbar button might have changed.

CSC_NAVIGATEFORWARD (00000001h)
    Enabled state of the Forward button has changed.

CSC_NAVIGATEBACK (00000002h)
    Enabled state of the Back button has changed.

  • pEnable
        Boolean value that specifies the enabled state:
        false
            Command is disabled.
        true
            Command is enabled.
DocumentComplete fe:WBEvt_DocumentComplete

Fired when the document being navigated to reaches ReadyState_Complete.

Syntax

FeBrowser.EventDocumentComplete (long pDisp, string pURL)

Parameters

  • pDisp
    Object that specifies the top-level or frame WebBrowser object corresponding to the event.
  • URL
    String that specifies the URL, Universal Naming Convention (UNC) file name, or pointer to an item identifier list (PIDL) of the loaded document.
DownloadBegin fe:WBEvt_DownloadBegin

Download of a page started.

Syntax

FeBrowser.EventDownloadBegin ()

Remarks

This event is fired shortly after the BeforeNavigate or BeforeNavigate2 event, unless the navigation is canceled.

Each DownloadBegin event will have a corresponding DownloadComplete event.

DownloadComplete fe:WBEvt_DownloadComplete

Download of page complete.

Syntax

FeBrowser.EventDownloadBegin ()

Remarks

Unlike NavigateComplete or NavigateComplete2, which are fired only when a URL is successfully navigated to, this event is always fired after a navigation starts

Each DownloadBegin event will have a corresponding DownloadComplete event.

FileDownload fe:WBEvt_FileDownload

Fires to indicate that a file download is about to occur. If a file download dialog is to be displayed, this event is fired prior to the display of the dialog.

FrameBeforeNavigate fe:WBEvt_FrameBeforeNavigate

See the BeforeNavigate event for a full description.

FrameNavigateComplete fe:WBEvt_FrameNavigateComplete See the NavigateComplete event for a full description.
FrameNewWindow fe:WBEvt_FrameNewWindow
NavigateComplete fe:WBEvt_NavigateComplete

In async, this is sent when we have enough to show. Fires after a navigation to a link is completed on either a window or frameSet element.

Syntax

FeBrowser.EventNavigateComplete2 (long pDisp, string pURL)

Parameters

  • pDisp
    Object that evaluates to the top-level or frame WebBrowser object corresponding to the event.
  • URL
    String expression that evaluates to the URL, UNC file name, or PIDL that was navigated to.


Remarks

This event is obsolete. Use the NavigateComplete2 event instead.

NavigateComplete2 fe:WBEvt_NavigateComplete2 Fired when the document being navigated to becomes visible and enters the navigation stack. Fires after a navigation to a link is completed on either a window or frameSet element.

Syntax

FeBrowser.EventNavigateComplete2 (long pDisp, string pURL))


Parameters

  • pDisp
    Object that evaluates to the top-level or frame WebBrowser object corresponding to the event.
  • URL
    String expression that evaluates to the URL, UNC file name, or PIDL that was navigated to. Note that this URL can be different from the URL that the browser was told to navigate to. One reason is that this URL is the canonicalized and qualified URL; for example, if an application specified a URL of "www.microsoft.com" in a call to the Navigate or Navigate2 method, the URL passed by Navigate2 will be "http://www.microsoft.com/". Also, if the server has redirected the browser to a different URL, the redirected URL will be reflected here.

Remarks

This event replaces the NavigateComplete and FrameNavigateComplete events, which should no longer be used. Microsoft Internet Explorer 4.0 and Internet Explorer 5 continue to fire the NavigateComplete and FrameNavigateComplete events for compatibility with Internet Explorer 3.0.

The document might still be downloading (and in the case of HTML, images might still be downloading), but at least part of the document has been received from the server, and the viewer for the document has been created.

NewWindow fe:WBEvt_NewWindow

Fires when a new window is to be created.

Remarks

This event is obsolete. Use the NewWindow2 event instead.

NewWindow2 fe:WBEvt_NewWindow2 Fires when a new window is to be created. Create a new, hidden, nonnavigated WebBrowser.

Syntax

FeBrowser.EventNewWindow2()

Remarks

In Microsoft Internet Explorer, the NewWindow2 event is not fired when the user selects Window from the New command on the File menu. This event precedes the creation of a new window from within the WebBrowser.

The NewWindow2 event is fired when a window is about to be created, such as during the following actions:

The user clicks a link while pressing the SHIFT key.
The user right-clicks a link and selects Open In New Window.
The user selects New Window from the File menu.
There is a targeted navigation to a frame name that does not yet exist.

Your browser application can also trigger this event by calling the Navigate or Navigate2 method with the navOpenInNewWindow flag. The WebBrowser control has an opportunity to handle the new window creation itself. If it does not, a top-level Internet Explorer window is created as a separate (nonhosted) process.

 

OnAddressBar fe:WBEvt_OnAddressBar

feBrowser.EventOnToolbar()

Sent when the address bar should be shown/hidden.

OnFullScreen fe:WBEvt_OnFullScreen

feBrowser.EventOnFullScreen()

Sent when fullscreen / kiosk mode should be on/off

OnMenuBar fe:WBEvt_OnMenuBar

feBrowser.EventOnMenuBar()

Sent when the menubar should be shown/hidden

OnQuit fe:WBEvt_OnQuit

feBrowser.EventOnQuit()

Fired when the application is quiting

OnStatusBar fe:WBEvt_OnStatusBar

feBrowser.EventOnStatusBar()

Sent when the statusbar should be shown/hidden

OnTheaterMode fe:WBEvt_OnTheaterMode

feBrowser.EventOnTheaterMode()

Sent when theater mode should be on/off

OnToolBar fe:WBEvt_OnToolBar

feBrowser.EventOnToolbar()

Sent when the toolbar should be shown/hidden

OnVisible fe:WBEvt_OnVisible

feBrowser.EventOnVisible()

Sent when the window goes visible/hidden

ProgressChange fe:WBEvt_ProgressChange

feBrowser.EventProgressChange()

Sent when download progress is updated

PropertyChange fe:WBEvt_PropertyChange

feBrowser.EventPropertyChange()

Sent when the PutProperty method is called

Quit fe:WBEvt_Quit feBrowser.EventOnQuit()
SetSecureLockIcon fe:WBEvt_SetSecureLockIcon

feBrowser.EventSetSecureLockIcon()

Fired to indicate the security level of the current web page contents

StatusTextChange fe:WBEvt_StatusTextChange

feBrowser.EventStatusTextChange()

Statusbar text changed

TitleChange fe:WBEvt_TitleChange

feBrowser.EventTitleChange()

Sent when the document title changes

WindowActivate fe:WBEvt_WindowActivate

Sent when main window has been activated

WindowClosing fe:WBEvt_WindowClosing

feBrowser.EventWindowClosing()

Fired when the WebBrowser is about to be closed by script
WindowMove fe:WBEvt_WindowMove

Sent when main window has been moved

WindowResize fe:WBEvt_WindowResize

Sent when main window has been sized

WindowSetHeight fe:WBEvt_WindowSetHeight

feBrowser.EventWindowSetHeight()

Fired when the host window should change its height
WindowSetLeft fe:WBEvt_WindowSetLeft

feBrowser.EventWindowSetLeft()

Fired when the host window should change its Left coordinate
WindowSetResizable fe:WBEvt_WindowSetResizable

feBrowser.EventWindowSetResizable()

Fired when the host window should allow/disallow resizing
WindowSetTop fe:WBEvt_WindowSetTop

feBrowser.EventWindowSetTop()

Fired when the host window should change its Top coordinate
WindowSetWidth fe:WBEvt_WindowSetWidth

feBrowser.EventWindowSetLeft()

Fired when the host window should change its width

 

Other FileExplorer Specific Event Callbacks
feBrowser.EventClick() Fired when the user clicks in the control. Only traps the click event, no other information is provided (such as what the user clicked on etc.) The FeBrowser.EventBeforeNavigate() event callback can be used to trap mouse clicks that cause a navigation command to execute.
feBrowser.EventDblClick()

Fired when the user double clicks in the control.

 

horizontal rule

bulletUseful Tip: How To Load and Print Web Pages in the Background

Using FileExplorer you can load a web page, print it, and close the window that the page is loaded with, without the user having to see anything. You can do this simply by adding a procedure with a FileExplore feBrowser control, and passing it a string as a parameter. This string contains the URL of the website page to print.

This is demonstrated in the BackgroundPrint example in the Clarion\3rdparty\Examples\FileExplorer\BackgroundPrint\ folder. The example allows a file to be selected that is printed using FE in the background. While the example allows a file to be selected and a button to be pressed to print the file, this can be automated using exactly the same technique. Note that you can also specify a web page address (URL) instead of a file name and FE will print it. You can also specify any file type that IE can open - HTML, EML, MHT, PDF etc.

The example uses the following technique to implement background printing, which involves embedding a small amount of code in four embed points.

1) Hide the Window

In the ThisWindow.Init method, after the window has opened, hide it (this is in the embed below SELF.Open(Window)):

! Open the window
    Open(Window)                ! Open window
    ! [Priority 8030]

    Window{prop:hide} = 1

2) Load the page. After the call to ThisViewer.Init(), call the .Load() method to load the page that you want to print. The example application passes a parameter to the procedure to specify the page to load.

3) Print the page after it has been loaded in the ThisViewer.EventDocumentComplete() procedure, after the parent call add the following code:

    if Clip(pUrl) <> 'about:blank'     ! Ignore the blank page
if Message('Would you like to print the page ' & Clip(pURL) & '?', | 'Print this page?', Icon:Question, Button:Yes + Button:No) = Button:Yes ThisViewer1.PrintMe(false) ! print the document end
end
4) Close the window once the print is completed, in the ThisViewer1.EventPrintTemplateTeardown() method, again after the parent call, add the following:

    Post(Event:CloseWindow)

And that is it - you now have a procedure that will print any file or page that Internet Explorer can load, all in the background!

 

horizontal rule

bulletUseFul Tip: Finding which Radio button is selected.

When using Radio button on a web page, all the buttons that need to be in the same "group" should be name the same, and each given a unique value:

  <input type="radio" name="R1" value="V1" checked>
  <input type="radio" name="R1" value="V2">
  <input type="radio" name="R1" value="V3">

The problem is determining which radio button is selected before the form is submitted, unfortunately the Checked attribute is not set for radio buttons when getting the value from the IE HTML DOM (although it is used to determine the default selection). However a small amount of JavaScript can be used to assign the selected value to a hidden entry in the form:

  <p><input type="radio" name="R1" value="V1" onMouseUp="rSelect.value='V1'" checked></p>
  <p><input type="radio" name="R1" value="V2" onMouseUp="rSelect.value='V2'"></p>
  <p><input type="radio" name="R1" value="V3" onMouseUp="rSelect.value='V3'"></p>
  <input type="hidden" value="" name="rSelect">

The above code assigns the value to the hidden control (rSelect) when the radio button is selected. Using GetElementsQ() will list the selected value for the rRelected element. JavaScript and FileExplorer are an excellent combination for providing additional functionality and providing a rich, dynamic user interface.

horizontal rule

bulletLeveraging the power of the HTML DOM using JavaScript and FileExplorer

Using JavaScript in conjunction with FileExplorer allows you to create powerful, dynamic user interfaces and web pages to display in your application. You use JavaScript with FE in the same manner as using it in any other web page - simply add the required JavaScript to the HTML file that is being loaded. You can add an 'onload="MyFunction();"' to the <body> tag to run JavaScript when the application loads, you can call JS code when a control is click on, selected, moused over, moused out etc. You have full control over the document and the DOM, and there are loads of JavaScript examples and documentation available online.
 
Below there is some JavaScript from an recent application that uses FileExplorer to display dynamic forms (an example of which will ship with FE in the near future). In the <head> section of the HTML declare the JavaScript functions:
<script type="text/javascript">
<!--
function autoTab(input, len, e)
{
    var keyCode = (isNN) ? e.which : e.keyCode;
    var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
    if(input.value.length >= len && !containsElement(filter,keyCode))
    {
        input.value = input.value.slice(0, len);
        input.form[(getIndex(input)+1) % input.form.length].focus();
    }

    function containsElement(arr, ele)
    {
        var found = false, index = 0;
        while(!found && index < arr.length )
            if(arr[index] == ele)
                found = true;
            else
               index++;

        return found;
    }

    function getIndex(input)
    {
        var index = -1, i = 0, found = false;

        while (i < input.form.length && index == -1)
            if (input.form[i] == input)
                index = i;
            else
                i++;

        return index;
    }
    return true;
}

function expandTA(ta) {
    var maxChars = ta.cols;
    var theRows = ta.value.split("\n");

    var numNewRows = 0;

    for ( var i = 0; i < theRows.length; i++ ) {
        numNewRows += ( Math.ceil( theRows[i].length / maxChars ) - 1 );
    }
    if (numNewRows + theRows.length == 0)
        ta.rows = 1
    else
        ta.rows = numNewRows + theRows.length;
    }

function padout(number) { return (number < 10) ? '0' + number : number; }

function SetDate(dayInput, monthInput, yearInput)
{
    var now = new Date();

    dayInput.value = padout(now.getDate());
    monthInput.value = padout(now.getMonth() + 1); // return from 0 to 11.
    yearInput.value = now.getYear();

}
//-->
</script>


The autoTab() function automatically moves to the next field when the user completes the current field and the expandTA() function expands a Text box as the user types, so each time they press return for a new line the box expands to fit the text (very useful for keeping forms compact and neat, but still functional and clear). SetDate() sets the date of the passed fields to the current date, and the PadOut() function just adds a zero to the front of the number if it is a single digit so that dates are always in the format 01/01/2007 instead of 1/1/2007 etc.
 
For example in the <body> tag call SetDate() to fill fields with the current date:
  <body onload="SetDate(document.ConsultationForm.dayField, document.ConsultationForm.monthField,
                document.ConsultationForm.yearfieldField);">
The syntax for a fields is document.formname.fieldname. The document object is the current document and contains a number of properties and methods (any JS reference will list then for you). You declare the form as:
    <form name="ConsultationForm" id="ConsulationForm">
And you can then reference it as document.ConsulationForm. I have set the ID to ConsultationForm here because I used the ID when I read the fields in using the FE GetElementsQueue() method. Similarly you can the fields to use them:
 
<input id="DOB_d" size="3" maxlength="2" onKeyUp="return autoTab(this, 2, event);"
       onFocus=" this.value='';" />
<input id="DOB_m" size="3" maxlength="2" onKeyUp="return autoTab(this, 2, event);" onFocus=" this.value='';" />
<input id="DOB_y" size="5" maxlength="4" onKeyUp="return autoTab(this, 4, event);" onFocus=" this.value='';" />
This declares fields for day, month and year. When the user fills in a field it jumps to the next field in the form automatically, and when the user clicks in a field it clears it. The onKeyUp and onFocus events are used.
 
JavaScript is immensely flexible and powerful, and you can provide some great interfaces for your user by leveraging the combination of FileExplorer and JavaScript. We will be expanding on this documentation and providing a dynamic form example with FE in the near future.

horizontal rule 

bulletHow to remove parts of a loaded page before displaying it to the user

When a page is loaded using Internet Explorer (or any other web browser) you don't have any control over which parts of the page is displayed, whatever the web server provides is displayed by the web browser. FileExplorer allows you to remove parts of web pages as well as modifying values (such as filling in forms automatically etc.).

  1. It is often helpful to hide the control using the feBrowser.HideControl() method while the content is loading. If you want to make it appear as if the control is still there then use a Box control, with a white fill that is displayed in place of the FE control while it is loading. This also allows you to add a progress control or animation to show the user that the loading of the page etc. This isn't required but means that it won't be displayed until you have finished modifying it, which may be better visually.
  2. Turn on callbacks in the feBrowser extension (or right click on the FileExplorer control in the Window Editor and choose Actions, the Callbacks setting is on the second tab).
  3. Load the URL by calling the Load() method
  4. In the EventDocumentComplete() method embed code to process the received page:
    • Check that the pUrl parameter is the page that you have just loaded (this method is called a number of times, for example it is initially called for 'about:blank' before you load any other pages).
    • Call GetElementQ() to get a list of all elements on the page.
    • For each element in the queue that you want to remove call SelectElementByID() or SelectElementByName() to select the object on the page.
    • Call Edit(fe:Browser_Delete) to delete the selected element

 

You can use the same approach to get and set the values of elements on the page by calling GetValueByID(), GetValueByName(), SetValueByID(), SetValueByName() and elements can be "clicked" on using ClickByRecordNumber().

 

 

 

[end of document]