InsertControl expands table cells

General TRichView support forum. Please post your questions here
Post Reply
mphilbrick
Posts: 27
Joined: Mon Aug 29, 2005 7:08 pm

InsertControl expands table cells

Post by mphilbrick »

Sergey,

In my application I have a table template. This table is copied to another TRichViewEdit control. I then use InsertControl to put in a TFrame object, although I have tried it with simple controls and the result is the same.

In code I locate a table cell based upon a search string and then insert the control using the TopLevelEditor.

Here is the code:

with rvForm do begin
ReadOnly := False;
frImages1 := TfrImagesTab.Create(nil);
dmRichViewMod.MoveToStart(rvForm);
LockWindowUpdate(rvForm.Handle);
try
if SearchText('<IMAGE>', [rvseoDown]) then begin
frImages1.InitializeImages;
// assign the appropriate height and width before inserting
frImages1.Height := TopLevelEditor.Height-4;
frImages1.Width := TopLevelEditor.Width-4;
InsertControl('image1', frImages1, rvvaBaseline);
FormatTail;
ReadOnly := True;
end;
dmRichViewMod.MoveToStart(rvForm);
finally
LockWindowUpdate(0);
end;
end;

Notice that I set the dimensions of the control to be less than the dimensions of the table cell. This works great for new tables, regardless of the number of rows and columns.

Where it fails is when I have merged cells. Assume that the table has 9 columns and 2 rows. The top row needs the 9 columns but the bottom row only needs three. I merge six cells into one on the bottom row. This is done using the RichViewActions editor.

I then, in code, insert the control into this merged cell. When the control is inserted it is the correct size, but there appear to be margins (on the right if left justified, on the left if right justified, and on both sides if centered) -- in other words, the control will not go all the way to the edge of the cell width, so the table cell is enlarged to fit the control.

For testing, I placed a paragraph of text in the cell. The text goes all the way to the edges, but the control will not.

As far as I know, this only happens if I have merged cells in a row and then attempt to insert a control in that row that is the nearly the width of the cell. If I decrease the width of the control to take into account this "margin", the cell width of course does not change.

Could you investigate this? My only work around is to create a table within a table so I don't have to merge cells.

Thank you.
Sergey Tkachenko
Site Admin
Posts: 17315
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I cannot reproduce the problem (I tried with picture instead of control, it should not matter which type of nontext item is used). Can you send me this document as RVF file?
mphilbrick
Posts: 27
Joined: Mon Aug 29, 2005 7:08 pm

Post by mphilbrick »

Sergey,

I will send two documents to your support email address.

Eyelid Good -- this is my work around, and the control takes up the entire cell where <IMAGE> is located.

Eyelid Bad -- this is the original where the control does not take up the entire cell and instead enlarges the table.
Post Reply