c++ - 使用 TColorListBox 更改矩形的颜色

标签 c++ c++builder firemonkey shapes c++builder-xe6

我又来了。 我只是想了解如何使用 TColorListBox 更改矩形(形状)的颜色背景。 我知道这很容易,但是我总是在尝试为矩形设置新值时遇到异常。 我使用的命令如下:

Rectangle1->Fill->Color = ColorListBox1->Color;

功能:

void __fastcall TForm1::ColorListBox1Click(const TCustomListBox *Sender,
          const TListBoxItem *Item)
{
    Rectangle1->Fill->Color = ColorListBox1->Color;
}

现在我尝试更改颜色时一直遇到的错误:

Access violation at address 00405628 in module 'Project1.exe'. Read of address 00000360.

调试器的另一个异常在这里:

First chance exception at $00405615. Exception class $C0000005 with message 'access violation at 0x00405615: read of address 0x00000360'. Process Ninterpres.exe (904)

有人可以帮我吗?从现在开始,非常感谢!

最佳答案

你第一次写

ColorListBox1

第二次你使用的名字不带'1'

ColorListBox->Color;

但看起来您还没有初始化某些对象(我记得这应该由表单编辑器自动完成)因此程序抛出异常。

关于c++ - 使用 TColorListBox 更改矩形的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28817500/

相关文章:

c++ - 调试错误 R6010 - 已调用 abort()

c++ - 这个 reinterpret_cast 可以吗

ios - 在 StringGrid 中输入值时是否可以设置键盘类型?

delphi - TListbox - OnChangeEvent 在多选时触发不可靠

c++ - 如何将 boost local_date_time 转换为 time_t

c++ - 关于 XML 解析

c++ - 我无法使用 RegOpenKeyEx

c++ - 将 Visual C++ 代码转换为 Borland C++Builder

c++ - 读取文件所花费的时间

macos - 使用 Delphi Firemonkey 应用程序让 firebird 在 OSX 下工作