我又来了。 我只是想了解如何使用 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/