Page 1 of 1
GetItemStyle
Posted: Mon Jul 24, 2017 11:04 am
by th9999
Hello, administrator
Ask a question. I have a document containing text, pictures, components, forms, etc. How can I decide which item is a form or text.
My code is as follows:
For I: = 0 to TmpSRichViewEdit. RichViewEdit. Do ItemCount - 1
The begin
If TmpSRichViewEdit. RichViewEdit. RVData. GetItemStyle (I) = rvsTable then begin
TableTmp: = TRVTableItemInfo (TmpSRichViewEdit. RichViewEdit. RVData. The GetItem (I));
... This is the form
End else begin / / normal content
...... This judgment is text
The end;
The end;
Thank you very much!
Re: GetItemStyle
Posted: Mon Jul 24, 2017 1:36 pm
by Sergey Tkachenko
If GetItemStyle returns zero or positive value, this is a text item. The returned value is the index in the collection TmpSRichViewEdit.RichViewEdit.Style.TextStyles.
If GetItemStyle returns a negative value, this is a non-text item. The list of items is here:
http://www.trichview.com/help/idh_const_rvsxxx.html
Re: GetItemStyle
Posted: Mon Jul 24, 2017 11:34 pm
by th9999
Thank you very much
Re: GetItemStyle
Posted: Mon Jul 24, 2017 11:45 pm
by th9999
Hi Sergey Tkachenko
I have a document at the time of editing, the text has multiple colors to distinguish, but at the time of printing requirements to print all black font, in my judgment in the way you modify the document font color, but some will be garbled words? The HTML code is as follows: for I: = 0 to TmpSRichViewEdit. RichViewEdit. Do ItemCount - 1
The begin
If TmpSRichViewEdit. RichViewEdit. RVData. GetItemStyle (I) = rvsTable rvsTable then / / form
The begin
TableTmp: = TRVTableItemInfo (TmpSRichViewEdit. RichViewEdit. RVData. The GetItem (I));
For tmpRow: = 0 to TableTmp. RowCount - 1 do / / line count
The begin
For tmpCol: = 0 to TableTmp. ColCount - 1 do / / column number
The begin
If TableTmp. Cells [tmpRow tmpCol] < > nil then
The begin
RVData: = TableTmp Cells [tmpRow, tmpCol]. GetRVData;
For tmpTtemNO: = 0 to RVData. ItemCount - 1 do
The begin
If rvdata.getitemstyle (tmpTtemNO) > = 0 then / / greater than or equal to 0 represents text
RVData. The GetItem (tmpTtemNO). StyleNo: = 0; / / cancel the font color
The end;
The end;
The end;
The end;
End else begin / / normal content
If TmpSRichViewEdit. RichViewEdit. GetItemStyle (I) > = 0 then / / is greater than or equal to 0 (text
TmpSRichViewEdit. RichViewEdit. The GetItem (I). The StyleNo: = 0; / / cancel the font color
The end;
The end;
Is there a problem with the way I changed the color of the font? thank you
Re: GetItemStyle
Posted: Tue Jul 25, 2017 8:23 pm
by Sergey Tkachenko
TRVPrint component has ColorMode property, allowing to print black-on-white text without document modification.
However, this feature is not supported by ScaleRichView, so you are right, you need to change text color in document.
If you need changing only text color, you do not need to analyze the whole document. You just need to change RVStyle:
Code: Select all
procedure MakeBW(RVStyle: TRVStyle);
var
i, j: Integer;
begin
for i := 0 to RVStyle.TextStyles.Count - 1 do
begin
RVStyle.TextStyles[i].Color := clBlack;
RVStyle.TextStyles[i].BackColor := clNone;
end;
for i := 0 to RVStyle.ListStyles.Count - 1 do
for j := 0 to RVStyle.ListStyles[i].Levels.Count - 1 do
RVStyle.ListStyles[i].Levels[j].Font.Color := clBlack;
end;
procedure SRVMakeBW(Srv: TSRichViewEdit);
var
i: TSRVHeaderFooterType;
begin
MakeBW(Srv.RichViewEdit.Style);
for i := Low(TSRVHeaderFooterType) to High(TSRVHeaderFooterType) do
MakeBW(Srv.SubDocuments[i].GetRVStyle);
end;
This code makes all text items and list markers black.
SRVMakeBW
Posted: Wed Jul 26, 2017 4:45 am
by th9999
Hello, administrator
Sorry to have to bother you, I listen to your code changes, print text can black font, but I don't have any (TSRVHeaderFooterType) unit, I modify your code, do not know to have what effect, modify the code is as follows:
Procedure SRVMakeBW (Srv: TSRichViewEdit);
/ / var I: TSRVHeaderFooterType;
The begin
MakeBW (Srv) RichViewEdit) Style);
MakeBW (Srv) RVHeader) Style);
MakeBW (Srv) RVFooter) Style);
/ / for I: = Low (TSRVHeaderFooterType) to High (TSRVHeaderFooterType) do
/ / MakeBW (Srv SubDocuments GetRVStyle);
The end;
Currently, the TSRVComboBox control in the printed file is still in color, can it not be modified?
SRVMakeBW
Posted: Wed Jul 26, 2017 4:50 am
by th9999
Code: Select all
procedure SRVMakeBW(Srv: TSRichViewEdit);
//var i: TSRVHeaderFooterType;
begin
MakeBW(Srv.RichViewEdit.Style);
MakeBW(Srv.RVHeader.Style);
MakeBW(Srv.RVFooter.Style);
//for i := Low(TSRVHeaderFooterType) to High(TSRVHeaderFooterType) do
// MakeBW(Srv.SubDocuments[i].GetRVStyle);
end;
Re: GetItemStyle
Posted: Wed Jul 26, 2017 8:59 am
by Sergey Tkachenko
Your change is correct, if you use an old version of ScaleRichView which does not support special headers and footers for the first page and odd/even pages.
For changing text color in controls, you really need to enumerate all items in the document and assign Font.Color. I'll make an example later.
Re: GetItemStyle
Posted: Thu Jul 27, 2017 1:19 am
by th9999
Sergey Tkachenko
Thank you very much, waiting for your presentation... I'll show you a screenshot of the color of the control.