Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

64-bit

delphi

Suppose you have code like this:

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

The Windows API claims "-1" is a valid value that makes it it return the active line.

However, Delphi has this defined as NaiveUInt and complains if I try to pass -1.

What is the cleanest solution to this? Casting?

like image 284
Tom Avatar asked Feb 19 '12 01:02

Tom


1 Answers

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.

like image 53
RRUZ Avatar answered Nov 15 '22 07:11

RRUZ