9

In Delphi 6 WPARAM is declared as being signed:

WPARAM = Longint;

In Delphi 2010 WPARAM is declared as being signed:

WPARAM = INT_PTR;

But in XE2 it is declared as being unsigned:

WPARAM = UINT_PTR;

The official Windows definition is:

typedef UINT_PTR WPARAM;

This matches with XE2.


Does anyone know whether the change was made for XE or for XE2?

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490

1 Answers1

8

In Delphi XE WPARAM = INT_PTR; so the change was introduced in XE2.

RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • 1
    Thank you. That means there's more risk with my current migration to XE2 than I had anticipated. – David Heffernan Oct 20 '11 at 14:18
  • @David Heffernan - would you care to explain that? AFAIK, it should not be a problem unless you have been using negative WPARAM's somewhere. – Lieven Keersmaekers Oct 20 '11 at 14:31
  • 4
    @Lieven I've come across code with tests like `WParam>=0`. There's a whole class of potential bugs here that will be quite hard to find. – David Heffernan Oct 20 '11 at 14:33
  • 3
    In Delphi XE2 many data type aliases (in WinAPI units) where changed to the original data types that are used in Microsofts WinAPI header files. WPARAM should have never been declared as Longint (in Delphi 2). Now they fixed all data types to get them working in 64 bit Delphi. – Andreas Hausladen Oct 20 '11 at 14:35
  • @Andreas Thanks. Do you know which other types have had their definitions changed/corrected? P.S. Still loving your fabulous Delphi enhancements! – David Heffernan Oct 20 '11 at 14:41
  • @David Will the compiler not "catch" those potential bugs with the _widened both operands_ warning? – NGLN Oct 20 '11 at 15:38
  • 2
    @NGLN No it won't because no widening is needed. `WParam>=0` gets caught by the "always evaluates to True" warning, but `WParam>0` will not be caught and has completely different meaning. – David Heffernan Oct 20 '11 at 15:40
  • Interestingly MSDN declares WPARAM values of -1 for some methods as having a special meaning. Actually MS doesn't really care of handling negative values in a word. Just have a look at the WMPARAM description of WM_MOUSEWHEEL. "The high-order word indicates the distance the wheel is rotated, expressed in multiples or divisions of WHEEL_DELTA, which is 120. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user." – Uwe Raabe Oct 20 '11 at 18:43
  • 1
    A history follow up in ´The Old New Thing´ (http://blogs.msdn.com/b/oldnewthing/archive/2011/06/29/10181137.aspx). – LU RD Oct 20 '11 at 21:04