在达到最大长度时第二次避免使用相同的警告消息

问题描述 投票:-1回答:1

我有这个 :

procedure TForm1.cxMemo1PropertiesChange(Sender: TObject);
begin
  if not  (trim(cxmemo1.lines.Text) = '')  then begin
    AdvSmoothWin8Marquee1.Animate :=True;
    AdvSmoothWin8Marquee1.Visible :=True;
    cxlabel1.Visible:=True;
    cxlabel1.caption := 'Letters left : ' + inttostr(cxmemo1.Properties.MaxLength - Length(cxmemo1.Text));
    if Length(cxMemo1.Text) = cxMemo1.Properties.MaxLength then    //when maximum lenght reached
      if MessageDlg(
        'Maximum lenght reached (200).'+ #13#10 +'Extend maximum lenght to 500?',
        mtWarning, 
        [mbNo, mbYes], 
        0) = mrYes then
          cxmemo1.Properties.MaxLength:=500;
    cxlabel1.caption := 'Letters left : ' + inttostr(cxmemo1.Properties.MaxLength - Length(cxmemo1.Text));
  end else  begin
    AdvSmoothWin8Marquee1.Animate :=False;
    AdvSmoothWin8Marquee1.Visible :=False;
    cxmemo1.Properties.MaxLength:=200 ;
    cxlabel1.Visible:=False;
  end;
end;

如果用户在备忘录中达到500个字符或者至少告诉他已经达到最大奖励(500),我该如何避免显示警告信息?

delphi
1个回答
0
投票

在这里,重做......

procedure TForm1.cxMemo1PropertiesChange(Sender: TObject);
begin
if not  (trim(cxmemo1.lines.Text) = '')  then  begin
AdvSmoothWin8Marquee1.Animate :=True;
AdvSmoothWin8Marquee1.Visible :=True;
cxlabel1.Visible:=True;
cxlabel1.caption := 'Letters left : ' + inttostr(cxmemo1.Properties.MaxLength - Length(cxmemo1.Text));
end else begin
AdvSmoothWin8Marquee1.Animate :=False;
AdvSmoothWin8Marquee1.Visible :=False;
cxmemo1.Properties.MaxLength:=200 ;
cxlabel1.Visible:=False;
end;
  if Length(cxMemo1.Text) = cxMemo1.Properties.MaxLength then begin
  case cxmemo1.Properties.MaxLength of
  200:
  if MessageDlg('Maximum lenght reached (200).'+ #13#10 +'Extend memo maximum lenght to 400?',
  mtWarning, [mbNo, mbYes], 0) = mrYes then  begin
  cxmemo1.Properties.MaxLength:=400;
  cxlabel1.caption := 'Letters left : ' + inttostr(cxmemo1.Properties.MaxLength - Length(cxmemo1.Text));
  end;
  400: 
  ShowMessage('No more extensions.');
  end;
  end;
  end;
end;
© www.soinside.com 2019 - 2024. All rights reserved.