数学建模社区-数学中国

标题: 请问,怎样让程序一到时间,就弹到最前呢? [打印本页]

作者: 小菜菜同学    时间: 2005-4-30 12:15
标题: 请问,怎样让程序一到时间,就弹到最前呢?
<>就是让程序运行后,干点别的,程序运行完或一到时间,就不管你做什么,就一下子弹到最先,起一提示作用。就象有的下棋网络游戏,对方一下棋,棋盘就自动跳出来。</P>* s$ f% e. I2 `* A2 R2 i# S8 b
<>望大侠解答一下,</P>[em02][em02]
作者: ilikenba    时间: 2005-4-30 13:18
<>用一个时钟控件,在OnTimer事件中加上Form2-&gt;Show();</P><>使窗体在最前面主要是重载Form的虚拟函数CreateParams,改变TCreateParams的成员WndParent就可以了。  
0 R5 @0 r" X. _  q$ i; b
  o4 _2 B: G; F( z  o! wclass  TForm2  :  public  TForm  8 f( k. E2 T0 x# s3 g) G
{  
1 t% B) J' S% M! y" s, Z! |__published:            //  IDE-managed  Components  % M) j  [' \) s! r
private:            //  User  declarations  + Z2 v! \  q, B3 d5 [& h. P
protected:  2 ~+ Y! \/ I0 a( n& L
       virtual  void  __fastcall  CreateParams(TCreateParams  &amp;  Param);  6 C0 f% c# i( ^2 b; P
public:            //  User  declarations  
) Q8 J. F* e: m* ~4 H# `+ \' s       __fastcall  TForm2(TComponent*  Owner);  2 }3 h' K. U* r+ @0 v8 _# q
};  8 F/ N$ V5 p3 l! W

3 K& s; k3 x9 ^# X( C5 Bvoid  __fastcall  TForm2::CreateParams(TCreateParams  &amp;  Param)  
% j7 a) r1 p: n) x: T' j8 K{  8 s, ?9 s, q3 i) a5 {5 t
       //调用基类的函数  
( Y6 X( ^6 @% w0 i5 B4 _2 p5 K       TForm::CreateParams(Param);  
* f2 c1 a- ~% j* q9 a  L( S
6 G/ }/ b; e% `% d1 H5 P6 l( E       Param.ExStyle    &brvbar;=  WS_EX_TOPMOST;    0 j  y2 K+ U# T

* A* R. r; o$ A9 M- n       //这儿最关键的是只要Param.WndParent不是Application-&gt;Handle就可以了,  
5 O0 B- c6 A! ~7 P  b% P6 m( i       //不一定非要用GetDesktopWindow(),用其它的窗口也可以。  
" M, o% i0 b9 R1 p9 w       Param.WndParent  =  GetDesktopWindow();   
  @# B+ i* \) m- z/ R}6 _: L' U; o$ Z
</P>




欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5