Solved

how to make several html page into one file , and then read it in my program?

Posted on 2002-04-17
5
130 Views
Last Modified: 2010-04-04
how to make several html page into one file , and then read it in my program?

i have some html file , and i want pack them into one
file, then use WebBrowser vcl compenent show them by
a certain order.

could you help me ?
0
Comment
Question by:bloodbird
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:Gwena
Comment Utility
Huh?

If you actually just want to join several html pages together...like concatinating strings.. and then display the result..then that won't work well :-)

If you want to take several html pages and somehow add them to your exe file and then display them at run time...then that is pretty easy... but I do it by just calling the default web browser to display the pages...I extract the pages into windows/temp  it works well.

If webbrowser vcl can show a page held in a stream then you could do that and never write the html to the disk...

If this is the sort of thing you want to do let me know and I will send you some demo code.  I made a little program that stores a copy of a website inside of itself..then extracts and displays it by clicking a button :-)
0
 

Author Comment

by:bloodbird
Comment Utility
hi! Gwena

  That is what i want , if it can show a page held in
stream ,that could be wonderful ,

where is your code ?

my email address : kisskiller@163.net

very thank you
0
 
LVL 5

Accepted Solution

by:
Gwena earned 100 total points
Comment Utility
Hi :-)

 I am mailing you a demo to kisskiller@163.net

  I included all source and 2 exe demos... one is just the compiled source...and the other is the same exe but I have run the program and stuffed a small website into it... just push the button and it will display :-)

  Be sure and read the comments inside ExeMod.pas .. especially if you use NT/2000/XP  !

  I did this demo for someone else a while back..but it seems to fit your needs well so I just modified it slightly for your use.

  You can put any sort of files into this... you can put all the files for a huge delphi project and extract them with a single button push... just remember that the FIRST file you stuff into the archive will be the item that is extracted and executed at runtime!! this can be anything at all... exe,htm/l,pdf,ra... anything :-)

  Here is the source for the demo.... I hope it formats correctly..sometimes it doesn't when you post it here on EE



unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, ExeMod, Buttons, ShellAPI;

type
  TForm1 = class(TForm)
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    OpenDialog1: TOpenDialog;
    SpeedButton3: TSpeedButton;
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure FormDblClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Count: Integer;  //this variable holds the number of files added to the exe

implementation

{$R *.DFM}

//This procedure handles adding a file to an ebook exe
//==============================================================================
procedure TForm1.SpeedButton1Click(Sender: TObject);
Var Temp: String;
begin

if Exe = '' then ReadExe;    //These 2 lines make sure that a new file cannot
if Exe[3] <> 'P' then Exit;  //be added to a finalized ebook..

OpenDialog1.Execute;
If OpenDialog1.FileName <> '' then
begin
  Add2Exe('E-BookFileName'+IntToStr(Count),ExtractFileName(OpenDialog1.FileName));
  AddFile2Exe('E-BookFile'+IntToStr(Count),OpenDialog1.FileName);
  Inc(Count);
end;
end;
//==============================================================================



//This procedure rebuilds the exe at runtime by adding all the files.
//==============================================================================
procedure TForm1.SpeedButton2Click(Sender: TObject);
Var Temp: String;
begin
ExtractFromExe('E-BookFileName0',Temp);
If Temp = '' then Exit;
Exe[3] := Chr(Count);
AlterExe;
end;
//==============================================================================



//This procedure extracts a finished ebook to disk and views it with browser..
//the first file you stuffed into the ebook is what will be executed so make
//certain you put the main page as the first saved file... usually this is
//index.htm/l  ... but it could be anything at all... including another exe :-)
//==============================================================================
procedure TForm1.SpeedButton3Click(Sender: TObject);
Var
Temp: String;
X,Y: Byte;
begin
ReadExe;
If Exe[3] = 'P' then Exit;
Y := ord(Exe[3])-1;
For X := 0 to Y do
begin
  ExtractFromExe('E-BookFileName'+IntToStr(X),Temp);
  Extract2File('E-BookFile'+IntToStr(X),Temp);
end;
ExtractFromExe('E-BookFileName0',Temp);
ShellExecute(Form1.Handle,nil,pchar(Temp),
nil,nil, SW_SHOWNORMAL);
end;
//==============================================================================



//This procedure returns the running exe to its original state .. to activate
//this just double click somewhere on the form of either a finalized ebook
//or do it if you make a mistake while building an ebook and want to start over.
//==============================================================================
procedure TForm1.FormDblClick(Sender: TObject);
Var
Temp: String;
X,Y: Byte;
begin
Y := ord(Exe[3])-1;
For X := 0 to Y do
begin
  DelFromString('E-BookFileName'+IntToStr(X),Exe);
  DelFromString('E-BookFile'+IntToStr(X),Exe);
  Exe[3] := 'P';
end;
AlterExe;
end;
//==============================================================================



//This procedure always runs first and it checks to see if the exe is a
//finalized ebook... if it is it alters the appearance of the form to reflect
//that fact :-)
//==============================================================================
procedure TForm1.FormCreate(Sender: TObject);
begin
ReadExe;
if Exe[3] <> 'P' then
begin
  Form1.Height := 85;
  SpeedButton3.Top := 14;
  Form1.Color := $00BFDABA;
  SpeedButton3.Visible := True;
  SpeedButton1.Visible := False;
  SpeedButton2.Visible := False;
end;
end;
//==============================================================================

end.






0
 
LVL 5

Expert Comment

by:Gwena
Comment Utility
Oh...

I just had the demo extract the files to the current directory... you could extract them to windows/temp just as easily ...  sorry about not giving demo code for viewing the html pages from a stream.. but I only have the free D6 personal and D2 standard... so I can't try out using Webrowser vcl.... I'm not sure if it can do this anyway. There is a shareware component that can... at least I seem to remember seeing one somewhere :-)
0
 

Author Comment

by:bloodbird
Comment Utility
hi, Gwena,
  thank you very much , your code is good :)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now