In C++Builder 6 (and the "classic" Borland compiler in modern versions), you can't use compound operators like +=
with properties. Doing so will read the property value into a temporary and then modify the temporary, but will not assign the temporary back to the property. Using compound operators on properties requires a modern Clang-based compiler:
Differences Between Clang-enhanced C++ Compilers and Previous Generation C++ Compilers, __property: Compound and Chained Assignment
Clang-enhanced C++ compilers support compound assignment of __property
, while BCC32 does not.
The objects of the keyword __property
are not like fields or members. They should be used in simple assignments.
Although both BCC32 and the RAD Studio Clang-enhanced C++ compilers allow __property
to be used in compound assignments such as:
Form1->Caption += DateToStr(Now());
BCC32 only invokes the getter, not the setter. Therefore we recommend that you avoid such constructs when targeting multiple platforms.
None of these compilers support the usage of __property
in chained assignment, as in:
Button2->Caption = Button1->Caption = DateToStr(Now()); // Error
So, in your situation, when you invoke image->Left += xPos;
for instance, it acts as-if you had written this instead:
//image->Left += xPos;
int temp = image->Left;
temp += xPos;
So, you need to use the +
and =
operators separately instead, eg:
void __fastcall TForm1::DVDLogoTimer(TObject *Sender)
{
image->Left = image->Left + xPos;
image->Top = image->Top + yPos;
...
}