老问题,怎样让窗体浮在最上方.(20分)

  • 主题发起人 主题发起人 epic
  • 开始时间 开始时间
E

epic

Unregistered / Unconfirmed
GUEST, unregistred user!
试过n种方法,都不行,总是会被其他窗口挡住,我看了看,<br>连FlashGet的提示小窗口也有时会被遮住,而OICQ的广告窗口就不会,<br>怎么做?
 
窗体的FormStyle 为fsStayOnTop应该可以吧!
 
不行,你想,如果别的程序的窗口也是fsStayOnTop,<br>系统会如何处理?
 
是是API<br>SetWindowPos;<br>原型:BOOL SetWindowPos(<br>&nbsp; HWND hWnd, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // handle to window<br>&nbsp; HWND hWndInsertAfter, &nbsp;// placement-order handle<br>&nbsp; int X, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // horizontal position<br>&nbsp; int Y, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // vertical position<br>&nbsp; int cx, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// width<br>&nbsp; int cy, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// height<br>&nbsp; UINT uFlags &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// window-positioning options<br>);
 
uFlags参数要用组合的
 
用application.bringtofront;
 
那就监控啊,如果状态不是OnStayTop,就立即设为OnStayTop.[:D]
 
你一定试过ctrl_alt_del吧,这三个键为什么一按,其他的程序都在它下边,要知道它的<br>优先级是相当高的,但不是最高的,因此你可以设定程序或线程的优先级,这不就解决了!
 
使用TIME(N)<br>不停地将FORM放置到最前,:) N 由你决定
 
老问题了,看下面:<br>/////////////////////////<br>方法一:<br>先setforegroundwindow(HWND);然后再setwindowpos(form2.Handle,HWND_TOPmost,10,10,200,300,SWP_SHOWWINDOW );<br>////////////////////////<br><br>方法二:<br>关键技术是重载Form的CreateParams方法<br>{form2 code}<br>public<br>&nbsp; procedure CreateParams(Var Params:TCreateParams);override;<br><br>uses unit1;<br>procedure tform2.CreateParams(var Params:TCreateParams);<br>begin<br>&nbsp; inherited;<br>&nbsp; With Params do<br>&nbsp; begin<br>&nbsp; &nbsp; wndParent:=GetDesktopwindow;<br>&nbsp; &nbsp; ExStyle:=ExStyle or WS_EX_TOPMOST;<br>&nbsp; end;<br>end;<br><br>procedure TForm2.FormClose(Sender :TObject;var Action:TCloseAction);<br>begin<br>&nbsp; Form1.show;<br>&nbsp; ShowWindow(Application.handle,sw_show);<br>end;<br><br><br>{Form1}<br>uses unit2;<br>procedure TForm1.Button1Click(Sender:TObject);<br>begin<br>&nbsp; with tform2.create(self) do show;<br>&nbsp; hide; &nbsp;{Hide Form1}<br>&nbsp; ShowWindow(Application.handle,sw_hide); &nbsp;{Hide Application}<br>end;<br>
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部