Hi,
I insert a picture from clipboard into a table cell, in principle as follows:
Chart->CopyToClipboardMetafile(true) ;
TClipboard *pCB = Clipboard();
Graphics::TMetafile *pMetafile = new Graphics::TMetafile();
pMetafile->Assign(pCB);
Cell = table->Cells[1][1];
Cell->AddPictureEx("", pMetafile ,0, rvvaAbsMiddle);
But the picture does not fully fill the table cell; I have to manually enlarge it in order to fully fill the cell with the picture (similiar to Alignment=alClient in Delphi/CB).
How could I accomplish this programmically (without playing with pixels) ?
Thank you for a short note !
Best regards
Intis
picture alignment in table cell
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Cells are always wide enough to show their content (unless you include rvtoIgnoreContentWidth and/or rvtoIgnoreContentHeight in table.Options).
If you specify too small BestWidth, the column will be widened to show the whole picture in the cell.
The picture cannot be automatically resized to fill the cell. Only the cell can be resized to the size of the picture. If you want to resize a picture, do it manually (either by changing the picture itself or by assigning rvepImageWidth and rvepImageHeight properties for the picture item).
If you specify too small BestWidth, the column will be widened to show the whole picture in the cell.
The picture cannot be automatically resized to fill the cell. Only the cell can be resized to the size of the picture. If you want to resize a picture, do it manually (either by changing the picture itself or by assigning rvepImageWidth and rvepImageHeight properties for the picture item).
I tried it as follows:
Cell->Clear();
Cell->BestWidth = -79;
Cell->AddPictureEx("", pMetafile ,0, rvvaAbsMiddle);// rvvaBaseline);
//int w = Cell->GetWidth(); // returns -6
int w = Cell->GetAreaWidth(); // returns -6
Cell->SetItemExtraIntProperty(Cell->ItemCount-1, rvepImageWidth, w);
Cell->Format(true);
Nevertheless, the format of the picture within the cell seems unchanged.
Where is my mistake ?
Thank you for a hint !
Best regards
Intis
Cell->Clear();
Cell->BestWidth = -79;
Cell->AddPictureEx("", pMetafile ,0, rvvaAbsMiddle);// rvvaBaseline);
//int w = Cell->GetWidth(); // returns -6
int w = Cell->GetAreaWidth(); // returns -6
Cell->SetItemExtraIntProperty(Cell->ItemCount-1, rvepImageWidth, w);
Cell->Format(true);
Nevertheless, the format of the picture within the cell seems unchanged.
Where is my mistake ?
Thank you for a hint !
Best regards
Intis
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
GetAreaWidth is an internal function, and it returns a valid value only if the document is formatted. Document can be formatted only when it is ready (all items are added), so you cannot use this function for assigning item width.
So I suggest to estimate a desired picture width basing on RichViewEdit->ClientWidth.
So I suggest to estimate a desired picture width basing on RichViewEdit->ClientWidth.
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: