如何在c++builder中更改TMenuItem的可见性
How to change visibility of TMenuItem in c++ builder?
我正在使用C++Builder开发一个应用程序。我想遍历MainMenu中的所有TMenuItems,因为我想更改其中一些的标题。我用了这个代码:
int numAction = MainMenu1->Items->Count;
for (int i=0;i<numAction;i++)
{
TMenuItem* tmpAction = &MainMenu1->Items[i];
tmpAction->Caption = "Test Caption";
}
我认为它应该起作用,但我总是遇到应用程序崩溃的情况。带有这种信息:
调试器异常通知项目Project1.exe在地址处引发了异常类EAccessViolation,消息为Access违规模块vcl120.bpl中的501C380E。读取地址0000003C
任何帮助都将不胜感激。
TMenu
具有类型的属性
_property TMenuItem* Items
其又具有阵列型的特性
__property TMenuItem* Items[int Index]
因此,解决方案是(正如n.m.已经注意到的那样)编写
TMenuItem* tmpAction = MainMenu1->Items->Items[i];
相关文章:
- 如何更改唯一指针向量的可见性
- 当指向对象的指针作为参数传递给 std::thread 时,内存可见性
- 限制静态库中符号的可见性 (MSVC/Visual C++)
- 班级成员可见性C++
- 内联模板函数的可见性
- Clang 是否可以在使用可见性属性时生成导入库(不带 __declspec(dllexport))?
- std::mutex 的发布-获取可见性保证是否仅适用于关键部分?
- 符号可见性和 gcc 警告
- C++/libscreen 无法更新可见性
- 在 C++11 线程中,std::mutex 对内存可见性有什么保证?
- C++继承构造函数的可见性
- CRTP - 嵌套叶类类型的可见性
- C++模板 - 实例之间的通用操作和成员可见性
- 放松的订单和线程间可见性
- GCC 6.x警告有关Lambda可见性
- C++ 中的Shared_ptr和内存可见性
- 静态库中的符号可见性和操作
- 未直接继承的基模板类成员的可见性
- 从shm_open() mmap()更改对共享内存的可见性
- 如何在c++builder中更改TMenuItem的可见性