From Clomosy Docs

Revision as of 13:06, 12 February 2024 by ClomosyManager (talk | contribs)

To integrate a web browser using Clomosy, you can use the TclWebBrowser component. To use it, you should create a form and create a Web Browser inside it.

xWeb:= MyForm.AddNewWebBrowser(MyForm,'xWeb');

The 'Navigate' method is used to navigate the browser to the specified URL. This method is used when you want to load a specific web page.

xWeb.Navigate('www.google.com');

Using the "goForward" function refers to going to a page in a web browser's history. That means returning to the previous page from an undone step in the browser.

xWeb.goForward;

It is used to go back from one page. Example: You searched on Google and want to return to the home page.

xWeb.goBack;

The CanGoBack feature specifies the browser's ability to go backwards. This property returns True if it is possible to go back one page; otherwise it returns False.

xWeb.CanGoBack


Example:

Base Syntax
Var
 MyForm:TclForm;
 xWeb:TclWebBrowser;
 xBtn,xBtn2 : TCLButton;
 xPnl : TclPanel;

 procedure goForwardClick;
 begin
   xWeb.goForward;  
 end;

 procedure goBackClick;
 begin
   if xWeb.CanGoBack then 
     ShowMessage('You can return to the page.')
   else
     ShowMessage('There is no page to go back to.');
   xWeb.goBack;  
 end;

Begin
 MyForm := TclForm.Create(Self);

 xPnl := MyForm.AddNewLayout(MyForm,'xPnl');
 xPnl.Align := alTop;
 xPnl.Height := 45;

 xBtn2 := MyForm.AddNewButton(xPnl,'xBtn2','goBack');
 xBtn2.Align := alLeft;
 xBtn2.Width := 70;
 MyForm.AddNewEvent(xBtn2,tbeOnClick,'goBackClick');

 xBtn := MyForm.AddNewButton(xPnl,'xBtn','goForward');
 xBtn.Align := alLeft;
 xBtn.Width := 70;
 MyForm.AddNewEvent(xBtn,tbeOnClick,'goForwardClick');

 xWeb:= MyForm.AddNewWebBrowser(MyForm,'xWeb');  
 xWeb.Align := alClient;
 xWeb.Navigate('www.google.com');

 MyForm.Run;
End;
TRObject Syntax
 Var
  MyForm:TclForm;
  xWeb:TclWebBrowser;
  xBtn,xBtn2 : TCLButton;
  xPnl : TclPanel;
 
  void goForwardClick;
  {
    xWeb.goForward;  
  }
 
  void goBackClick;
  {
    if (xWeb.CanGoBack)
      ShowMessage('You can return to the page.')
    else
      ShowMessage('There is no page to go back to.');
    xWeb.goBack;  
  }
 
 {
  MyForm = TclForm.Create(Self);
 
  xPnl = MyForm.AddNewLayout(MyForm,'xPnl');
  xPnl.Align = alTop;
  xPnl.Height = 45;
 
  xBtn2 = MyForm.AddNewButton(xPnl,'xBtn2','goBack');
  xBtn2.Align = alLeft;
  xBtn2.Width = 70;
  MyForm.AddNewEvent(xBtn2,tbeOnClick,'goBackClick');
 
  xBtn = MyForm.AddNewButton(xPnl,'xBtn','goForward');
  xBtn.Align = alLeft;
  xBtn.Width = 70;
  MyForm.AddNewEvent(xBtn,tbeOnClick,'goForwardClick');
 
  xWeb= MyForm.AddNewWebBrowser(MyForm,'xWeb');  
  xWeb.Align = alClient;
  xWeb.Navigate('www.google.com');
 
  MyForm.Run;
 }