Autor Beitrag
Björn karpenstein
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 96

Windows XP, Linux
D7, K3
BeitragVerfasst: Mi 21.09.05 11:04 
Welche Komponente bei Delphi7 kann einen HTML-String wie im Browser darstellen?

Habs eben schonmal mit TWebBrowser versucht, hab aber bis auf das Navigate (was nur eine URL will - kann aber auch ein Textfile sein) nichts sinnvolles gefunden. Kann mir mal jdm. helfen?

Das Problem: Rufe mit IdPOP3 eMail ab und hole mir den Body mit:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
//Liste mit Mailanhängen und Mailbody
  for intIndex := 0 to Pred(msg.MessageParts.Count) do
  begin
    if (msg.MessageParts.Items[intIndex] is TIdAttachment) then
    begin
      li := ListView1.Items.Add;
      li.Caption := TIdAttachment(msg.MessageParts.Items[intIndex]).FileName;
    end  else
    begin
      if msg.MessageParts.Items[intIndex] is TIdText then
      begin
        RichEdit1.Text :=TIdText(msg.MessageParts.Items[intIndex]).Body.Text;
      end;
    end;
  end;


Das sieht dann lustigerweise bei einer eMail, wo nur "Hallo" drin steht so aus:

ausblenden volle Höhe 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:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 10">
<meta name=Originator content="Microsoft Word 10">
<link rel=File-List href="cid:filelist.xml@01C5BE98.5ED549F0">
<!--[if gte mso 9]><xml>
 <o:OfficeDocumentSettings>
  <o:DoNotRelyOnCSS/>
 </o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:SpellingState>Clean</w:SpellingState>
  <w:GrammarState>Clean</w:GrammarState>
  <w:DocumentKind>DocumentEmail</w:DocumentKind>
  <w:HyphenationZone>21</w:HyphenationZone>
  <w:EnvelopeVis/>
  <w:Compatibility>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]-->
<style>
<!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
  {mso-style-parent:"";
  margin:0cm;
  margin-bottom:.0001pt;
  mso-pagination:widow-orphan;
  font-size:12.0pt;
  font-family:"Times New Roman";
  mso-fareast-font-family:"Times New Roman";}
a:link, span.MsoHyperlink
  {color:blue;
  text-decoration:underline;
  text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
  {color:purple;
  text-decoration:underline;
  text-underline:single;}
span.EmailFormatvorlage17
  {mso-style-type:personal-compose;
  mso-style-noshow:yes;
  mso-ansi-font-size:10.0pt;
  mso-bidi-font-size:10.0pt;
  font-family:Arial;
  mso-ascii-font-family:Arial;
  mso-hansi-font-family:Arial;
  mso-bidi-font-family:Arial;
  color:windowtext;}
@page Section1
  {size:595.3pt 841.9pt;
  margin:70.85pt 70.85pt 2.0cm 70.85pt;
  mso-header-margin:35.4pt;
  mso-footer-margin:35.4pt;
  mso-paper-source:0;}
div.Section1
  {page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
 /* Style Definitions */ 
 table.MsoNormalTable
  {mso-style-name:"Normale Tabelle";
  mso-tstyle-rowband-size:0;
  mso-tstyle-colband-size:0;
  mso-style-noshow:yes;
  mso-style-parent:"";
  mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
  mso-para-margin:0cm;
  mso-para-margin-bottom:.0001pt;
  mso-pagination:widow-orphan;
  font-size:10.0pt;
  font-family:"Times New Roman";}
</style>
<![endif]-->
</head>

<body lang=DE link=blue vlink=purple style='tab-interval:35.4pt'>

<div class=Section1>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>hallo<o:p></o:p></span></font></p>

</div>

</body>

</html>
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mi 21.09.05 11:55 
da wird dir wphl nix anderes ürig bleiben, als doch mir der webbrowser kompo zu arbiete. bei www.swissdelphicenter.ch steht, wie man einen HTML Text direkt in eine TWebbrowser komponente einlesen kann.
Du kannst natürlich, wenn du den TWebbrowser nicht hernehmen willst, weil es eine IE instanz ist auch den TMozillaBrowser nehmen. dazu findest du eineige Beiträge hier im Forum !

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Björn karpenstein Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 96

Windows XP, Linux
D7, K3
BeitragVerfasst: Mi 21.09.05 12:21 
ausblenden 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:
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(00);
        (WebBrowser.Document as IPersistStreamInit).Load(TStreamAdapter.Create(ms));
      finally
        ms.Free;
      end;
    finally
      sl.Free;
    end;
  end;
end;


Danke! Das hier sieht sehr sinnig aus :)
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mi 21.09.05 13:31 
Hallo,

etwas :wink: kürzer:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
var s : String;
  s := '<HTML><BODY><H1>Testseite</H1><b>Hallo</b></BODY></HTML>';
  WebBrowser1.Navigate('about:' + s);
end;

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )