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) without having to set sizes and such?
You should read the size with
WM_GETTEXTLENGTHand use the value for the buffer.