The code below draws tables of various sizes with different LeftMargin's specified. All tables have 1 row. The first tables has 3 columns with LeftMargin=0. The next has 4 columns with LeftMargin=40. The next has 5 columns with LeftMargin=80. The next has 6 columns with LeftMargin=120. The last has 7 columns with LeftMargin=160. The program successfully draws the image.
But then RichViewEdit fails to work whenever the window is maximized or resized horizontally (resizing vertically does not cause the problem). At first glance, it appears to lose all the LeftMargins with such resizing, replacing all the specified left margins with the last LeftMargin value that was used whenever the window so resized. The two photos attached show just before resizing the window horizontally and after resizing the window.
However, on closer examination, what has actually happened is RichViewEdit has resized the first cell in each table, so the first cell is no longer the same size as the other cells in each table, except for the last table drawn. The leftmost cell of the tables all start at the last LeftMargin value that was used and end at the same point where the program originally drew the table cell. The other cells all remained the same size and position.
I realize that I can just redraw the whole RichViewEdit when the window is resized, but is any code changes or setting I can use to have it keep the left margins when resized horizontally?
Sample code to demonstrate the problem:
Code: Select all
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "RichView.hpp"
#include "RVStyle.hpp"
#include "RVTable.hpp"
#include "RVScroll.hpp"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "RichView"
#pragma link "RVEdit"
#pragma link "RVScroll"
#pragma link "RVStyle"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
#define MAX_TABLES 5
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TRVTableItemInfo *table;
TRVTableCellData * Cell;
TButton *btn;
for (int i = 0; i < MAX_TABLES; i++) {
table = new TRVTableItemInfo(1, 3 + i, rve->RVData);
Cell = table->Cells[0][0];
Cell->Clear();
Cell->AddNL("Hi from cell 1", 0, 0);
table->SetCellTag(UnicodeString(i), 0, 0);
Cell = table->Cells[0][2];
Cell->Clear();
Cell->AddNL("Hi from cell 3", 0, 0);
Cell = table->Cells[0][i+2];
Cell->Clear();
Cell->AddNL("Hi from last cell. I am writing this from the last cell", 0, 0);
rve->AddItem("Row_" + UnicodeString(i) , table);
rve->LeftMargin = 40 * i;
rve->FormatTail();
}
}