Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi {$Resource HTML.res}/ html aus Ressource in Webbrowser laden (https://www.delphipraxis.net/101085-%7B%24resource-html-res%7D-html-aus-ressource-webbrowser-laden.html)

taktaky 8. Okt 2007 10:54


{$Resource HTML.res}/ html aus Ressource in Webbrowser laden
 
Hallo,

ich habe eine html und ein Bild in Ressource
Delphi-Quellcode:
//.rC :
index     HTML  "index.html"
bild1      BILDER "logo.gif"
Wie kann ich mein index.html aus Ressource in meinen Webbrowser1 laden?

Wer kann mir weiter helfen :
Delphi-Quellcode:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    WebBrowser1: TWebBrowser;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
{$Resource HTMLs.res}

// um html aus Res in Webbrowser zu laden brauche ich eine Fuktion
procedure TForm1.LoadvonRessource(htmls:string);
var
  Adress: string;
  index: array[0..255] of Char;
begin
  GetModuleFileName(hInstance, index, SizeOf(index));
  Adress:='res://' + StrPas(index) + '/RT_HTML/'+HTMLS;
  WebBrowser1.Navigate(Adress);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Webbrowser1.navigate(adress);
//Webbrowser1.navigate('index.htm');


end;

end.

Daniel 8. Okt 2007 11:01

Re: {$Resource HTML.res}/ html aus Ressource in Webbrowser l
 
Was geht denn an Deinem Code nicht?

Was hast Du bisher versucht, um an die Lösung zu kommen. Wird das ein weiterer Teil nach dem Motto: "Ich will dies und jenes erreichen, macht mir das mal bitte" ?

Du scheinst Dich an einem Bereich zu versuchen, der für Deine Menge an Grundwissen eindeutig zu komplex ist.

taktaky 8. Okt 2007 12:11

Re: {$Resource HTML.res}/ html aus Ressource in Webbrowser l
 
Zitat:

Zitat von Daniel
Was geht denn an Deinem Code nicht?

Ich habe die Fehler behoben :mrgreen:
Aber leider wird die html in Webbrowser1 nicht geladen :(
Die Frage wie muss der Code von Button1 sein, damit die html von Resource in Webbrowser geladen wird?
Delphi-Quellcode:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    WebBrowser1: TWebBrowser;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
     procedure LoadvonRessource(htmls:string);
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
{$R htmls.res}

procedure TForm1.LoadvonRessource(htmls:string);
var
  Adress: string;
  index: array[0..255] of Char;
begin
  GetModuleFileName(hInstance, index, SizeOf(index));
  Adress:='res://' + StrPas(index) + '/RT_HTML/'+htmls;
  WebBrowser1.Navigate(Adress);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  Adress: string;

begin

LoadvonRessource('INDEX');
WebBrowser1.Navigate(Adress);

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
webBrowser1.Navigate('about:blank');
end;

end.

DeddyH 8. Okt 2007 12:16

Re: {$Resource HTML.res}/ html aus Ressource in Webbrowser l
 
Das Protokoll "res" kenne ich noch nicht.

taktaky 8. Okt 2007 12:24

Re: {$Resource HTML.res}/ html aus Ressource in Webbrowser l
 
Zitat:

Zitat von DeddyH
Das Protokoll "res" kenne ich noch nicht.

hallo Deddy

soll nun der Schüller dem Lehrer helfen? :mrgreen:
Delphi-Quellcode:
The 'res:' Protocol

The 'res:' protocol lets you extract a resource from a compiled module like an EXE or DLL. While this protocol has been introduced to work with HTML pages, you can use it to work with other type of resources as well, including custom resources. A URL based on this protocol looks like this:

res://resource_file.ext[/resource_type]/{res_id}


Alle Zeitangaben in WEZ +1. Es ist jetzt 19:49 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz