Reputation:
I have following line in Delphi XE4 which is giving me error: E1012 Constant expression violates subrange bounds
Message.WParam := clBtnFace;
When I debugged the code, I got value of clBtnFace = -16777201
;
Same is working for Delphi 7 code.
I found following link on stackoverflow, but could not get it to resolve my problem: Using the `in` keyword causes "E1012 Constant expression violates subrange bounds" in Delphi
Upvotes: 0
Views: 2459
Reputation: 612993
In modern Delphi versions, the declarations of the Windows data types have been brought in line with the definitions in the Windows header files. And WPARAM
is, and has always been, an unsigned type. But in older versions of Delphi it was erroneously declared as being signed.
So, to make the code compiler in modern Delphi you need to cast the value to the same type as Message.WParam
. And that type is WPARAM
:
Message.WParam := WPARAM(clBtnFace);
Upvotes: 4