读书人

sendmessage用不了,该怎么处理

发布时间: 2013-01-28 11:49:56 作者: rapoo

sendmessage用不了
本帖最后由 baiylhnh 于 2013-01-18 18:53:29 编辑 我想现实的功能是把MEMO中的文本.一行一行的弄到记事本里
但是每次执行都盖掉了原来的文本.怎么让他们实现自动换行并不盖掉原来的内容

var windows,windowsex:hwnd;
procedure writetxt();
var i:dword;
temp:string;
begin
windows:=FindWindow('Notepad',nil);
if windows<>0 then
begin
windowsex:=FindWindowEx(windows,0,'edit',nil);
while True do
begin
if i>form1.Memo1.Lines.Count-1 then
i:=0
else
begin
SendMessage(windowsex,WM_SETTEXT,Length(form1.Memo1.Text),
Integer(PChar(form1.Memo1.lines[i]))); //问题肯定出在这里
inc(i);
sleep(2500);
end;
end;
end
else
showmessage('22222222222');
end;


还有一个问题.我向指定的窗口发送回车
sendmessage(windows,WM_CHAR,13,0) //为什么一点反应也没有.句柄没有错
[解决办法]
引用:
非常感谢你的回答.但是没有用.还是把原来的内容给盖掉了

请确认加入了SendMessage(windowsex,WM_GETTEXT,sizeof(str),integer(@str));
如果还是覆盖,请查看这行运行后str的值是否为notepad当前的内容

读书人网 >.NET

热点推荐