Hello,
I'm making a page viewing program that views URLs in a list it downloads from the Internet. I have it downloading the list and then loading it into a memo but I'm struggling on how to get all the URLs off of it and view them each individually in a TWebBrowser. Anyone know how to do this? Here's my source code if it helps:
I'm making a page viewing program that views URLs in a list it downloads from the Internet. I have it downloading the list and then loading it into a memo but I'm struggling on how to get all the URLs off of it and view them each individually in a TWebBrowser. Anyone know how to do this? Here's my source code if it helps:
Code:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, WinInet, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
List: TMemo;
DownloadL: TButton;
Status: TLabel;
View: TButton;
procedure DownloadLClick(Sender: TObject);
procedure ViewClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function GetInetFile (const fileURL, FileName: String): boolean;
const
BufferSize = 1024;
var
hSession, hURL: HInternet;
Buffer: array[1..BufferSize] of Byte;
BufferLen: DWORD;
f: File;
sAppName: string;
begin
result := false;
sAppName := ExtractFileName(Application.ExeName) ;
hSession := InternetOpen(PChar(sAppName), INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0) ;
try
hURL := InternetOpenURL(hSession, PChar(fileURL), nil, 0, 0, 0) ;
try
AssignFile(f, FileName) ;
Rewrite(f,1) ;
repeat
InternetReadFile(hURL, @Buffer, SizeOf(Buffer), BufferLen) ;
BlockWrite(f, Buffer, BufferLen)
until BufferLen = 0;
CloseFile(f) ;
result := True;
finally
InternetCloseHandle(hURL)
end
finally
InternetCloseHandle(hSession)
end
end;
procedure TForm1.DownloadLClick(Sender: TObject);
var
internetFile,
localFileName: string;
begin
Status.Caption:='Downloading...';
internetFile := '[URL unfurl="true"]http://skysthelimitco.webs.com/URLList.txt';[/URL]
localFileName := 'URLList.txt';
if GetInetFile(internetFile, localFileName) then begin
ShowMessage('Download successful.');
List.Lines.LoadFromFile(localFileName);
View.Enabled:=True;
Status.Caption:='Idle...';
end
else
ShowMessage('Error in file download.') ;
Status.Caption:='Idle...';
end;
procedure TForm1.ViewClick(Sender: TObject);
begin
end;
end.