一个很简单的问题(100分)

  • 主题发起人 主题发起人 abcxca
  • 开始时间 开始时间
A

abcxca

Unregistered / Unconfirmed
GUEST, unregistred user!
&nbsp; &nbsp;如何用mouse点一点我的程序中的一个按钮,就让另一个窗口(拥有该窗口的句柄),<br>获得焦点并能接收键盘输入.<br>&nbsp; &nbsp;
 
postmessage(窗口句柄,WM_SETFOCUS,0,0)
 
if wnd&lt;&gt;0 then<br>begin<br>&nbsp; &nbsp; &nbsp;if isiconic(wnd) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ShowWindow(wnd,sw_restore)<br>&nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetForegroundWindow(wnd);<br>end;
 
&nbsp; 都不行
 
&nbsp; 更正: jiajiajia888的方法可行.<br>&nbsp; &nbsp;但如果窗口被最小化了呢?
 
if wnd&lt;&gt;0 then<br>begin<br>&nbsp; &nbsp; &nbsp;if isiconic(wnd) then<br>&nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ShowWindow(wnd,sw_restore)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetForegroundWindow(wnd);<br>&nbsp; end;<br>end;<br>这样,最小化问题就解决了
 
其实,完全没必要加isiconic() <br>就它即可:<br>if wnd&lt;&gt;0 then<br>begin<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ShowWindow(wnd,sw_restore)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SetForegroundWindow(wnd);<br>end;<br><br>
 

Similar threads

后退
顶部