Z
ZHC
Unregistered / Unconfirmed
GUEST, unregistred user!
我编写了一个可程序,希望显示一个子窗口,但并不激活它(即不获得输入焦点), <br>这可以用showwindow(form2.handle,SW_SHOWNA)达到目的,但是我发现<br>用这个函数现实的窗体,其上的按钮没有显示出来,<br>我改用 setwindowpos(form2.handle,0,0,0,0,0,swp_showwindow or swp_nosize or swp_nomove);<br>也无法显示按钮。<br>并且用鼠标点击关闭按钮没有任何作用,不知为何?是否有其他办法可以达到<br>不激活显示窗体的目的。 <br><br>以下是我的程序代码。<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls,unit2;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> setwindowpos(form2.handle,0,0,0,0,0,swp_showwindow or swp_nosize or swp_nomove);<br>end;<br><br>end.<br>以上是主窗体,点击button1显示子窗体。<br><br>unit Unit2;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm2 = class(TForm)<br> Button1: TButton;<br> Label1: TLabel;<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form2: TForm2;<br><br>implementation<br><br>{$R *.DFM}<br><br>end.<br>以上是子窗体,其上有一个按钮button1,用showwindow时无法显示出来。