delphi ShowDebugInfo 窗口  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi ShowDebugInfo 窗口


//调用 ShowDebugInfo('登录成功了','登录成功了');


unit uDebug;

interface

uses
  windows, Forms, StdCtrls, Controls, SysUtils;

type

  TOnDispDebugMsg = procedure(AMsg: string) of object;

procedure ShowDebugInfo(Title: string; Info: string);
procedure OutDbgMsg(AMsg: string; Value: integer); overload;
procedure OutDbgMsg(AMsg: string; Value: Cardinal); overload;
procedure OutDbgMsg(AMsg: string; Value: boolean); overload;
procedure OutDbgMsg(AMsg: string; Value: string); overload;

procedure SetOnDispDebugMsg(AOnDispDebugMsg: TOnDispDebugMsg);
procedure DispDebugMsg(AMsg: string);

implementation

var
  OnDispDebugMsg: TOnDispDebugMsg;

procedure ShowDebugInfo(Title: string; Info: string);
var
  Frm: TForm;
  Memo: TMemo;
begin

  Frm := TForm.Create(nil);
  Memo := TMemo.Create(Frm);

  with Frm do
  begin
    Left := 100;
    Top := 100;
    Caption := Title;
  end;

  with Memo do
  begin
    Parent := Frm;
    Align := alClient;
    Font.Size := 11;
    Font.Charset := GB2312_CHARSET;
    Font.Name := '宋体';
    Text := Info;
    ScrollBars := ssBoth;
  end;

  try
    Frm.ShowModal();
  finally
    Frm.Free();
  end;
end;

procedure OutDbgMsg(AMsg: string; Value: integer);
var
  sTemp: string;
begin
  AMsg := AMsg + ':';
  sTemp := inttostr(Value);
  OutputDebugString(pchar(AMsg + sTemp));
end;

procedure OutDbgMsg(AMsg: string; Value: Cardinal);
var
  sTemp: string;
begin
  AMsg := AMsg + ':';
  sTemp := inttostr(Value);
  OutputDebugString(pchar(AMsg + sTemp));
end;

procedure OutDbgMsg(AMsg: string; Value: boolean); overload;
var
  sTemp: string;
begin
  AMsg := AMsg + ':';

  if Value then
    sTemp := 'True'
  else
    sTemp := 'False';
  OutputDebugString(pchar(AMsg + sTemp));

end;

procedure OutDbgMsg(AMsg: string; Value: string);

begin
  AMsg := AMsg + ':';
  OutputDebugString(pchar(AMsg + Value));
end;

procedure SetOnDispDebugMsg(AOnDispDebugMsg: TOnDispDebugMsg);
begin
  OnDispDebugMsg := AOnDispDebugMsg;
end;

procedure DispDebugMsg(AMsg: string);
begin
  if Assigned(OnDispDebugMsg) then
    OnDispDebugMsg(AMsg);
end;

end.

推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.033989191055298 seconds