In my last blog on this topic, from about five weeks ago, I wrote how I exported blogs that had been sent to me via Outlook to a text file containing HTML statements, and how I 'taught' the blog manager to display those text files within an internal web brower. Of the 1646 blogs to date, I must have connected about 800 files.
After another session of renumbering files the other day, I thought that it might be better if the text of these files were stored within a table inside the blog database. As I wrote then,
I spent a frustrating hour and a half trying to save html text to a new table; my guide was a question on Stack Exchange where someone asked how to save the text displayed within a web browser - not exactly my situation, but close. Big mistake. Eventually I realised that I was knocking my head against a brick wall, so I decided to take the dog for a walk.
Exporting the data from Outlook solved the 'saving html text' problem; a few days ago, I wondered whether I could load the text from these files into a table, then later retrieve that text and display it in a web browser without having to save it to a file then load that file. In a more lucid moment, I searched the web and came across this page with the following code:
uses ActiveX; procedure WB_LoadHTML(WebBrowser: TWebBrowser; HTMLCode: string); var sl: TStringList; ms: TMemoryStream; begin WebBrowser.Navigate('about:blank'); while WebBrowser.ReadyState < READYSTATE_INTERACTIVE do Application.ProcessMessages; if Assigned(WebBrowser.Document) then begin sl := TStringList.Create; try ms := TMemoryStream.Create; try sl.Text := HTMLCode; sl.SaveToStream(ms); ms.Seek(0, 0); (WebBrowser.Document as IPersistStreamInit).Load(TStreamAdapter.Create(ms)); finally ms.Free; end; finally sl.Free; end; end; end; procedure TForm1.Button1Click(Sender: TObject); begin WB_LoadHTML(WebBrowser1,'SwissDelphiCenter'); end;
|
|
Title | Tags |
---|---|---|---|
185 |
|
MBA | MBA |
389 |
|
Masochistic programming | Programming, Unicode |
881 |
|
Vinyl log 22 - 27 July | Vinyl log, Fairport Convention, Jackson Browne |
1057 |
|
Sing Street | Films, Swell Season |
1157 |
|
Careless love | Literature, DCI Banks |
1248 |
|
10 years of post-graduate study | DBA |
No comments:
Post a Comment