因为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;
分类:
Delphi2010
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律