An application sends a WM_GETTEXT message to copy the text that corresponds to a window into a buffer provided by the caller. WM_GETTEXT wParam = (WPARAM) cchTextMax; // number of characters to copy lParam = (LPARAM) lpszText; // address of buffer for text ParameterscchTextMaxValue of wParam. Specifies the maximum number of characters to be copied, including the terminating null character. lpszTextValue of lParam. Points to the buffer that is to receive the text. 以上是SDK 原文,请仔细看啊。
非bug,参看函数原型: LRESULT SendMessage( HWND hWnd, // handle to destination window UINT Msg, // message WPARAM wParam, // first message parameter LPARAM lParam // second message parameter ); 其中, LPARAM: A 32-bit value passed as a parameter to a window procedure or callback function. WPARAM: A value passed as a parameter to a window procedure or callback function: 16 bits on Windows versions 3.0 and 3.1; 32 bits on Win32.在Delphi6里,这两个类型都用Integer来表达。
最简单的方法就是将指针强制转化为Integer,这样就可以了。
至于为什么,兴许经过几年的钻研,你就明白了。
wParam = (WPARAM) cchTextMax; // number of characters to copy
lParam = (LPARAM) lpszText; // address of buffer for text
ParameterscchTextMaxValue of wParam. Specifies the maximum number of characters to be copied, including the terminating null character. lpszTextValue of lParam. Points to the buffer that is to receive the text.
以上是SDK 原文,请仔细看啊。
LRESULT SendMessage(
HWND hWnd, // handle to destination window
UINT Msg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
其中,
LPARAM: A 32-bit value passed as a parameter to a window procedure or callback function.
WPARAM: A value passed as a parameter to a window procedure or callback function: 16 bits on Windows versions 3.0 and 3.1; 32 bits on Win32.在Delphi6里,这两个类型都用Integer来表达。
所以SDK的描述是正确的,并没有错误。
如果不相信,可以到Messages单元看看,TMessage和TWMGetText表达的数据结构完全相同,但是内部结构却不一样。慢慢体会吧。