Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Parent WebBrowser (https://www.clubdelphi.com/foros/showthread.php?t=59182)

felipe88 15-08-2008 20:49:18

Parent WebBrowser
 
Hola a todos,
Detallando un poco acerca de como mejorara el Programita, me surgio un problema con el WeBrowser intentando hacer esto:
Código Delphi [-]
Page := TPageControl.Create(Self);          
wb := TWebBrowser.Create(Self);
wb.Parent := Page; // Saca error
El error es Cannot assing to a read-only property cuando le intento asignar como parent el PageControl.
Cita:

Empezado por Ayuda Delphi
WebBrowser provides access to the Web browser functionality of Microsoft’s Shell Doc Object and Control Library (SHDOCVW.DLL).

Unit

ShDocVw

Description

TWebBrowser wraps the IWebBrowser2 interface from Microsoft’s Shell Doc Object and Control Library (SHDOCVW.DLL) to allow you to create a customized Web browsing application or to add Internet, file and network browsing, document viewing, and data downloading capabilities to your applications.

Note: Because TWebBrowser wraps the SHDOCVW.DLL, you must have SHDOCVW.DLL installed to use this component. This DLL ships with Internet Explorer 4 and later. Hereda del TOleControl

Entonces, ¿Como puedo asignarle el parent visual al WebBrowser? :confused:

TOPX 15-08-2008 22:10:55

Hola,

Código Delphi [-]
  Page := TPageControl.Create(Self);
  Page.Parent := Self;

  Tab := TTabSheet.Create(Page);
  Tab.Parent := Page;
  Tab.PageControl := Page;

  wb := TWebBrowser.Create(Self);
  TWinControl(wb).Parent := Tab;

felipe88 15-08-2008 22:21:08

¿Y eso era todo? :rolleyes:...:D Gracias, ya lo estoy probando...

felipe88 16-08-2008 22:00:36

Hola,
Estuve mirando este codigo proporcionado por la ayuda de Delphi para optimizar el proceso que pretendo
Código Delphi [-]
procedure TForm1.FormCreate(Sender: TObject);
const
  TabTitles: array[0..3] of ShortString = ('Customer', 'Orders', 'Items', 'Parts' );
var
  i: Integer;
  PageControl1: TPageControl;
begin
  PageControl1 := TPageControl.Create(Self);
  PageControl1.Parent := Self;
  PageControl1.Align := alClient;
  for i := Low(TabTitles) to High(TabTitles) do
    with TTabSheet.Create(PageControl1) do
    begin
      PageControl := PageControl1;
      Name := 'ts' + TabTitles[i];
      Caption := TabTitles[i];
   end;
end;
Partiendo desde aqui quise probrar algo como esto...
Código Delphi [-]
procedure TForm1.Cargar;
var pag:TStringList;
    Page:TPageControl;
    wb:TWebBrowser;
    i:Integer;
begin
  pag := TStringList.Create;
  Page := TPageControl.Create(Self);
  Page.Parent := Self;
  Page.Top := 100;
  Page.Left := 100;
  Page.Height := 300;
  Page.Width := 500;
  pag.LoadFromFile('C:\Texto.txt');
  for i:=0 to pag.Count -1 do
    begin
      with TTabSheet.Create(Page) do
        begin
          Name := 'tab' + IntToStr(i);
          Caption := pag.Strings[i];
          PageControl := Page;
          wb := TWebBrowser.Create(Page);
          TWinControl(wb).Parent := PageControl; //Esta es la duda
        end;
    end;
end;
Como lo indico en el codigo, si lo hago de ese modo aparece el WebBrowser pero no deja ver los TabSheets ya que obviamente se crea sobre estos y no dentro de estos. Entonces, si quisiera que fuera asi; ¿como debo pasar la propiedad Parent para que sea el TabSheet recien creado? :confused:...

roman 18-08-2008 16:00:03

¿Qué tal así?

Código Delphi [-]
TWinControl(wb).Parent := Page.Pages[i]; //Esta era la duda

// Saludos

felipe88 18-08-2008 17:40:07

Roman, muchas gracias... esa era la solucion ;), ya tan solo me restaria asignar el nombre a cada WebBrowser para que en otro procedimiento pueda pasarles las URL...


La franja horaria es GMT +2. Ahora son las 17:35:19.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi