程序定时弹出提示消息,要显示到最前面,如果windows系统在执行几个程序时,比如我在操作OFFICE,也要显示到前面,直到点击确定,请问怎样写.谢谢。

解决方案 »

  1.   

    alwaysontop ,MainForm的窗口属性设置
      

  2.   

    可以考虑用这个API,AnimateWindow,类似QQ什么的弹出消息
      

  3.   

    MessageBox(Handle,pchar(e.Message),'错误信息',MB_OK or MB_ICONSTOP or MB_SYSTEMMODAL );
      

  4.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls, StdCtrls;type
      TForm1 = class(TForm)
        Label1: TLabel;
        Button1: TButton;
        Timer1: TTimer;
        Timer2: TTimer;
        procedure FormCreate(Sender: TObject);
        procedure Timer1Timer(Sender: TObject);
        procedure Button1Click(Sender: TObject);
        procedure Timer2Timer(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
    begin
      label1.Caption:='现在是:'+datetostr(now)+#13#10+'        '+timetostr(now);
      form1.Left:=round(screen.Width/2)-150;
      form1.Top:=round(screen.Height/2)-75;
      form1.Width:=300;
      form1.Height:=150;
      timer1.Interval:=1000;
      timer2.Interval:=10000;
      SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
    end;procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      label1.Caption:='现在是:'+datetostr(now)+#13#10+'        '+timetostr(now);
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      form1.WindowState:=wsMinimized;
      form1.FormStyle:=fsNormal;
    end;procedure TForm1.Timer2Timer(Sender: TObject);
    begin
      form1.FormStyle:=fsStayOnTop;
      form1.WindowState:=wsNormal;
      form1.Left:=round(screen.Width/2)-150;
      form1.Top:=round(screen.Height/2)-75;
      form1.Width:=300;
      form1.Height:=150;
    end;end.这个是定时每十秒显示到屏幕中央。
    很简单的。