Navigate2

 

To make navigation simple EmbeddedWb include 

Procedure Go(Url : String);

procedure TEmbeddedWB.Go(Url: string);
var
   _URL, Flags, TargetFrameName, PostData, Headers: Olevariant;
begin
   _URL := Url;
   Flags := 0; TargetFrameName := 0; Postdata := 0; Headers := 0;
   Navigate2(_URL, Flags, TargetFrameName, PostData, Headers);
end;

To do more than simple navigating you need to use Navigate2.

procedure Navigate2(
                       var URL:OleVariant;
                       var Flags: OleVariant; 
                       var TargetFrameName:OleVariant;
                       var PostData: OleVariant; 
                       var Headers: OleVariant);

  • URL: A string expression that evaluates to the URL of the resource to display or the full path to the file location.

  • Flags: (Optional) A set of values that specify 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. It can be a sum of zero or more of the following:


navOpenInNewWindow Open the resource or file in a new window.
navNoHistory Do not add the resource or file to the history list. The new page replaces the current page in the list.
navNoReadFromCache Not currently supported.
navNoWriteToCache Not currently supported.
navAllowAutosearch If the navigation fails, the autosearch functionality attempts to navigate common root domains (.com, .edu, and so on). If this also fails, the URL is passed to a search engine.
navBrowserBar Causes the current Explorer Bar to navigate to the given item, if possible.


  • TargetFrameName:(Optional) String expression that evaluates to the name of an HTML frame in URL to display in the browser window. The possible values for this parameter 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.

 

  • Postdata: (Optional). Data to send to the server during the HTTP POST transaction. For example, the POST transaction is used to send data gathered by an HTML form to a program or script. If this parameter does not specify any post data, the Navigate2 method issues an HTTP GET transaction. This parameter is ignored if URL is not an HTTP URL.

 

  • Headers: (Optional). A value that specifies additional HTTP headers to send to the server.

EmbeddedWb includes some function to make the use of Navigate2 easier:

 

Procedure NavigatePidl(pidl : PItemIdList);

Navigate2 provides the same capabilities as Navigate, but it also can be used to navigate to a folder by specifying a pointer to an item identifier list (PIDL). PIDLs were introduced with Windows 95 and provide a way to uniquely identify an item within the shell's namespace. PIDLs are also supported on NT 4.0.

 

Procedure NavigateFolder(CSIDL: Integer);

browsing on special folders—such as Desktop and My Computer:

EmbeddedWb1.NavigateFolder(CSIDL_Desktop);
 

All CSIDL-values are defined i shlobj.pas.

 

Function StringToVarArray(const S: String): Variant;
To send data in PostData and Headers you need to convert the strings to VariantArray.

Function VarArrayToString(Const V: variant): String;
If you want to read values in PostData and Headers, you need to translate VariantArray to string.

Function Encode(Const S: String) : String;
International characters, <space>, etc. must be encoded ('.'= '%2E') before posting. 


The following sample demonstrates how to use Navigate2 to send data to a form, using PostData and Headers. The sample navigate to Hotmail, post username and Password to the form and open the mailbox. 

We don't want any saving to historylist, so flag is NavNoHistory.

procedure TForm1.Button1Click(Sender: TObject);
var
url, Flags, TargetFrame, Postdata, Headers: Olevariant;
begin
Url := 'https://lc1.law5.hotmail.passport.com/cgi-bin/dologin';
TargetFrame:=0;
Flags:=NavNoHistory;
headers := StringtoVarArray('Content-Type:application/x-www-form-urlencoded'#13#10);
Postdata := StringToVarArray(Encode('login=<MyUsername>&passwd=<MyPassword>'));
EmbeddedWb1.Navigate2(URL, Flags, TargetFrame, PostData, Headers);
end;