很头痛的问题,关于vgScene的

leonliu911 2011-03-02 09:21:48
在使用vgScene这个DUI的时候,发现用CB做的简单例子通不过编译,原因如下:

Delphi:
function MessagePopup(const ACaption, AMessage: WideString; AType: TvgMessageType;
Buttons: TvgMessageButtons; const AOwner: IvgScene; const Target: TvgVisualObject = nil;
const ADisableScene: boolean = true;
const ABitmap: TvgBitmap = nil;
const AStyle: TvgResources = nil): integer;

示例调用:
var
vgScene: TvgScene
ToolBar: TvgToolBar
begin
messagepopup('caption','memo',vgMessageError, [vgButtonOK], vgScene, ToolBar);
end;


结果正常弹出msgbox
---------------------------------------------------------------------------------------------------------

C++:

__interface IvgScene;
typedef System::DelphiInterface<IvgScene> _di_IvgScene;

extern PACKAGE int __fastcall MessagePopup(const System::WideString ACaption, const System::WideString AMessage, TvgMessageType AType, TvgMessageButtons Buttons, const _di_IvgScene AOwner, const TvgVisualObject* Target = (TvgVisualObject*)(0x0), const bool ADisableScene = true, const TvgBitmap* ABitmap = (TvgBitmap*)(0x0), const TvgResources* AStyle = (TvgResources*)(0x0));


示例调用:
TvgScene vgScene;
TvgToolBar ToolBar;
void __fastcall TfrmMain::btnExitClick(TObject *Sender)
{
MessagePopup("caption", "memo",
vgMessageWarning,
TvgMessageButtons() << vgButtonOK,
(IvgScene*)vgControl,
ToolBar
);
}


结果编译通过,运行报AV。。。
dbg后发现是 (IvgScene*)vgControl 定义不对,那怎么定义才是正确的呢? 感觉CB对Delphi转换上有些特殊的地方。
...全文
233 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
leonliu911 2011-03-02
  • 打赏
  • 举报
回复
自己解决了,办法如下:

_di_IvgScene __fastcall getIvgScene(TvgScene *p)
{
_di_IvgScene DocIntf;
p->GetInterface(DocIntf);
return DocIntf;
}
MessagePopup("caption", "memo",
vgMessageWarning,
TvgMessageButtons() << vgButtonOK,
getIvgScene(vgControl),
ToolBar
);

为什么要这样呢,直接像Delphi那样不行?
leonliu911 2011-03-02
  • 打赏
  • 举报
回复
TvgScene vgScene; TvgToolBar ToolBar; void __fastcall TfrmMain::btnExitClick(TObject *Sender) { MessagePopup("caption", "memo", vgMessageWarning, TvgMessageButtons() << vgButtonOK, (IvgScene*)[color=#FF0000]vgControl, ToolBar ); }[/color]
补充下,vgControl应为vgScene 用的是CB2010, CB6干脆就编译不过,直接提示LinkError,还不给出原因。CB2010起码还告诉你那里出错。
draculamx 2011-03-02
  • 打赏
  • 举报
回复
我也用过这个东西,资料实在是少。。。自带的帮助文件,只有寥寥几行。。。
期待高手,给写资料先。。。

604

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder VCL组件使用和开发
社区管理员
  • VCL组件使用和开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