帮我看看这个代码有什么问题?关于改变当前窗口标题的程序。
YHW 2002-09-28 05:42:30 我想写一个程序,把当前窗口的标题最后加上几个字符。
可是写出来以后,只有我写的这个程序是当前窗口的时候运行有效果。
其他窗口是当前窗口的时候GetForegroundWindow老返回0。
不知道是什么原因。请各位高手帮我看一下。
procedure TForm1.Button1Click(Sender: TObject);
var
handle:integer;
title,right: string;
count,EditLong,TitleLong:integer;
begin
handle:=GetForegroundWindow;
TitleLong:=getwindowtextlength(handle);
setlength(title,TitleLong);
handle:=GetActiveWindow();
GetWindowText(handle,pchar(title),256);
EditLong:=length(edit1.Text);
right:=rightstr(title,EditLong);
if (TitleLong<EditLong) or (strcomp(pchar(right),pchar(edit1.text))<>0) then
begin
setwindowtext(handle,pchar(title+'-'+edit1.Text))
end;
end;