Steps to recreate (Delphi 2007):
Create a new VCL project;
Add a TMemo to the form;
Add the following text to the lines:
{\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0\froman\fprq2\fcharset0
Batang;}{\f1\fswiss\fcharset0 Arial;}{\f2\fswiss\fprq2\fcharset0 Arial
Black;}}
{\colortbl ;\red0\green0\blue255;}
\viewkind4\uc1\pard\f0\fs20 one\f1 \cf1 =\cf0 \f2 een\f1\par
\par
}
Press OK;
Try to edit the lines again..
Exp.: You can edit the lines.
Act.: Error "Richedit line insertion error"
Dou you have the same problem and if yes, should I add this to QC?
> I found a possible bug in TMemo.
>
> Steps to recreate (Delphi 2007):
>
> Create a new VCL project;
> Add a TMemo to the form;
> Add the following text to the lines:
>
> {\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0\froman\fprq2\fc
> harset0 Batang;}{\f1\fswiss\fcharset0
> Arial;}{\f2\fswiss\fprq2\fcharset0 Arial Black;}}
> {\colortbl ;\red0\green0\blue255;}
> \viewkind4\uc1\pard\f0\fs20 one\f1 \cf1 =\cf0 \f2 een\f1\par
> \par
> }
>
Test case error. A TMemo does not support rich text. A TRichedit does
not allow you to load rich text this way via the lines property, it
would be interpreted as plain text with all the tags visible. In fact
the behaviour you get depends on the version of the rich edit control
around on the users PC and is thus pretty unpredictable.
--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
Every RTF code gets a TMemo confused:
{\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0\fswiss\fcharset0
Arial;}}
\viewkind4\uc1\pard\f0\fs20\par
}
I have Delphi 2007 and Windows Vista.
Hi Peter,
I want to show the RichEdit source in a TMemo (with tags and all). Thats why
I want to use a TMemo, and not a TRichEdit. But somehow Delphi gets confused
doing this.
Did you try to add the source to the TMemo and open the component editor
again?
Best regards,
Hamer
>> Steps to recreate (Delphi 2007):
>>
>> Create a new VCL project;
>> Add a TMemo to the form;
>> Add the following text to the lines:
How do you 'Add' it?
>> {\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0\froman\fprq2\fcharset0
>> Batang;}{\f1\fswiss\fcharset0 Arial;}{\f2\fswiss\fprq2\fcharset0 Arial
>> Black;}}
>> {\colortbl ;\red0\green0\blue255;}
>> \viewkind4\uc1\pard\f0\fs20 one\f1 \cf1 =\cf0 \f2 een\f1\par
>> \par
>> }
Does it show the raw rtf, or the text 'one'?
>> Press OK;
? No OK button specified as being on this form.
>> Try to edit the lines again..
>>
>> Exp.: You can edit the lines.
>> Act.: Error "Richedit line insertion error"
Odd.
A Memo is not a richedit, it is a standard edit which allows multilines.
>>
>> Dou you have the same problem and if yes, should I add this to QC?
>
> Every RTF code gets a TMemo confused:
Quite often Lines.Add(... fails with 'line insertion error'.
You should therefore *always* add text with
Memo.Seltext:='\rtf1 ....'
> {\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0\fswiss\fcharset0
> Arial;}}
> \viewkind4\uc1\pard\f0\fs20\par
> }
>
> I have Delphi 2007 and Windows Vista.
I am wondering if the latest Windows DLLs try to parse the text entered into
an edit and if they think it might be rtf they send it to some other routine
to turn it into the text content of the rtf ??
(versions of Wordpad post XPSp2 seem to do this even if you tell it that it
is plain text in a .txt file - but Wordpad in this XPSP2 uses a completely
different DLL to Richedit .. unless Microsoft changed it in Vista ??)
In Delphi 2007, create a new VCL Forms Application;
Add a TMemo to the form;
Click om the TMemo;
Go to the Object Inspector;
Click on the property Lines to edit them;
Add the following RTF code in the String List Editor:
{\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0\fswiss\fcharset0
Arial;}}
\viewkind4\uc1\pard\f0\fs20\par
}
Click OK;
The RTF code is visible in the Memo1 on the form.
Go to the Object Inspector again, and try to open the String List Editor of
property Lines again.
Exp.: String List Editor is shown.
Act.: Error "Richedit line insertion error"
Somehow the TMemo strings behave like a RichEdit?
Call stack:
[2019195C]{vcl100.bpl } ComCtrls.TRichEditStrings.Insert (Line 11557,
"ComCtrls.pas" + 19) + $1C
[200336B0]{rtl100.bpl } Classes.TStrings.Add (Line 4277,
"common\Classes.pas" + 2) + $8
[200336C7]{rtl100.bpl } Classes.TStrings.AddObject (Line 4282,
"common\Classes.pas" + 1) + $4
[20033759]{rtl100.bpl } Classes.TStrings.AddStrings (Line 4298,
"common\Classes.pas" + 4) + $23
[201916A8]{vcl100.bpl } ComCtrls.TRichEditStrings.AddStrings (Line 11491,
"ComCtrls.pas" + 4) + $3
[2003382B]{rtl100.bpl } Classes.TStrings.Assign (Line 4317,
"common\Classes.pas" + 12) + $7
[20D68099]{designide100.bpl} StringsEdit.TStringsEditDlg.SetLines (Line 81,
"StringsEdit.pas" + 1) + $E
[20D68C66]{designide100.bpl} StrEdit.TStringListProperty.Edit (Line 302,
"StrEdit.pas" + 16) + $E
[20AB55C6]{coreide100.bpl} PropInsp.TPropertyInspector.PropListEditDblClick
(Line 855, "PropInsp.pas" + 20) + $5
[20E0ED7D]{vclide100.bpl} IDEInspListBox.TInspListBox.DoEditDblClick (Line
967, "ideinsplistbox.pas" + 2) + $A
[20E10B3B]{vclide100.bpl} IDEInspListBox.TInspListBox.ListButtonClick (Line
1657, "ideinsplistbox.pas" + 2) + $2
[2013CA2C]{vcl100.bpl } Controls.TControl.Click (Line 5229, "Controls.pas"
+ 9) + $8
[20E0BD4A]{vclide100.bpl} IDEListBtns.TListButton.WMLButtonUp (Line 579,
"IDEListBtns.pas" + 8) + $11
[2013C527]{vcl100.bpl } Controls.TControl.WndProc (Line 5146,
"Controls.pas" + 83) + $6
[2014010B]{vcl100.bpl } Controls.TWinControl.IsControlMouseMsg (Line 7168,
"Controls.pas" + 1) + $9
[201406A7]{vcl100.bpl } Controls.TWinControl.WndProc (Line 7304,
"Controls.pas" + 111) + $6
[2013FDD0]{vcl100.bpl } Controls.TWinControl.MainWndProc (Line 7073,
"Controls.pas" + 3) + $6
[20040E4C]{rtl100.bpl } Classes.StdWndProc (Line 11583,
"common\Classes.pas" + 8) + $0
[201625E8]{vcl100.bpl } Forms.TApplication.ProcessMessage (Line 8103,
"Forms.pas" + 21) + $1
[2016262A]{vcl100.bpl } Forms.TApplication.HandleMessage (Line 8124,
"Forms.pas" + 1) + $4
[2016291F]{vcl100.bpl } Forms.TApplication.Run (Line 8223, "Forms.pas" +
20) + $3
[0042297A]{bds.exe } bds.bds (Line 195, "" + 7) + $7
I can reproduce this in D7 too. The issue is not TMemo but the
design-time editor for TStrings - so on the one hand, adding the RTF at
runtime doesn't cause any problems, but on the other, the design-time
issue effects TListBox.Items, TComboBox.Items, etc., and not just
TMemo.Lines.
> > Steps to recreate (Delphi 2007):
> >
> > Create a new VCL project;
> > Add a TMemo to the form;
> > Add the following text to the lines:
> >
> > {\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0\froman\fprq2\
> > fcharset0 Batang;}{\f1\fswiss\fcharset0
> > Arial;}{\f2\fswiss\fprq2\fcharset0 Arial Black;}}
> > {\colortbl ;\red0\green0\blue255;}
> > \viewkind4\uc1\pard\f0\fs20 one\f1 \cf1 =\cf0 \f2 een\f1\par
> > \par
> > }
> >
> > Press OK;
> > Try to edit the lines again..
> >
> > Exp.: You can edit the lines.
> > Act.: Error "Richedit line insertion error"
> >
> > Dou you have the same problem and if yes, should I add this to QC?
>
> Every RTF code gets a TMemo confused:
In fact it is not the TMemo. The TStrings property editor uses a
TRichedit for the text, not a TMemo. It is the editor that gets
confused, and that is in fact a Windows problem. I don't know when MS
did that but with one version of the rich edit control they added a
kind of autodetection for rich text added via the WM_SETTEXT message
(which is supposed to and also did in prior versions add only plain
text).
The solution is simple in your case: do not add the text at
design-time, add it at run-time by assigning to the memos Text property.
> I don't know when MS did that but with one version of the rich
>edit control they added a kind of autodetection for rich text added
> via the WM_SETTEXT message (which is supposed to and also
> did in prior versions add only plain text).
The WM_SETTEXTEX message of RichEdit v3.0 does such auto-detection:
http://msdn.microsoft.com/en-us/library/bb774284(VS.85).aspx
"If lParam starts with a valid Rich Text Format (RTF) ASCII sequence-for
example, "{\rtf" or "{urtf"-the text is read in using the RTF reader."
Not sure if it applies to WM_SETTEXT as well. Apparently, it does.
Gambit
Thank for your answers. I think I don't write a qc report, because I think
CodeGear should work on the Unicode Delphi and not on these trivial IDE
bugs..
Best regards,
H
Mh, I may have been off here. The TStrings property editor should in
fact use TStrings.Assign to transfer the content of the source TStrings
to its TRichedits Lines property (and back). Tstrings.Assign ends up
copying the lines one by one, and that means the message used to
transfer the content is EM_REPLACESEL, not WM_SETTEXT. See
TRicheditstrings.Insert. That makes the problem even weirder since the
control does not get the rich text in one chunk...