mauroaraujo
mauroaraujo

Reputation: 342

Change color from a Rectangle using a TColorListBox

I'm here again. I just would like to discover how to change the color background of a rectangle (Shape) using a TColorListBox. I know it is easy, however I'm getting exception all the time I try to set a new value for the Rectangle. The command I'm using is the following:

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

Function:

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

Now the error I'm getting all the time I try to change the collor:

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

Another exception on debugger is here:

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

Could someone help me please?Since now, thanks A LOT!

Upvotes: 0

Views: 537

Answers (2)

mauroaraujo
mauroaraujo

Reputation: 342

I've found the problem... The access violation code is because of multiple pointers with the same name. On this case I was using Rectangle1 (Actually is was called Transp, I changed the name to put here to make the comprehension easier) as a int var and as an object... Thanks for the answers XD.

Upvotes: 0

MTP
MTP

Reputation: 171

First time You wrote

ColorListBox1

and second time You used name without '1'

ColorListBox->Color;

But it looks like You have not initialised some object (as i remember this shall be done automagically by Form Editor) thus program throws an exception.

Upvotes: 1

Related Questions