光标本身可是一个共享资源,不信,你用下面的例程可以很清楚的看到,其实你在点击button1<br>的时候,光标控制实际是在button1上。<br>procedure TForm1.Button1Click(Sender: TObject);<br>var point:tpoint;<br> hedit,hwindow:thandle;<br> cap:array [0..255] of char;<br>begin<br> getcursorpos(point);<br> hedit:=windowfrompoint(point);<br> if getwindowtext(hedit,@cap,254)<>0 then showmessage(cap)<br> else showmessage('notext');<br> showmessage(inttostr(hedit));<br> hwindow:=findwindow('OpusApp',nil);<br> showmessage(inttostr(hwindow));<br>end;<br>其实你用光标,不如用插入标记。例如下面的例程,注意一点,必须保证插入标记在WORD上<br>,所以在点击BUTTON1时,必须先将插入标记放到WORD上,否则十有八九返回的是DELPHI的编辑<br>器句柄。<br>procedure TForm1.Button1Click(Sender: TObject);<br>var point:tpoint;<br> hedit,hwindow:thandle;<br> cap:array [0..255] of char;<br>begin<br> getcaretpos(point);//**********<br> hedit:=windowfrompoint(point);<br> if getwindowtext(hedit,@cap,254)<>0 then showmessage(cap)<br> else showmessage('notext');<br> showmessage(inttostr(hedit));<br> hwindow:=findwindow('OpusApp',nil);<br> showmessage(inttostr(hwindow));<br>end;