trichview.com

trichview.support




Re: table and picture


Return to index


Author

Message

Sergey Tkachenko

Posted: 03/03/2003 19:33:07


Each RichView item image must be unique.

In this code, you add the same image twice, so it is destroyed twice,

causing AV.


Create the following pascal unit and add in in your project

(I do not know how to write it in native C++):



DupImg.pas

<<<<<<<<<<<<


unit DupImg;


interface


uses Graphics, RVFuncs;


function DuplicateImage(gr: TGraphic): TGraphic;


implementation


function DuplicateImage(gr: TGraphic): TGraphic;

begin

  Result := RV_CreateGraphics(TGraphicClass(gr.ClassType));

  Result.Assign(gr);

end;


end.


>>>>>>>>>>>>


Now modify your code


#include "DupImg.hpp"



gr =RichViewEdit1->GetSelectedImage();

   if(gr)

  {

     gr = DuplicateImage(gr);

     TRVTableItemInfo* table = new TRVTableItemInfo(1,2,

                          RichViewEdit1->RVData);


    table->Cells[0][1]->BestWidth =gr->Width;

    table->Cells[0][1]->BestHeight =gr->Height;

    table->Cells[0][1]->Clear();

    table->Cells[0][1]->AddPictureEx("",gr,0,rvvaBaseline);

    if (RichViewEdit1->InsertItem("", table))

    {

    }

}




>

> Hi everyone, I have a question about  table and picture. I select a

picture

> in RichViewEdit and put it into a table's cell. But after I did so, I find

> that RichViewEdit can't be cleared, why?

>  The code is here:

>    gr =RichViewEdit1->GetSelectedImage();

>    if(gr)

>   {

>      TRVTableItemInfo* table = new TRVTableItemInfo(1,2,

>                           RichViewEdit1->RVData);

>

>     table->Cells[0][1]->BestWidth =gr->Width;

>     table->Cells[0][1]->BestHeight =gr->Height;

>     table->Cells[0][1]->AddPictureEx("",gr,0,rvvaBaseline);

>     if (RichViewEdit1->InsertItem("", table))

>     {

>     }

>  }

>

> Thanks.





Powered by ABC Amber Outlook Express Converter