Break not displayed

General TRichView support forum. Please post your questions here
Post Reply
wray
Posts: 38
Joined: Thu Feb 14, 2008 8:36 pm
Location: Romania

Break not displayed

Post by wray »

Hi,

2 questions please:

First: when i create a new table like this:
table = new TRVTableItemInfo(4,4, RichView1->RVData);

How can i free the resource ?

if i put a 'delete table;' after i insert the table in RichView1 and format it, get a nasty error. So how can i free the resource ? Because if i spam the button to add tables, without to release the resources, when i exit the program i get a nasty error too.


Second question is:

when i add a break like this:
RichView1->AddBreakEx(4, rvbsLine, clBlue);

is all ok, displayed ok, i save RTF, when i load it again, no break line.
If i open it with Microsoft Word , the break is there, so the problem is on Load, not on Save.

Take into account is about RichView not RichViewEdit, but i tested with RichViewEdit too and it does the same, on load RTF does not display the break... i changed the background color thinking is loaded on white color instead of blue, but nope... it just does not loads it...

this is the code:

int r,c;
AnsiString Target = "www.website.com";

for(int i = 0; i< RVStyle1->TextStyles->Count; i++)
RVStyle1->TextStyles->Items->Charset = EASTEUROPE_CHARSET;

table = new TRVTableItemInfo(4,4, RichView1->RVData);
table->BorderWidth = 1;
table->CellBorderWidth = 1;
table->CellBorderStyle = rvtbColor;
table->CellBorderColor = clBtnFace;
table->BorderStyle = rvtbColor;

// Each cell initially contains one empty text item. Deleting it
for (r=0; r<table->Rows->Count; r++)
for (c=0; c<table->Rows->Items[r]->Count; c++)
table->Cells[r][c]->Clear();

table->SetTableVisibleBorders(0,0,0,0);
table->SetCellVisibleBorders(0,0,0,0,0,0);
table->SetCellVisibleBorders(0,0,0,0,1,0);
table->SetCellVisibleBorders(0,0,0,0,2,0);
table->SetCellVisibleBorders(0,0,0,0,3,0);

table->SetCellVisibleBorders(0,0,0,0,0,3);
table->SetCellVisibleBorders(0,0,0,0,1,3);
table->SetCellVisibleBorders(0,0,0,0,2,3);
table->SetCellVisibleBorders(0,0,0,0,3,3);

table->Cells[0][1]->AddNL("Phone Brand",1,1);
table->Cells[1][1]->AddNL("Phone Model",1,1);
table->Cells[2][1]->AddNL("Unlock Type",1,1);
table->Cells[3][1]->AddNL("Operation",1,1);
table->SetCellBestWidth(200,0,1);
table->SetCellBestWidth(200,0,2);

table->Cells[0][2]->AddNL("Alcatel", 5, 1);
table->Cells[1][2]->AddNL("OT735", 5, 1);
table->Cells[2][2]->AddNL("Unlock by IMEI", 5, 1);
table->Cells[3][2]->AddNL("-", 5, 1);

for (c=0; c<table->ColCount; c++)
{
table->Cells[c][1]->Color = 0x00E6E6E6;
table->Cells[c][2]->Color = 0x00E6E6E6;
}

table->InsertRows(table->Rows->Count,1,0,false);
for (c=0; c<table->Rows->Items[table->Rows->Count-1]->Count; c++)
table->Cells[table->Rows->Count-1][c]->Clear();
table->Cells[table->Rows->Count-1][1]->AddNL("IMEI",1,1);
table->Cells[table->Rows->Count-1][2]->AddNL("12345678901234",5,1);


table->InsertRows(table->Rows->Count,1,0,false);
table->Cells[table->Rows->Count-1][2]->Color = clWhite;
table->Cells[table->Rows->Count-1][1]->Color = clWhite;
table->SetCellVisibleBorders(0,0,0,0,table->Rows->Count-1,1);
table->SetCellVisibleBorders(0,0,0,0,table->Rows->Count-1,2);

table->InsertRows(table->Rows->Count,1,0,false);
for (c=0; c<table->Rows->Items[table->Rows->Count-1]->Count; c++)
table->Cells[table->Rows->Count-1][c]->Clear();
table->Cells[table->Rows->Count-1][1]->AddNL("NCK",1,1);
table->Cells[table->Rows->Count-1][2]->AddNL("111111",6,2);
table->Cells[table->Rows->Count-1][2]->Color = 0x00E6E6E6;

table->InsertRows(table->Rows->Count,1,0,false);
for (c=0; c<table->Rows->Items[table->Rows->Count-1]->Count; c++)
table->Cells[table->Rows->Count-1][c]->Clear();
table->Cells[table->Rows->Count-1][1]->AddNL("SPCK",1,1);
table->Cells[table->Rows->Count-1][2]->AddNL("222222",6,2);
table->Cells[table->Rows->Count-1][2]->Color = 0x00E6E6E6;

table->ParaNo = 1;

jp->Assign(Image3->Picture->Graphic);
RichView1->AddNL("",2,0);
RichView1->AddNL("Finished Job !",7,1);
RichView1->AddNL("",2,0);
RichView1->AddBreakEx(4, rvbsLine, clBlue);
RichView1->AddNL("",2,0);
RichView1->AddPictureEx("", jp, 1, rvvaBaseline);
RichView1->AddNL("",2,0);
RichView1->AddItem("Spreadsheet", table);
RichView1->AddNL("",2,0);
RichView1->AddBreakEx(4, rvbsLine, clBlue);

RichView1->AddNL("",2,0);
RichView1->AddNLTag(Target,3,1, (int)StrNew(Target.c_str()));

RichView1->Format();




Regards
Vlad
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

1) If you insert table in TRichView, you must not free it yourself, it will be freed by TRichView. If you got an exception, the reason is in some another place. For example, what is jp? Where do you create it? You need to pass an unique graphic object to AddPictureEx.
I am not sure how to create a new copy of Image3->Picture->Graphic in C++. Probably the simplest way is to include the following pas file in your project

Code: Select all

unit CreateGraphics;

interface
uses Graphics, RVFuncs;

  function GetGraphicCopy(gr: TGraphic): TGraphic;

implementation

function GetGraphicCopy(gr: TGraphic): TGraphic;
begin
  Result := RV_CreateGraphics(TGraphicClass(gr.ClassType));
end;

end.
and use

Code: Select all

jp =GetGraphicCopy(Image3->Picture->Graphic);
jp->Assign(Image3->Picture->Graphic); 
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

2) "Breaks" cannot be saved in RTF (MS Word uses special drawing object for similar things, but MS drawing objects are not supported by TRichView yet).
TRichView saves "breaks" as two paragraphs, the first of them has border at the bottom side. When you open this RTF file in TRichView, they should be loaded accordingly, as two paragraphs with border between them.
wray
Posts: 38
Joined: Thu Feb 14, 2008 8:36 pm
Location: Romania

Post by wray »

Yes, you were right, it was not from table object but the graphic object. To solve this i had just to create every time a new instance of the object, hoping that RichView will free them by itself like it does with the tables :)

TJPEGImage *jpS;
jpS = new TJPEGImage();
jpS->Assign(Image3->Picture->Graphic);
RichView1->AddPictureEx("", jpS, 1, rvvaBaseline);

About the brakes...

I just do like this:

RichView1->AddBreakEx(4, rvbsLine, clBlue);
RichView1->SaveRTF("c:\\fisier.rtf",false);
RichView1->LoadRTF("c:\\fisier.rtf");
RichView1->Format();

When is loaded, no break is shown...

Should i renounce to the 'AddBreakEx' and manually add edged paragraphs ?

Thank you for very fast responce, the support is great once again.

Regards
Vlad
Post Reply