Having problem with TWebBrowser on frame [Edit]

I set all of this up on a form and it worked beautifully.  I then transferred it to a frame and now I get the error "Undeclared identifier 'WebBroswer1' at line 263.  Below is the code in the unit and yes I have removed stuff that didn't apply to this issue to simplify this posting. 

What am I doing wrong here that Delphi XE doesn't recognize that there is indeed a TWebbrowser already declared?

FYI this frame goes on a tabsheet on a pagecontrol on the main form.

Thanks,
TD

{code}
unit Picks;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs, ExtCtrls, ComCtrls, StdCtrls, DBCtrls, Mask, DB, Prt, OleCtrls,
  SHDocVw;

type
  TFrame3 = class(TFrame)
    btnData: TButton;
    WebBrowser1: TWebBrowser;
    procedure RecFilter;
    procedure btnDataClick(Sender: TObject);
  private
    { Private declarations }
    fPrt: TForm3;
  public
    { Public declarations }
  procedure LoadcboAdmitDate;
  end;



implementation

{$R *.dfm}

uses ExtActns, RegularExpressions, DM, Main;


function Download_HTML(const strURL: string): string;
var
  DOM : variant;
begin
    WebBrowser1.navigate(strURL);  < ----- THIS IS LINE 263 @@@@@@@@@@@@@@@@@@@@@
  while (WebBrowser1.ReadyState <> READYSTATE_COMPLETE) do
    begin
      Application.ProcessMessages;
      Sleep(5);
    end;
  DOM := WebBrowser1.Document;
  Result := DOM.Body.OuterHTML;
end;
{code}
0
Thomas
6/26/2013 12:35:28 AM
embarcadero.delphi.general 4258 articles. 0 followers. Follow

4 Replies
714 Views

Similar Articles

[PageSpeed] 34

Thomas Lee wrote:

> function Download_HTML(const strurl:  string): string;

Download_HTML should be a method of TFrame3, not a standalone function.

-- 
Dave Nottage [TeamB]
0
Dave
6/26/2013 1:06:21 AM
> {quote:title=Dave Nottage wrote:}{quote}
> Thomas Lee wrote:
> 
> > function Download_HTML(const strurl:  string): string;
> 
> Download_HTML should be a method of TFrame3, not a standalone function.
> 
> -- 
> Dave Nottage [TeamB]

So it should look something like this then?

{code}
unit Picks;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs, ExtCtrls, ComCtrls, StdCtrls, DBCtrls, Mask, DB, Prt, OleCtrls,
  SHDocVw;
 
type
  TFrame3 = class(TFrame)
    btnData: TButton;
    WebBrowser1: TWebBrowser;
    function Download_HTML(const strURL: string): string;   <--- ADDED THIS @@@@@@@@@@@@@@@@@@@
    procedure RecFilter;
    procedure btnDataClick(Sender: TObject);
  private
    { Private declarations }
    fPrt: TForm3;
  public
    { Public declarations }
  procedure LoadcboAdmitDate;
  end;
 
 
 
implementation
 
{$R *.dfm}
 
uses ExtActns, RegularExpressions, DM, Main;
 
 
function TFrame3.Download_HTML(const strURL: string): string; <-- CHANGED THIS @@@@@@@@@@@@@@@@@@@@@@@
var
  DOM : variant;
begin
    WebBrowser1.navigate(strURL);  < ----- THIS IS LINE 263 @@@@@@@@@@@@@@@@@@@@@
  while (WebBrowser1.ReadyState <> READYSTATE_COMPLETE) do
    begin
      Application.ProcessMessages;
      Sleep(5);
    end;
  DOM := WebBrowser1.Document;
  Result := DOM.Body.OuterHTML;
end;
{code}
0
Thomas
6/26/2013 2:20:28 AM
That's better but it's not best practice to put it in the "default" visibility section like that. You should move it to the either the public or the private section depending on how you're using it. That RecFilter procedure should probably go in private also if it's something you added rather than the IDE.

