Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Sendmessage 64 bit


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Jan 6, 2016 12:06 PM Last Post By: Remy Lebeau (Te...
Dennis McGuire

Posts: 1
Registered: 12/7/08
Sendmessage 64 bit  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 6, 2016 11:32 AM
This works in 32 bit:

SendMessage(Memo1.Handle, EM_LINEINDEX, -1, 0);

wParam

The zero-based line number. A value of –1 specifies the current line number (the line that contains the caret).

in 64 bit the wparam is defined as a nativeuint so the -1 doesn't compile

How do you get the line that contains the caret in 64 bir

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Sendmessage 64 bit  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 6, 2016 12:06 PM   in response to: Dennis McGuire in response to: Dennis McGuire
Dennis wrote:

This works in 32 bit:

SendMessage(Memo1.Handle, EM_LINEINDEX, -1, 0);

Oly because Delphi declares two overloaded versions of SendMessage(), one
that accepts an WPARAM, and the other that accepts an INT_PTR, as the wParam
parameter. -1 can be assigned as-is to an INT_PTR, but not to a WPARAM.
Since both overloads are available in 64bit, the code should be compiling
fine since -1 cannot be assigned as-is to a WPARAM. Sounds like an overload
resolution bug to me.

in 64 bit the wparam is defined as a nativeuint

WPARAM is a NativeUInt in 32bit, too.

How do you get the line that contains the caret in 64 bir

Use a type-cast to avoid any overload resolution issues:

SendMessage(Memo1.Handle, EM_LINEINDEX, INT_PTR(-1), 0);


Or:

SendMessage(Memo1.Handle, EM_LINEINDEX, WPARAM(-1), 0);


--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02