How should I pass negative values to SendMessage and Perform when they expect a NativeUInt?

前端 未结 1 1178
遥遥无期
遥遥无期 2021-01-18 11:25

Suppose you have code like this:

Result.X := ACustomMemo.Perform(EM_LINEFROMCHAR, -1, 0); 

The Windows API claims \"-1\" is a valid value t

1条回答
  •  醉话见心
    2021-01-18 11:55

    Casting the -1 value to WPARAM is the proper way to handle this case.

     Result.X := ACustomMemo.Perform(EM_LINEFROMCHAR, WPARAM(-1), LPARAM(0));
    

    btw, the delphi NativeUint definition for the WPARAM type is correct, because is a unsigned 32-bit on x86 and unsigned 64-bit on x64.

    0 讨论(0)
提交回复
热议问题