因为Memo1和Showmessage都是有焦点的,会同时运行,结果是,点了Showmessage的确认信息,Memo1的选择 文本会取消,所以不能用Showmessage

var   aCode:integer;    //记录 memo1错误代号
procedure TForm3.UpdateStatus(Code: Integer; const Msg: string);
begin
 Timer1.Enabled:=true;
  StatusBar1.Panels[0].Text := Msg;
 aCode:= Code;
end;

复制代码
procedure TForm3.StatusBar1DrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel;   const Rect: TRect);
const
  STATUS_COLORS: array[0..2] of TColor = (clBtnFace, $0000ff, $66CCFF);   //默认背景色,错误背景色
begin
  with StatusBar1.Canvas do begin
    Brush.Color := STATUS_COLORS[aCode];
    FillRect(Rect);

    Font.Size := 10;
    if aCode=0 then  Font.Color:= clblack;       //默认 字体 颜色 为黑色
    if aCode=1 then  Font.Color:= clwhite;       //错误 字体 颜色 为红

    TextOut(Rect.Left + 10, Rect.Top + 4, Panel.Text);
  end;
end;
复制代码

 

procedure TForm3.Timer1Timer(Sender: TObject);
begin
   UpdateStatus(0, '');  //返回 一般状态
  Timer1.Enabled:=  false;
end;