请帮助看看我的浮动窗口,它为什么不能象netants中的拖动窗口那样移动 (100分)

  • 主题发起人 主题发起人 go2
  • 开始时间 开始时间
G

go2

Unregistered / Unconfirmed
GUEST, unregistred user!
以下是我的代码<br>///////////form1 &nbsp; &nbsp;start<br>unit Uflatwin1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; StdCtrls;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; Button2: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; &nbsp; procedure Button2Click(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>uses Uflatwin, Uflatwin2;<br><br>{$R *.DFM}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; &nbsp; form2.show;<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>&nbsp; &nbsp; form3.showmodal;<br>end;<br><br>end.<br><br>/////////form1 &nbsp; &nbsp;end<br><br>/////////////////form2 &nbsp;start///////////<br>unit Uflatwin;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; StdCtrls;<br><br>type<br>&nbsp; TForm2 = class(TForm)<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; &nbsp; procedure WMNCHITTEST(var Message:TMessage);Message WM_NCHITTEST;<br><br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; protected<br>&nbsp; &nbsp; &nbsp; procedure CreateParams(var Params: TCreateParams);override;<br>&nbsp; end;<br><br>var<br>&nbsp; Form2: TForm2;<br><br>implementation<br><br>{$R *.DFM}<br>Procedure TForm2.CreateParams(var Params:TCreateParams);<br>begin<br>&nbsp; &nbsp; inherited &nbsp;CreateParams(Params);<br>&nbsp; &nbsp; if BorderStyle = bsNone &nbsp;then<br>&nbsp; &nbsp; with Params do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; Style:= Style or WS_POPUP;<br>&nbsp; &nbsp; &nbsp; &nbsp; EXStyle:=ExStyle or WS_EX_TOPMOST or WS_EX_ACCEPTFILES or WS_DLGFRAME;<br>&nbsp; &nbsp; &nbsp; &nbsp; WndParent:=GetDesktopWindow();<br>&nbsp; &nbsp; end;<br>end;<br><br>procedure TForm2.Button1Click(Sender: TObject);<br>begin<br>close;<br>end;<br><br>procedure TForm2.WMNCHITTEST(var Message:TMessage);<br>begin<br>&nbsp; &nbsp; inherited;<br>&nbsp; &nbsp; if Message.Result = htClient then<br>&nbsp; &nbsp; &nbsp; &nbsp; Message.Result := htCaption;<br>end;<br><br>end.<br>/////////////////form2 &nbsp;end////<br><br><br>//////form3 &nbsp;start////<br>unit Uflatwin2;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;<br><br>type<br>&nbsp; TForm3 = class(TForm)<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form3: TForm3;<br><br>implementation<br><br>{$R *.DFM}<br><br>end.<br>/////form3 end////<br>其中form2是一浮动窗口,可是在我打开form3的窗口时,form2就无法移动,<br>请问我要如何让form2移动,form3必须是showmodal方式打开,就象netants、flashget一样 &nbsp;<br><br>&nbsp;
 
有谁能回答
 
正常的,要不怎么叫showmodal呢?<br>form3非得用showmodal打开吗?
 
我这两天做了这么个东西,几个关键代码给你参考:<br>rocedure TNotesDropForm.createparams(var Params: TcreateParams);<br>begin<br>&nbsp; inherited;<br>&nbsp; with params do<br>&nbsp; begin<br>&nbsp; &nbsp;Exstyle:=WS_EX_TOOLWINDOW; <br>&nbsp; &nbsp;wndParent :=0;<br>&nbsp; end;<br>end;<br><br><br>procedure TNotesDropForm.wmnchittest(var msg: twmnchittest);<br>begin<br>inherited;<br><br>if (hiword(getasynckeystate(vk_lbutton)) &gt; 0) and (msg.result=htClient)<br>then msg.result:=htcaption;<br><br>end;<br><br><br>procedure TNotesDropForm.FormCreate(Sender: TObject);<br>begin<br>SetWindowPos(self.Handle, hwnd_TopMost,0,0,0,0, swp_NoMove or swp_NoSize or swp_NoActivate);<br><br>end;
 
如果ShowModal的话肯定不能移动它后面的窗口了,网络蚂蚁的小浮动窗口不是模式窗口。<br>Lera的方法可以解决你的问题
 
to Lera:<br>我将你的代码试了,可惜还是不行。<br>为什么netants在打开增加任务的窗口,还是能移动拖放窗口呢。<br>它究竟是如何实现的???<br>
 
不知道加个 &nbsp;application.ProcessMessages; 管不管用?<br>有点异想天开。
 
&gt;&gt;form3.showmodal;<br>改为:SetWindowPos(Form3.Handle,HWND_TOPMOST,0,0,300,400,SWP_DRAWFRAME or SWP_SHOWWINDOW);<br>在Form3的OnClose事件中加<br>Action:=caFree;<br>netants的增加任务窗口不是模式窗口,如果是模式窗口那正在下载的任务岂非都要停下来;<br>因此我认为netants因该用我的这种方法来显示任务窗口。
 
这样可以移动form2,不过form2并不会总在最上层,<br>即使将form2.formstyle := fsStayOnTop :(<br>
 
我曾听说,netants的拖动窗口的parents属性是wondows窗口下的状态栏,<br>不知道是不是,如果是,该如何实现
 
我用Spy++查了一下Netants的任务窗口是ModalFrame,也就是模式窗口,这样,我也不知道<br>怎么处理了。<br>另:netants的拖动窗口没有父窗口也没有Owner窗口
 
对我前面的贴子补充一点:<br><br>TNotesDropForm的FormStyle是fsStayonTop.<br>我的拖放窗口是在另一个窗体的onCreate事件中写的:<br>procedure TMainForm.BuildDropBasket(IsShow: Boolean);<br>begin<br>myDropForm:=TNotesDropForm.create(nil);<br>with myDropform do<br>begin<br>height:=40;<br>width:=40;<br>color:=clblue;<br>parent:=nil;<br>visible:=IsShow;<br>end;<br>end;<br><br>你再试试。<br>白天我上不来。
 
可以使用toolbar97控件
 
后退
顶部