求助,这段函数怎么老是提示有问题
本帖最后由 u011354184 于 2013-08-14 11:27:29 编辑 请教各位大虾,下面第五行总是提示[Error] Unit1.pas(47): Incompatible types: 'Integer' and 'Pointer'
Var
EditText:array[0..254] of Char;
Begin
EditTextLength:=Sendmessage(Ahwnd,WM_GetTextLength,0,0);
Sendmessage(Ahwnd,WM_GETTEXT,EditTextLength+1,@EditText);
是哪里出错了?
[解决办法]
@EditText->LongInt(@EditText)
[解决办法]
function GetWndText(ThWnd: hWnd): string;
var
Ret:LongInt;
mText:PChar;
Buf:Integer;
begin
Ret := SendMessage(ThWnd, WM_GETTEXTLENGTH, 0, 0) + 1;//返回长度
GetMem(mText,Ret);
try
Buf := LongInt(mText);
SendMessage(ThWnd, WM_GETTEXT, Ret, Buf);
Result := StrPas(mText);
finally
FreeMem(mText,Ret);
end;
end;