S
satanmonkey
Unregistered / Unconfirmed
GUEST, unregistred user!
我想写一个程序,把当前窗口的标题最后加上几个字符。<br>可是写出来以后,只有我写的这个程序是当前窗口的时候运行有效果。<br>其他窗口是当前窗口的时候GetForegroundWindow老返回0。<br>不知道是什么原因。请各位高手帮我看一下。<br><br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>handle:integer;<br>title,right: string;<br>count,EditLong,TitleLong:integer;<br>begin<br> handle:=GetForegroundWindow; //得到当前窗口句柄<br> TitleLong:=getwindowtextlength(handle);//得到当前窗口标题长度<br> setlength(title,TitleLong);<br> handle:=GetActiveWindow();<br> GetWindowText(handle,pchar(title),256);//得到当前窗口标题<br> EditLong:=length(edit1.Text);<br> right:=rightstr(title,EditLong);<br> if (TitleLong<EditLong) or (strcomp(pchar(right),pchar(edit1.text))<>0) then<br> begin<br> setwindowtext(handle,pchar(title+'-'+edit1.Text)));//设置当前窗口标题<br> end;<br>end;