请问程序中怎么判断当前是否有消息窗口弹出比如showmessage('xxx')窗口
并用程序关闭它

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
       showmessage('123');
    end;procedure TForm1.Timer1Timer(Sender: TObject);
    var  HWindow, HButton: THandle; //句柄变量
    Begin
       HWindow := 0;
       While true Do
          Begin
           HWindow := FindWindowEx(0, HWindow, 'TMessageForm', 'Project2');//Showmessage的窗体
           if hwindow=0 then
           begin
           exit;
           end
           else
           Begin
           HButton := FindWindowEx(HWindow, 0, 'TButton','OK');//找到按钮
          SendMessage(HButton, BM_CLICK, 0, 0);//单击按纽
         break;
        End;
      end;
    End;//Winxp+D7测试通过~~`