比如说一个程序定时弹出messagebox窗口进行提示,如何让它显示在其他窗口的前面?并且过一段时间之后自动关闭?
不用messagebox用其它方法也行!
请给出完整的代码,谢谢!

解决方案 »

  1.   

    {
    我这里写了一个过程,可以完成你所需的功能:
    新建一个窗体,在其上放置一个Memo用于显示信息
    ,一个Timer用于定时,一个按钮用于关闭提示窗口(将其
    ModalResult属性设置为mrOK),在需要调用本过程的窗体中
    uses unit2,调用ShowMyInfoBox过程即可,祝好运!
    }
    unit Unit2;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      ExtCtrls, StdCtrls;type
      Tfrminfo = class(TForm)
        Memo1: TMemo;
        btnok: TButton;
        Timer1: TTimer;
        procedure Timer1Timer(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    //显示提示信息的窗口,默认是隔1秒钟自动关闭,你可以在调用时
    //指定另外的值.
    procedure ShowMyInfoBox(info:String;timeout:Integer=1000);implementation{$R *.DFM}procedure ShowMyInfoBox(info:String;timeout:Integer=1000);
    Var
      frminfo:TFrminfo;
    begin
    frminfo:=TFrminfo.Create(application);
    try
      frminfo.memo1.clear;
      frminfo.Memo1.Lines.Add(info);
      frminfo.Timer1.Enabled:=false;
      frminfo.Timer1.Interval:=timeout;
      frminfo.Timer1.Enabled:=true;
      frminfo.ShowModal;
    finally
      frminfo.Free;
    end;
    end;procedure Tfrminfo.Timer1Timer(Sender: TObject);
    begin
    ModalResult:=mrOK;
    end;end.
      

  2.   

    只能自己做一个类似 MESSAGEBOX 的 FORM
      

  3.   

    你们可以去联众打一下它的游戏,,,它有个非常典型的这样的窗口,就是自已画的而不是用MessageBox做的
      

  4.   


    不用自己写窗口!只要在MessageBox函数中加入 MB_SYSTEMMODAL 常数就能实现最前端显示!至于定时关闭,用TIMER设定时间,到时找到messagebox窗口句柄,发送关闭消息即可!
      

  5.   


      //New a Application,在窗体上加入一个 Button 和一个 Timer  //将 Timer 的 Enabled 属性设定为 False  //将 Timer 的 Interval 属性设定为 5000  // 这个就是关闭的时间  //其他代码如下:procedure TForm1.Button1Click(Sender: TObject);
    begin
    Timer1.Enabled:=True;
    MessageBox(Form1.Handle,'内容','标题',MB_SYSTEMMODAL);
    end;procedure TForm1.Timer1Timer(Sender: TObject);
    var
    WFound:THandle;
    begin
    Timer1.Enabled:=False;
    WFound:=FindWindow(nil,'标题');
    If WFound<>0 Then
    SendMessage(WFound,WM_SYSCOMMAND,SC_CLOSE,0);
    end;
    //一点问题也没有,散分吧~
      

  6.   

    ★那么如何让这个messagebox上动态的显示当前的时间呢?
    我对消息和win 32 api一点不懂,惨!通过什么来学习呢?
      

  7.   

    to:TempterX(兄弟) 
    我真是学到了。
    ★那么如何让这个messagebox上动态的显示当前的时间呢?
    我对消息和win 32 api一点不懂,惨!通过什么来学习呢?
      

  8.   

    TempterX(兄弟)的做法是对的,其实你只要注意加入句柄就行了
    自动消失的话你可以用不同的方法来控制它
      

  9.   

    要显示时间,那只能是自己画的窗体了。messagebox功能有限!
      

  10.   

    TempterX(兄弟)做法较好,不过根据窗体标题找窗体的效率较低。
    建议自己做一类,这样以后也可以用了。
      

  11.   

    messagebox在最前面
    MessageBox(FindWindow('progman',nil),'This is A Test','Test',MB_TOPMOST);
      

  12.   

    MessageBox(0'This is A Test','Test',MB_TOPMOST);就行了
      

  13.   

    错了

    MessageBox(0,'This is A Test','Test',MB_TOPMOST);