|
|
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » How To Find/Replace on RichEditWithToolBar
How To Find/Replace on RichEditWithToolBar [message #16539] |
Mon, 23 June 2008 22:14 |
alex100
Messages: 118 Registered: November 2007
|
Experienced Member |
|
|
Hi all,
I am trying to use a button to test the find/replace operation on the RichEditWithToolBar but I cant access that member.
Can you, please, tell me How do I do that?
A sample source code would be appreciated,
Thank you,
Alex
|
|
|
|
Re: How To Find/Replace on RichEditWithToolBar [message #16560 is a reply to message #16548] |
Thu, 26 June 2008 10:43 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
alex100 wrote on Tue, 24 June 2008 11:48 | Is it possible to make this?
Thank you
Alex
|
You cannot invoke it directly, but there is
void FindReplaceTool(Bar& bar, dword key = K_CTRL_F);
member that adds the button to any toolbar.
Note that button just opens the find dialog, IMO it is pointless to expose this as public (but I can if you think it would help, OTOH it would lock us with currect find/replace user interface).
Mirek
[Updated on: Thu, 26 June 2008 10:44] Report message to a moderator
|
|
|
|
|
|
Re: How To Find/Replace on RichEditWithToolBar [message #16591 is a reply to message #16588] |
Mon, 30 June 2008 18:53 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
alex100 wrote on Mon, 30 June 2008 05:34 | Hi,
Suppose I have a database with some customers and I want to send a letter to all of them, for instance.
I was planning to write some document using the word processor (sample) that comes with Ultimate++. Suppose this document:
Customer name: <NNNNNN>
Customer id: <iiiiiii>
Customer adsress: <D1D1D1D1>
<D2D2D2D2>
<D2D2D2D2>
<D3D3D3D3>
Dear <NNNNNN>
Congratulation for blablablabla
blablablavla
...
Then when I choose "send letter to customers main menu"
I would like to open a dialog with a RichEdit widget that automatically opens the document above and also the database. Then for each customer it finds its details and replaces the tags
<
<NNNNNN>
<iiiiiii>
<D1D1D1D1>
<D2D2D2D2>
<D2D2D2D2>
<D3D3D3D3>
accordingly and prints a letter for each customer.
It that what I am trying to do.
Any ideas?
Many thanks
Alex
|
Sure, I am doing something very similar, if a bit advanced, all the time.
Anyway, I do not believe you need that dialog for this. Just tak RichText, scan it and replace what you need
OK, my method is a bit different, as I am (mis)using index entries to mark parts of document that are about to be replaced.
Anyway, for the inspiration, the heart of the code goes like this:
RichTxt Expand(const RichTxt& text, const RichStyles& styles,
const VectorMap<String, NamedText>& map)
{
RichText r;
NamedText deftext;
deftext.text = "****";
for(int i = 0; i < text.GetPartCount(); i++) {
if(text.IsPara(i)) {
RichPara para = text.Get(i, styles);
RichPara rpara;
rpara.format = para.format;
for(int j = 0; j < para.GetCount(); j++) {
const RichPara::Part& p = para[j];
if(IsNull(p.format.indexentry))
rpara.part.Add(p);
else {
StringBuffer t;
String d = map.Get(p.format.indexentry.ToString(), deftext).text;
t << "[%CS-CZI" << p.format.indexentry.ToString() << "; " << d << ']';
RichText txt = ParseQTF(t);
if((txt.GetPartCount() > 1 || txt.GetPartCount() > 0 && txt.IsTable(0))
&& rpara.GetCount() == 0) {
for(int i = 0; i < txt.GetPartCount(); i++)
if(txt.IsPara(i))
r.Cat(txt.Get(i));
else {
RichTable tab(txt.GetTable(i), 1);
r.CatPick(tab);
}
goto norpara;
}
else
if(txt.GetPartCount() && txt.IsPara(0)) {
RichPara par = txt.Get(0);
for(int j = 0; j < par.GetCount(); j++) {
rpara.part.Add(par[j]);
rpara.part.Top().format = p.format;
}
}
}
}
r.Cat(rpara);
norpara:;
}
else {
RichTable tab(text.GetTable(i), 1);
Size sz = tab.GetSize();
for(int q = 0; q < sz.cy; q++)
for(int j = 0; j < sz.cx; j++) {
RichTxt h = Expand(tab.Get(q, j), styles, map);
tab.SetPick(q, j, h);
}
r.CatPick(tab);
}
}
return r;
}
RichText Expand(const char *qtf, const VectorMap<String, NamedText>& map)
{
RichText text = ParseQTF(qtf);
RichStyles styles;
styles <<= text.GetStyles();
return RichText(Expand(text, styles, map), styles);
}
|
|
|
|
|
Re: How To Find/Replace on RichEditWithToolBar [message #16620 is a reply to message #16612] |
Wed, 02 July 2008 17:51 |
alex100
Messages: 118 Registered: November 2007
|
Experienced Member |
|
|
I forgot the existence of the reference\report. It could also help me.
Yes, my reports are more close to RichText (mailling letters) so I will try to use your tip to implement a method to replace tags with text (preserving the formating) using the richText widget.
Thank you again
Alex
|
|
|
Goto Forum:
Current Time: Sun May 05 20:52:12 CEST 2024
Total time taken to generate the page: 0.02149 seconds
|
|
|