Autor Beitrag
t3Qn0lo-G
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68

Win 7
Delphi 7 Enterprise
BeitragVerfasst: Di 26.10.04 21:25 
Also, ich möchte, wenn ich mein Projekt starte sofort einen Text im WebBrowser haben, zb: "Bitte erst einloggen" oder sonstwas.

Ich habe auch diesen Tipp probiert, ging nicht, kam nen Fehler: www.swissdelphicente...showcode.php?id=2148

Gibt es sonst noch andere Möglichkeiten, außer eine lokale Datei in den Browser zu laden?

[edit]Das Ganze geht doch, leider muss dafür bereits eine Seite offen sein[/edit]
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Di 26.10.04 23:45 
Du kannst das z.B. auch so machen...
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleCtrls, SHDocVw, MSHTML, StdCtrls;

type
  TForm1 = class(TForm)
    WebBrowser1: TWebBrowser;
    procedure FormCreate(Sender: TObject);
    procedure WebBrowser1DocumentComplete(Sender: TObject;
      const pDisp: IDispatch; var URL: OleVariant);
  private
    { Private-Deklarationen }
    FirstRun: Boolean;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{--------------------------------------------------------------------------------------------------}

procedure TForm1.FormCreate(Sender: TObject);
begin

  FirstRun := True;
  WebBrowser1.Navigate('about:blank');

end;

{--------------------------------------------------------------------------------------------------}

procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
var
  WebDoc: HTMLDocument;
  WebBody: HTMLBody;
begin

  if FirstRun then
    if pDisp = WebBrowser1.Application then
    begin
      FirstRun := False;
      WebDoc := WebBrowser1.Document as HTMLDocument;
      WebBody := WebDoc.body as HTMLBody;
      WebBody.insertAdjacentHTML('BeforeEnd', '<h1>Hello World!</h1>');
    end;

end;

{--------------------------------------------------------------------------------------------------}

end.

_________________
Ciao, Sprint.
t3Qn0lo-G Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68

Win 7
Delphi 7 Enterprise
BeitragVerfasst: Mi 27.10.04 14:33 
Ah, wunderbar ;) danke!