本文介绍了将Pascal转换为C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码在firemonkey ListView的ItemClickEx事件中运行.我想知道如何在C ++中做到这一点.
The following code runs in the ItemClickEx event of a firemonkey ListView. I want to know how to do this in C++.
procedure TfrmCategory.lstListCategoryItemClickEx(const Sender: TObject;
ItemIndex: Integer; const LocalClickPos: TPointF;
const ItemObject: TListItemObject);
begin
if ItemObject is TListItemAccessory then
begin
ShowMessage('Acessory clicked');
end;
end;
来源:链接此处.
我不知道如何在c ++中执行如果ItemObject是TListItemAccessory".
I don't know how to do the "if ItemObject is TListItemAccessory" in c++.
推荐答案
与Delphi的is
运算符等效的C ++是dynamic_cast
,例如:
The C++ equivalent to Delphi's is
operator is dynamic_cast
, eg:
void __fastcall TfrmCategory::lstListCategoryItemClickEx(const TObject *Sender,
int ItemIndex, const TPointF &LocalClickPos, const TListItemObject* ItemObject)
{
if (dynamic_cast<const TListItemAccessory*>(ItemObject))
ShowMessage(L"Acessory clicked");
}
这篇关于将Pascal转换为C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!