• 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.

  • 相关阅读:
    log4j1修改DailyRollingFileAppender支持日志最大数量
    log4j1 修改FileAppender解决当天的文件没有日期后缀
    log4j生成有日期的日志文件名
    Java删除List和Set集合中元素
    Java并发编程:并发容器之ConcurrentHashMap
    Java并发编程:并发容器之CopyOnWriteArrayList
    java.util.ConcurrentModificationException解决详解
    Handshake failed due to invalid Upgrade header: null 解决方案
    web项目Log4j日志输出路径配置问题
    log4j.properties 的使用详解
  • 原文地址:https://www.cnblogs.com/Jekhn/p/1917233.html
Copyright © 2020-2023  润新知