可否把这段Delphi转换成C++Builder?
var gr: TGraphic;
pic: TPicture;
...
if OpenPictureDialog1.Execute then begin
pic := TPicture.Create;
try
pic.LoadFromFile(OpenPictureDialog1.FileName);
gr := RV_CreateGraphics(TGraphicClass(pic.Graphic.ClassType));
gr.Assign(pic.Graphic);
MyRichViewEdit.InsertPicture('', gr, rvvaBaseline);
finally
pic.Free;
end;
end;
[解决办法]
大概是这个样子,由于我没有安装RichView这个三方组件,所以没有测试。
if (OpenPictureDialog1->Execute()){ TPicture *pic = new TPicture; try { pic->LoadFromFile(OpenPictureDialog1->FileName); TGraphic *gr = RV_CreateGraphics((TGraphicClass)pic->Graphic->ClassType()); gr->Assign(pic->Graphic); MyRichViewEdit->InsertPicture("", gr, rvvaBaseline); } __finally { delete pic; }}