{code}
type
  TFrame3 = class(TFrame)
    btnData: TButton;
    WebBrowser1: TWebBrowser;
    procedure RecFilter;
    procedure btnDataClick(Sender: TObject);
  private
    { Private declarations }
    fPrt: TForm3;
    function Download_HTML(const strURL: string): string;
  public
    { Public declarations }
  procedure LoadcboAdmitDate;
  end;
{code}

A simple rule of thumb is that if you wrote it put it in private. If compiler gives an error move it to public. If the IDE wrote it, leave it alone.

That will serve you well until you start using inheritance but by then you should make sure you understand the different visibilities properly.
http://docwiki.embarcadero.com/RADStudio/XE4/en/Classes_and_Objects#Private.2C_Protected.2C_and_Public_Members

--
Lachlan
Embarcadero MVP
http://www.tindex.net

Edited by: Lachlan Gemmell on Jun 27, 2013 11:44 AM
0
Lachlan
6/27/2013 1:45:52 AM
Thank you !!!
TD



> {quote:title=Lachlan Gemmell wrote:}{quote}
> That's better but it's not best practice to put it in the "default" visibility section like that. You should move it to the either the public or the private section depending on how you're using it. That RecFilter procedure should probably go in private also if it's something you added rather than the IDE.
> 
> {code}
> type
>   TFrame3 = class(TFrame)
>     btnData: TButton;
>     WebBrowser1: TWebBrowser;
>     procedure RecFilter;
>     procedure btnDataClick(Sender: TObject);
>   private
>     { Private declarations }
>     fPrt: TForm3;
>     function Download_HTML(const strURL: string): string;
>   public
>     { Public declarations }
>   procedure LoadcboAdmitDate;
>   end;
> {code}
> 
> A simple rule of thumb is that if you wrote it put it in private. If compiler gives an error move it to public. If the IDE wrote it, leave it alone.
> 
> That will serve you well until you start using inheritance but by then you should make sure you understand the different visibilities properly.
> http://docwiki.embarcadero.com/RADStudio/XE4/en/Classes_and_Objects#Private.2C_Protected.2C_and_Public_Members
> 
> --
> Lachlan
> Embarcadero MVP
> http://www.tindex.net
> 
> Edited by: Lachlan Gemmell on Jun 27, 2013 11:44 AM
0
Thomas
6/27/2013 1:50:37 AM
Reply:

Similar Artilces:

Delphi XE5 TWebBrowser Problem on Android [Edit]
I have write 4 samples code: 1) paginaweb:='file://'+pathpdf+'prova.pdf'; webbrowser1.URL:=paginaweb; 2) paginaweb:='http://www.ufficiotecnicogecom.com/Volantini/prova.pdf'; webbrowser1.URL:=paginaweb; 3) have used webbrowser1.Navigate(paginaweb); 4) paginaweb := 'http://www.youtube.com/user/SisaCentroSudGecom'; webbrowser1.Navigate(paginaweb); or webbrowser1.URL:=paginaweb; webbroser1 is in a mobile form. All not work on Android but work fine on iOS, the case of youtube url load page but still stuck on loading vide...

Delphi 2006 to Delphi XE Crystal BPL problem [Edit]
I am in the process of migrating our application from Delphi 2006 to Delphi XE and, for ease of use, I have both 2006 and XE installed on my development computer. I access Crystal Reports XI RDC in our application and so I rebuilt the BPL in XE in order to add the new package to XE. However, when I try to add the package to XE I get the error message: “Registration procedure, Craxddrt_tbl.Register in the package c:\Documents and Settings\All Uers\Documents\RADS Studio\8.0\BPL\Crystal.bpl raised exception class EFilerError: Component TDatabase can’t be registered by package crystal.bpl be...

Problem using InstallAware 7 CodeGear Special Edition with Delphi 2010 [Edit]
Hi Everyone, I am trying to create an installation disk for my delphi 2010 application using the installAware that kind of comes with Delphi 2010. When I try to built it, it keeps giving me the error message:- No files matching pattern "C:\Windows\system32\\*120.bpl" and when I look into my windows\system32 folder, there the files with extension *.bpl end with *140.bpl and not *120.bpl like it was expected. Can anyone tell me if I am doing something wrong or how I can get around this. Thanks in advance. Edited by: Tat Hon Chu on Dec 3, 2009 12:55 AM > {quo...

Delphi Designer Problem [Edit]
An older Delphi application consisting of many projects (a host exe and several plug in libraries) was thrown my way today and it has a problem. The problem lies in the way Delphi is choosing which designer to use when displaying a data module for one particular plug in library project. Each plug in library has one data module which inherits from a shared base data module unit. The base data module published some new properties like version (string), serial (string), and security (integer), etc. In all the plug in library projects, when you open the derived data module Delphi picks the ...

Delphi
Hi, I'm trying to make an application that connects to the specyfic device and read some data... thay are in strings... Device producer give Delphi library that works but instead of number (string with number '1234.67') I get kind of chinesse letters.. if I do AnsiString := String there is '??????d' string instead od chinnesse :-) with other string I get without last letter i.e.: 'Unknow'. http://i.imgur.com/jP47wgC.png The library was made for Delphi 7 and is open in XE5... In future I'd like to use it in FMX also... Sebastian wrote: > I&#...

TWebBrowser in Delphi 2009 [Edit]
I'm having a strange problem with TWebBrowser in Delphi 2009. If you take a TWebBrowser from the palette, put it on a form, then it works :) However, if you put the TWebBrowser control and put it on a form, and then open the form as a child window, it does not work. By 'child' window I don't mean anything to do with MDI; rather I mean opening one form almost as a control onto another (in order words, a Petzold 'child'). Code showing how this is done is posted below. This has not been a problem in earlier versions of Delphi. Something has changed. If someone cou...

Delphi 2010 and RichEdit problem. [Edit]
I am using Delphi 2010 and RichEdit control. When set RichEdit controls WantReturns to False And WordWrap to False. When running application and entering some word in to richedit and clicking to enter key then richedit control text is wrapped and cursor moved new line. Wantreturns property doesnt works. (In the delphi 7 working well) When using Memo control is ok. TRichEdit's wantreturns set false not working. How to fix it? Edited by: Amar Avirmed on Mar 10, 2010 5:18 PM Hello, you might get more answers to your question when asking this in the ..vcl.components.usinn...

TDatamodule problem on Delphi XE2 [Edit]
I reported a problem to QC (#100324) that I think is related with this issue. I've a project that I'm trying to compile with Delphi XE2 and when I close the application or close a form that links to the datamodule where my main connection to Interbase database is located, I'm geting this error message: First chance exception at $0061BCEA. Exception class $C0000005 with message 'access violation at 0x0061bcea: read of address 0x80808088'. Process Fac2011.exe (5608) For example, I have a form with a TIBTransaction and a TIBQuery that are linked to a TIBDatabase that b...

Problem with constructor in Delphi 2011 [Edit]
Anybody helps me plz. {code} type PQuestion = class public q: String; a, b, c, d: String; ans: byte; public constructor Create(q1, a1, b1, c1, d1: String; ans1: byte); end; {code} {code} constructor PQuestion.Create(q1, a1, b1, c1, d1: String; ans1: byte); begin q := q1; a := a1; b := b1; c := c1; d := d1; ans := ans1; end; {code} But when I call it from another unit, I got error message: +Acess violation at address....write at....+ {code} obj.Create('q','a','b','c','d',1);//Example {code...

Problem with query delphi 2010 [Edit]
Problem with query delphi 2010 Staff when I perform the query below I describe the following error occurs: Exception class EAccessViolation with message 'Access violation at address in module 03E64A60' dbxora.dll '. Write of address 004B0041 '. Process PdvMultiEmpresa.exe (5704). The query that esecuto is as follows: SQL.Add ('SELECT *'); SQL.Add ('FROM TABLE (pac_pdv_totalcard.CONSULTA_CONTA_CARTAO (: p_cod_empresa,: p_cpf,: p_nro_cartao,: p_nro_conta ))'); ParamByName ('p_cod_empresa'). AsFmtBcd: = IntegerToBcd...

TWebbrowser and proxy settings problem [Edit]
Hi I use a TWebBrowser and I need to add proxy settings. To do it I use this code: function SetProxy(UserAgent, Address: string): Boolean; var list: INTERNET_PER_CONN_OPTION_LIST; dwBufSize: DWORD; hInternet: Pointer; Options :array[1..3] of INTERNET_PER_CONN_OPTION; begin Result := False; dwBufSize := sizeof(list); list.dwSize := sizeof(list); list.pszConnection := Nil; list.dwOptionCount:= High(Options); Options[1].dwOption := INTERNET_PER_CONN_FLAGS; Options[1].Value.dwValue := PROXY_TYPE_DIRECT or PROXY_TYPE_PROXY; Options[2].dwOption := INTERNET_P...

Delphi 2010 and RichEdit problem [Edit]
I am using Delphi 2010 and RichEdit control. When set RichEdit controls WantReturns to False And WordWrap to False. When running application and entering some word in to richedit and clicking to enter key then richedit control text is wrapped and cursor moved new line. Wantreturns property doesnt works. (In the delphi 7 working well) When using Memo control is ok. TRichEdit's wantreturns set false not working. How to fix it? Edited by: Amar Avirmed on Mar 10, 2010 5:17 PM Amar Avirmed wrote: > I am using Delphi 2010 and RichEdit control. > When set RichEdit con...

Problems, problems, problems
Name: Hans Halvorsen Email: capricorn_at_online.no Product: Thunderbird Summary: Problems, problems, problems Comments: Hi, I downloaded Thunderbird some time ago, and I was over-satisfied whit it and how well it worked. In fact it worked 100% PERFECTLY UNTIL I got an newer update version of it. Since then I' ve had nothing BUT trouble! I've checked adresses, notes, password, deleted accounts and made new one's, checked sign-ins and sign-outs, passwords inside and out, upside and down, so many times that my frustration now is about to turn into pure and major ...

Problem with printing, using Delphi XE2 [Edit]
I have problem with printing images using Delphi XE2. I have code Delphi 7, and this code work very well. {code} procedure Print; var ImgName: string; rect: TRect; jpg: TJPEGImage; begin OpenPictureDialog1.Execute; ImgName := OpenPictureDialog1.FileName; rect.TopLeft:=Point(0,0); rect.BottomRight:=Point(Printer.PageWidth,Printer.PageHeight); jpg := TJPEGImage.Create; jpg.LoadFromFile(ImgName); Printer.BeginDoc; Printer.Canvas.StretchDraw(rect,jpg); Printer.EndDoc; end; {code} But this code Delphi XE2 is not work, printer print clear sheets. (HP ...

Web resources about - Having problem with TWebBrowser on frame [Edit] - embarcadero.delphi.general

Getting TWebBrowser on iOS to zoom
... := TUIWebView.Create; FWebView.setScalesPageToFit(true); // Add this line of code FDelegate := TiOSWebViewDelegate.Create; FDelegate.SetWebBrowser(Self); ...

Embarcadero AppMethod: another route to cross-platform mobile, now with C++ support
Embarcadero has updated AppMethod, its IDE for cross-platform mobile and desktop applications. The IDE now supports C++, and as a special offer, ...

Resources last updated: 12/11/2015 6:04:03 AM