开发者

Using WM_GETTEXT - what to set the Size?

开发者 https://www.devze.com 2023-02-28 22:38 出处:网络
Var PText : array[0..512] of Char; Handle, Child : HWND; begin FillChar(PText,512,0); Handle := FindWindow(\'Notepad\',nil);
Var
 PText : array[0..512] of Char;
 Handle, Child : HWND;
begin
 FillChar(PText,512,0);
 Handle := FindWindow('Notepad',nil);
 Child := FindWindowEx(Handle,0,'Edit',nil);

 Caption := IntToStr(Handle)+' - '+IntToStr(Child);

 SendMessage(Child,WM_GETTEXT,512,Integer(@PText[0]));

 ShowMessage(PText);

end;

I am just wondering - What should I normally set the size (Currently 512) to when using WM_GETTEXT? I guess it differs to how much text there is in the source control?

What do you recommend to set it to, when dealing with rather large ammounts of text?

Is there a way to do the same (Getting the text from a handle) wi开发者_如何学Pythonthout having to set sizes and such?


You should read the size with WM_GETTEXTLENGTH and use the value for the buffer.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号