From Clomosy Docs

No edit summary
No edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
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.
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert">
function AddNewWebBrowser(AComponent: TCLComponent; xName: string): TclWebBrowser;
</div>


  xWeb:= MyForm.AddNewWebBrowser(MyForm,'xWeb');
<span style="color:blue"><b>AComponent</b></span> : Specifies the parent of the object to be defined.<br>


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.
<span style="color:blue"><b>xName</b></span> : The name of the defined component should be written.<br>


xWeb.Navigate('www.google.com');
To integrate a web browser using Clomosy, you can use the TclWebBrowser component.<br>


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.
To use it, you should create a form and create a Web Browser inside it.<br>


  xWeb.goForward;
<pre>
  WebBrowser1 = Form1.AddNewWebBrowser(Form1,'WebBrowser1');
</pre>


It is used to go back from one page. Example: You searched on Google and want to return to the home page.
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.<br>


  xWeb.goBack;
<pre>
  WebBrowser1.Navigate('www.google.com');
</pre>


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.
The URL property is used to determine which URL the browser is navigating to. This property returns the URL of the currently loaded page in the browser as a string value.


xWeb.CanGoBack
<pre>
UrlStr = WebBrowser1.URL //UrlStr : String;
</pre>


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.<br>


'''Example:'''
<pre>
:'''Base Syntax'''
WebBrowser1.goForward;
</pre>
 
It is used to go back from one page. Example: You searched on Google and want to return to the home page.<br>
 
<pre>
WebBrowser1.goBack;
</pre>
 
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.<br>
 
<pre>
WebBrowser1.CanGoBack;
</pre>
 
<b>Example</b><br>
<pre>
  Var
  Var
   MyForm:TclForm;
   MyForm:TclForm;
   xWeb:TclWebBrowser;
   xWeb:TclWebBrowser;
   xBtn,xBtn2 : TCLButton;
   xBtn,xBtn2 : TCLButton;
   xPnl : TclPanel;
   xLyt : TclLayout;
   
   
   procedure goForwardClick;
   void goForwardClick;
   begin
   {
     xWeb.goForward;   
     xWeb.goForward;   
   end;
   }
   
   
   procedure goBackClick;
   void goBackClick;
   begin
   {
     if xWeb.CanGoBack then
     if (xWeb.CanGoBack)
       ShowMessage('You can return to the page.')
       ShowMessage('You can return to the page.')
     else
     else
       ShowMessage('There is no page to go back to.');
       ShowMessage('There is no page to go back to.');
     xWeb.goBack;   
     xWeb.goBack;   
   end;
   }
   
   
  Begin
  {
   MyForm := TclForm.Create(Self);
   MyForm = TclForm.Create(Self);
   
   
   xPnl := MyForm.AddNewLayout(MyForm,'xPnl');
   xLyt  = MyForm.AddNewLayout(MyForm,'xLyt');
   xPnl.Align := alTop;
   xLyt.Align = alTop;
   xPnl.Height := 45;
   xLyt.Height = 45;
   
   
   xBtn2 := MyForm.AddNewButton(xPnl,'xBtn2','goBack');
   xBtn2 = MyForm.AddNewButton(xLyt,'xBtn2','goBack');
   xBtn2.Align := alLeft;
   xBtn2.Align = alLeft;
   xBtn2.Width := 70;
   xBtn2.Width = 70;
   MyForm.AddNewEvent(xBtn2,tbeOnClick,'goBackClick');
   MyForm.AddNewEvent(xBtn2,tbeOnClick,'goBackClick');
   
   
   xBtn := MyForm.AddNewButton(xPnl,'xBtn','goForward');
   xBtn = MyForm.AddNewButton(xLyt,'xBtn','goForward');
   xBtn.Align := alLeft;
   xBtn.Align = alLeft;
   xBtn.Width := 70;
   xBtn.Width = 70;
   MyForm.AddNewEvent(xBtn,tbeOnClick,'goForwardClick');
   MyForm.AddNewEvent(xBtn,tbeOnClick,'goForwardClick');
   
   
   xWeb:= MyForm.AddNewWebBrowser(MyForm,'xWeb');   
   xWeb= MyForm.AddNewWebBrowser(MyForm,'xWeb');   
   xWeb.Align := alClient;
   xWeb.Align = alClient;
   xWeb.Navigate('www.google.com');
   xWeb.Navigate('www.google.com');
   
   
   MyForm.Run;
   MyForm.Run;
  End;
  }
 
</pre>
:'''TRObject Syntax'''


  Var
<h2> See Also </h2>
  MyForm:TclForm;
* [[Components]]
  xWeb:TclWebBrowser;
* [[Object Properties]]
  xBtn,xBtn2 : TCLButton;
* [[AddNewEvent]]
  xPnl : TclPanel;
{{#seo:|title=TclWebBrowser Using in Clomosy - Clomosy Docs}}
 
{{#seo:|description=Use TclWebBrowser in Clomosy to integrate a web browser into your app, enabling navigation, forward/backward history, and dynamic URL loading.}}
  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;
  }

Latest revision as of 14:56, 24 December 2024

AComponent : Specifies the parent of the object to be defined.

xName : The name of the defined component should be written.

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.

 WebBrowser1 = Form1.AddNewWebBrowser(Form1,'WebBrowser1');

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.

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

The URL property is used to determine which URL the browser is navigating to. This property returns the URL of the currently loaded page in the browser as a string value.

UrlStr = WebBrowser1.URL //UrlStr : String;

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.

 WebBrowser1.goForward;

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

 WebBrowser1.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.

 WebBrowser1.CanGoBack;

Example

 Var
  MyForm:TclForm;
  xWeb:TclWebBrowser;
  xBtn,xBtn2 : TCLButton;
  xLyt : TclLayout;
 
  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);
 
  xLyt  = MyForm.AddNewLayout(MyForm,'xLyt');
  xLyt.Align = alTop;
  xLyt.Height = 45;
 
  xBtn2 = MyForm.AddNewButton(xLyt,'xBtn2','goBack');
  xBtn2.Align = alLeft;
  xBtn2.Width = 70;
  MyForm.AddNewEvent(xBtn2,tbeOnClick,'goBackClick');
 
  xBtn = MyForm.AddNewButton(xLyt,'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;
 }

See Also