我应该如何传递负值SendMessage函数,当他们期待NativeUInt执行? [英] How should I pass negative values to SendMessage and Perform when they expect a NativeUInt?
本文介绍了我应该如何传递负值SendMessage函数,当他们期待NativeUInt执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设你有code是这样的:
Suppose you have code like this:
Result.X := ACustomMemo.Perform(EM_LINEFROMCHAR, -1, 0);
Windows API的索赔-1是一个有效的值,使得其返回的有效行。
The Windows API claims "-1" is a valid value that makes it it return the active line.
不过,德尔福这个定义为NaiveUInt和抱怨,如果我尝试传递-1。
However, Delphi has this defined as NaiveUInt and complains if I try to pass -1.
什么是最干净的解决办法?铸造?
What is the cleanest solution to this? Casting?
推荐答案
铸造-1值WPARAM是正确的方式来处理这种情况。
Casting the -1 value to WPARAM is the proper way to handle this case.
Result.X := ACustomMemo.Perform(EM_LINEFROMCHAR, WPARAM(-1), LPARAM(0));
顺便说一句,delphi的NativeUint定义为WPARAM类型是正确的,因为是在x86和64位无符号的64位无符号32位。
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.
这篇关于我应该如何传递负值SendMessage函数,当他们期待NativeUInt执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文