发信人: gear1023()
整理人: soaringbird(2002-11-08 21:18:20), 站内信件
|
//以下Unit 是修改后的Showmessage ==> sMsg,用于调试方便
// 原用法 新用法
// ———————————————— ————
// Showmessage(IntToStr(134)); ==> sMsg(134);
// Showmessage(DateTimeToStr(now)); ==> sMsg(now);
unit GSDialogs;
interface
uses Windows, Messages, SysUtils, Dialogs, Classes, Graphics, Controls, Forms;
// Extend ShowMessage
function SMsg(const Msg: Extended; sFloatFormat:string=''; bShowMessag:Boolean=True): string; overload;
function SMsg(const Msg: Integer; bShowMessag:Boolean=True): string; overload;
function sMsg(const Msg: string; bShowMessag:Boolean=True): string; overload;
function sMsg(const Msg: TClass; bShowMessag:Boolean=True): string; overload;
function SMsg(const Msg: TDateTime; sDateformat:string=''; bShowMessag:Boolean=True): string; overload;
function sMsg(const Msg: TObject; bShowMessag:Boolean=True): string; overload;
implementation
function SMsg(const Msg: Integer; bShowMessag:Boolean=True): string;
begin
Result := IntToStr(msg);
sMsg(Result, bShowMessag);
end;
function SMsg(const Msg: string; bShowMessag:Boolean=True): string;
begin
if bShowMessag then
ShowMessage(Msg);
end;
function SMsg(const Msg: TDateTime; sDateformat:string=''; bShowMessag:Boolean=True): string;
begin
if sDateformat = '' then
Result := DateTimeToStr(msg)
else
Result := FormatDateTime(sDateFormat, msg);
sMsg(Result, bShowMessag);
end;
function SMsg(const Msg: Extended; sFloatFormat:string=''; bShowMessag:Boolean=True): string;
begin
if sFloatFormat = '' then
Result := FloatToStr(msg)
else
Result := FormatFloat(sFloatFormat, msg);
sMsg(Result, bShowMessag);
end;
function sMsg(const Msg: TObject; bShowMessag:Boolean=True): string; overload;
begin
if Msg is TComponent then
Result := Format('%s:%s', [TComponent(Msg).Name, TComponent(Msg).ClassName])
else
Result := msg.ClassName;
sMsg(Result, bShowMessag);
end;
function sMsg(const Msg: TClass; bShowMessag:Boolean=True): string; overload;
begin
Result := msg.ClassName;
sMsg(Result, bShowMessag);
end;
end.
|
|