Форум: "Начинающим";
Текущий архив: 2006.09.24;
Скачать: [xml.tar.bz2];
ВнизTRichEdit, загрузка rtf текста Найти похожие ветки
← →
чаки (2006-09-06 11:15) [0]Как корректно загрузить RTF текст в RichEdit. Т.е. есть переменная rtfstring: string, содержащая RTF текст ("{\rtf1\ansi\ansicpg1251\deff0\deflang1049{\fonttbl{\f0\fnil\fcharset0 Verdana;..."), необходимо загрузить этот текст в RichEdit. Как это сделать?
← →
PSPF2003 © (2006-09-06 11:21) [1]procedure SetPaste(Value: Boolean);
var h:thandle; p:pchar; C:integer;
begin
ClipBoard.Open;
try
c:=RegisterClipboardFormat(pchar(CF_RTF));
H := Clipboard.GetAsHandle(C);
p := GlobalLock(h);
FRTF:= StrPas(p);
GlobalUnlock(h);
finally
Clipboard.Close;
FPaste:=false;
end;
end;
← →
PSPF2003 © (2006-09-06 11:25) [2]Извиняюсь не тот кусок кода…
← →
PSPF2003 © (2006-09-06 11:33) [3]Подправишь сам
procedure TForm1.Button1Click(Sender: TObject);
var
ms : TMemoryStream;
FRTF : String ;
begin
ms:=TMemoryStream.create;
FRTF := Memo1.Lines.CommaText;
ms.Write(pchar(FRtf)^,length(FRTF));
ms.Position:=0;
RichEdit1.lines.LoadFromStream(ms);
ms.Free;
end;
Содержимое мемо
{\rtf1\ansi\ansicpg1251\uc1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\defl ang1049\deflangfe1049{\fonttbl{\f0\froman\fcharset204\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f38\froman\fcharset0\fprq2 Times New Roman;}
{\f36\froman\fcharset238\fprq2 Times New Roman CE;}{\f39\froman\fcharset161\fprq2 Times New Roman Greek;}{\f40\froman\fcharset162\fprq2 Times New Roman Tur;}{\f41\froman\fcharset177\fprq2 Times New Roman (Hebrew);}
{\f42\froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f43\froman\fcharset186\fprq2 Times New Roman Baltic;}{\f44\froman\fcharset163\fprq2 Times New Roman (Vietnamese);}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255 \blue255;
\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green25 5\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\re d0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\b lue0;
\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1049\langfe1049\cgrid\langnp1049\langfenp1049 \snext0 \styrsid7942023 Normal;}{\*\cs10 \additive
\ssemihidden \styrsid7942023 Default Paragraph Font;}{\*
\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\tr paddfr3\trcbpat1\trcfpat1\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbr drr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv
\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1024\langfe1024\cgrid\langnp1024\langfenp1024 \snext11 \ssemihidden Normal Table;}}{\*\latentstyles\lsdstimax156\lsdlockeddef0}{\*\rsidtbl \rsid7942023}
\paperw11906\paperh16838\margl1701\margr850\margt1134\margb1134 \deftab708\widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\no spaceforul\formshade\horzdoc\dgmargin\dghspace180\dgvspace180\dghorigin1701\dgvo rigin1984\dghshow1\dgvshow1
\jexpand\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\usel tbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\nobrkwrptbl\snaptogridincell\a llowfieldendsel\wrppunct\asianbrkrule\rsidroot7942023\newtblstyruls\nogrowautofi t \fet0\sectd
\linex0\headery708\footery708\colsx708\endnhere\sectlinegrid360\sectdefaultcl\sf tnbj {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang
{\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl7
\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}\pard\plain
\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid79 42023 \fs24\lang1049\langfe1049\cgrid\langnp1049\langfenp1049 {\insrsid7942023 \"c8\"e7\"e2\"e8\"ed\"ff\"fe\"f1\"fc }{\b\insrsid7942023\charrsid13724446 \"ed\"e5}{
\insrsid7942023 \"f2\"ee\"f2 \"ea\"f3\"f1\"ee\"ea \"ea\"ee\"e4\"e0\"85}{\insrsid7942023\charrsid5850826
\par }}
← →
begin...end © (2006-09-06 11:38) [4]var
S: string;
Stream: TStringStream;
begin
Stream := TStringStream.Create(S);
try
RichEdit.PlainText := False;
RichEdit.Lines.LoadFromStream(Stream)
finally
Stream.Free
end
end
Страницы: 1 вся ветка
Форум: "Начинающим";
Текущий архив: 2006.09.24;
Скачать: [xml.tar.bz2];
Память: 0.46 MB
Время: 0.037 c