⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uerror.pas

📁 ESS-Model is a powerful, reverse engine, UML-tool for Delphi/Kylix and Java-files.
💻 PAS
字号:
{
  ESS-Model
  Copyright (C) 2002  Eldean AB, Peter S鰀erman, Ville Krumlinde

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
}

unit uError;

{
  Errorhandler.
  Use command line switch '-traceon' to display trace messages runtime.
}

interface

{$IFNDEF Release}
{$ifdef WIN32}
uses SysUtils, Forms, StdCtrls;
{$endif}
{$ifdef LINUX}
uses SysUtils, QForms, QStdCtrls;
{$endif}
{$ENDIF}


type
  TTraceMode = (trOff, trShowWindow);

  TErrorHandler = class
  public
    constructor Create;
    procedure SetTraceMode(Mode: TTraceMode);
    procedure Trace(const Msg: string);
  private
    {$IFNDEF Release}
    TraceMode: TTraceMode;
    TraceWindow: TForm;
    TraceMemo: TMemo;
    {$ENDIF}
  end;


var
  ErrorHandler: TErrorHandler;


implementation

{$IFNDEF Release}
{$ifdef WIN32}
uses Windows, Controls;
{$endif}
{$ifdef LINUX}
uses QControls;
{$endif}
{$ENDIF}


{-------------------}
{ ErrorHandler }

constructor TErrorHandler.Create;
begin
  {$IFNDEF Release}
  SetTraceMode(trOff);
  {$ENDIF}
end;


procedure TErrorHandler.SetTraceMode(Mode: TTraceMode);
{
  Avg鰎 hur tracemeddelanden visas.
  trOff
    St鋘ger av trace
  trWinDebug
    Meddelande skrivs till eventlog
    Anv鋘d View - Debug Windows - Event log i delphi f鰎 att visa dessa meddelanden
  trShowWindow
    Tracemeddelanden visas i ett eget f鰊ster
}
begin
{$IFNDEF Release}
  TraceMode := Mode;
  if (TraceMode = trShowWindow) and (TraceWindow = nil) then
  begin
    TraceWindow := TForm.Create(Application);
    //F鰊stret skapas nere i h鰃ra h鰎net, med full bredd.
    with TraceWindow do
    begin
      FormStyle := fsStayOnTop;
      Left := Screen.Width - 300;
      Top := (Screen.Height div 3) * 2;
      Width := Screen.Width - 100;
      Height := Screen.Height div 3;
    end;
    TraceMemo := TMemo.Create(TraceWindow);
    with TraceMemo do
    begin
      Parent := TraceWindow;
      Align := alClient;
      ScrollBars := ssVertical;
    end;
    TraceWindow.Show;
  end;
{$ENDIF}
end;


procedure TErrorHandler.Trace(const Msg: string);
begin
{$IFNDEF Release}
  case TraceMode of
    trOff: ;
    trShowWindow: TraceMemo.Lines.Add(Msg);
  end;
{$ENDIF}
end;

{--------------------}


initialization

  ErrorHandler := TErrorHandler.Create;
  {$IFNDEF Release}
  if FindCmdLineSwitch('traceon', ['-', '/'], True) then
    ErrorHandler.SetTraceMode(trShowWindow);
  {$ENDIF}

finalization

  ErrorHandler.Free;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -