让悬浮工具栏不抢去父窗体焦点 ( 积分: 100 )

  • 主题发起人 主题发起人 flyat
  • 开始时间 开始时间
F

flyat

Unregistered / Unconfirmed
GUEST, unregistred user!
是悬浮窗体不用焦点?<br>还是悬浮窗体和父窗体同时有焦点?(Windows同意吗?)<br>不知这种东西是怎样做的,是否有相关的API
 
是悬浮窗体不用焦点?<br>还是悬浮窗体和父窗体同时有焦点?(Windows同意吗?)<br>不知这种东西是怎样做的,是否有相关的API
 
看看这个是不是你要的???<br>两个窗口同时显示为 Active 状态 <br>在form的private中:<br> &nbsp; procedure WMActive(var Msg:TWMActivate);Message WM_ACTIVATE;<br>procedure TFrm_XMTree.WMActive(var Msg: TWMActivate);<br>begin<br> &nbsp; if Msg.Active&amp;lt;&amp;gt;0 then<br> &nbsp; begin &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//此窗体获得焦点<br> &nbsp; &nbsp; &nbsp; SendMessage(TWinControl(Owner).Handle,WM_NCACTIVATE,-1,0);<br> &nbsp; &nbsp; &nbsp; Windows.SetWindowPos(TWinControl(Owner).Handle,HWND_TOP,0,0,0,0,SWP_NOSIZE or SWP_NOMOVE or SWP_NOACTIVATE);<br> &nbsp; end<br> &nbsp; else begin &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //此窗体失去焦点<br> &nbsp; &nbsp; &nbsp; SendMessage(Handle,WM_NCACTIVATE,-1,0);<br> &nbsp; &nbsp; &nbsp; SendMessage(TWinControl(Owner).Handle,WM_NCACTIVATE,0,0);<br> &nbsp; end;<br> &nbsp; inherited;<br>end;<br>把TWinControl(Owner).Handle换成你要的(不过这样最好在Form的OnClick事件中加上show,否则只有点标题栏才能切换)。 &nbsp;
 
谢谢,<br>可惜不是我要的,把两个窗体&quot;激活&quot;没有意义吧,因为父焦点还是被抢去.<br>
 
悬浮窗应该总在非激活状态,下面代码完成了一半,可惜Resize时还是激活了窗体.<br>来自:rainxy2002,<br>WMMouseActivate(var Msg: TWMMouseActivate); <br>begin <br> &nbsp;Msg.Result := MA_NOACTIVATE; <br>end;<br>
 
后退
顶部