首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

可否把这段Delphi转换成C++Builder?该如何解决

2012-03-03 
可否把这段Delphi转换成C++Builder?var gr: TGraphicpic: TPicture...if OpenPictureDialog1.Execute th

可否把这段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这个三方组件,所以没有测试。

C/C++ code
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;    }} 

热点排行