• Custom ShowMessage,MessageDlg


    showMessage:

    代码
    {
    --Author Ming
    --Version V01.001
    --Creation Date 2009/03/25
    --Last Updated Date
    }
    unit unitShowMsg;

    interface

    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls, ExtCtrls;

    type
    TfrmShowMsg
    = class(TForm)
    moMsg: TMemo;
    btOK: TButton;
    Panel1: TPanel;
    procedure btOKClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    private
    { Private declarations }
    procedure ChangeLanguage;
    public
    { Public declarations }
    class procedure CustShowMessage(aMsg:String);
    end;

    var
    frmShowMsg: TfrmShowMsg;

    implementation

    const
    K_CH
    = 'CN';
    K_EN
    = 'EN';
    LanguageFlag
    = K_CH;

    {$R *.dfm}

    procedure TfrmShowMsg.ChangeLanguage;
    begin
    if LanguageFlag = K_CH then
    begin
    btOK.Caption :
    = '确定';
    end
    else
    begin
    btOK.Caption :
    = 'OK';
    end;
    end;

    class procedure TfrmShowMsg.CustShowMessage(aMsg:String);
    begin
    with TfrmShowMsg.Create(nil) do
    try
    moMsg.Clear;
    moMsg.Lines.Add(aMsg);
    ShowModal;
    finally
    Free;
    end
    end;

    procedure TfrmShowMsg.btOKClick(Sender: TObject);
    begin
    Close;
    end;

    procedure TfrmShowMsg.FormCreate(Sender: TObject);
    begin
    ChangeLanguage;
    end;

    end.
    MessageDlg:

    代码
    {
    --Author Ming
    --Version V01.001
    --Creation Date 2009/03/25
    --Last Updated Date
    }
    unit unitMsgDlg;

    interface

    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, ExtCtrls, StdCtrls;

    type
    TfrmMsgDlg
    = class(TForm)
    btYes: TButton;
    btNo: TButton;
    Panel1: TPanel;
    moMsg: TMemo;
    procedure btYesClick(Sender: TObject);
    procedure btNoClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    private
    { Private declarations }
    procedure ChangeLanguage;
    public
    { Public declarations }
    class function CustMessageDlg(aMsg:String):Boolean;
    end;

    var
    frmMsgDlg: TfrmMsgDlg;

    implementation

    const
    K_CH
    = 'CN';
    K_EN
    = 'EN';
    LanguageFlag
    = K_CH;

    {$R *.dfm}

    procedure TfrmMsgDlg.ChangeLanguage;
    begin
    if LanguageFlag = K_CH then
    begin
    btYes.Caption :
    = '确定';
    btNo.Caption :
    = '取消';
    end
    else
    begin
    btYes.Caption :
    = 'Yes';
    btNo.Caption :
    = 'No';
    end;
    end;

    class function TfrmMsgDlg.CustMessageDlg(aMsg:String):Boolean;
    begin
    with TfrmMsgDlg.Create(nil) do
    try
    moMsg.Clear;
    moMsg.Lines.Add(aMsg);
    ShowModal;
    Result :
    = ModalResult = mrYes;
    finally
    Free;
    end;
    end;

    procedure TfrmMsgDlg.btYesClick(Sender: TObject);
    begin
    Self.ModalResult :
    = mrYes;
    end;

    procedure TfrmMsgDlg.btNoClick(Sender: TObject);
    begin
    Self.ModalResult :
    = mrNo;
    end;

    procedure TfrmMsgDlg.FormCreate(Sender: TObject);
    begin
    ChangeLanguage;
    end;

    end.

  • 相关阅读:
    软工实践结对作业第二次
    团队展示
    软件工程结对作业
    软工实践第二次作业
    栈的初步学习
    课程作业四
    作业
    课程作业2
    博客汇总目录
    Mybatis-plus学习笔记,基于springboot
  • 原文地址:https://www.cnblogs.com/Jekhn/p/1917233.html
Copyright © 2020-2023  润新知