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

📄 configformunit.pas

📁 自动打印dos产生的文本文件 自动打印dos产生的文本文件
💻 PAS
字号:
{******************************************************************************}
{                                                                              }
{   WinPrint - Print Spooler for DOS Programs                                  }
{                                                                              }
{   Copyright (C) 2004 Przemyslaw Czerkas <przemekc@users.sourceforge.net>     }
{                 2008 Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>      }
{   See GPL.TXT for copyright and license details.                             }
{                                                                              }
{******************************************************************************}

{******************************************************************************}
{                                                                              }
{   This file is part of WinPrint.                                             }
{                                                                              }
{   WinPrint 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.                                        }
{                                                                              }
{   WinPrint 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 WinPrint; if not, write to the Free Software                    }
{   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                      }
{   MA  02111-1307  USA                                                        }
{                                                                              }
{******************************************************************************}

unit ConfigFormUnit;

{$WARN UNIT_PLATFORM OFF}
{$WARN SYMBOL_PLATFORM OFF}

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ComCtrls, StdCtrls, Buttons, ExtCtrls, NumEdit, Printers, ConversionUnit;

type
  TConfigData = record
    InputFilesDir: string;
    InputFilesMask: string;
    FormatFileExtension: string;
    EnableFormatting: boolean;
    TimerInterval: integer;
    MinFileAge: integer;
    Priority: integer;
    AutoStart: boolean;
    FontName: string;
    FontSize: integer;
    FontCharset: integer;
    FontStyles: TFontStyles;
    MarginLeft,MarginRight,MarginTop,MarginBottom: double;
    Orientation: TPrinterOrientation;
    LinesPerInch: double;
    LinesPerPage: integer;
    EOPCodes: TCharCodes;
    SkipEmptyPages: boolean;
    ClipperCompatible: boolean;
    CodePage: TCodePage;
    UseCustomConversionTable: boolean;
    ConversionItems: TConversionItems;
    Logo: string;
    LogoLeft: double;
    LogoTop: double;
    Logo1PageOnly: boolean;
    PrinterId: integer;
  end;

  TConfigForm = class(TForm)
    Button3: TButton;
    Button2: TButton;
    Button1: TButton;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    GroupBox1: TGroupBox;
    SpeedButton1: TSpeedButton;
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    GroupBox2: TGroupBox;
    Label3: TLabel;
    Label4: TLabel;
    CheckBox1: TCheckBox;
    GroupBox3: TGroupBox;
    Label5: TLabel;
    Memo1: TMemo;
    Button4: TButton;
    GroupBox4: TGroupBox;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    RadioGroup1: TRadioGroup;
//    FloatEdit1: TFloatEdit;
//    FloatEdit2: TFloatEdit;
//    FloatEdit3: TFloatEdit;
//    FloatEdit4: TFloatEdit;
    Edit3: TEdit;
    Label11: TLabel;
    Button5: TButton;
    Button6: TButton;
    Label12: TLabel;
    TrackBar1: TTrackBar;
    Label13: TLabel;
    GroupBox5: TGroupBox;
    Label10: TLabel;
//    FloatEdit5: TFloatEdit;
//    IntEdit1: TIntEdit;
    Label14: TLabel;
    CheckBox2: TCheckBox;
    TabSheet3: TTabSheet;
    GroupBox6: TGroupBox;
    Edit4: TEdit;
    Label15: TLabel;
    CheckBox3: TCheckBox;
    GroupBox7: TGroupBox;
    Button7: TButton;
    ComboBox1: TComboBox;
    Label16: TLabel;
    ListBox1: TListBox;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
//    IntEdit2: TIntEdit;
//    IntEdit3: TIntEdit;
    Edit5: TEdit;
    CheckBox4: TCheckBox;
    Label17: TLabel;
    Label18: TLabel;
    Button8: TButton;
    Button9: TButton;
    CheckBox5: TCheckBox;
    Edit6: TEdit;
    Edit7: TEdit;
    UpDown1: TUpDown;
    UpDown2: TUpDown;
    TabSheet4: TTabSheet;
    GroupBox8: TGroupBox;
    SpeedButton4: TSpeedButton;
    Label19: TLabel;
    Label20: TLabel;
    Label21: TLabel;
    Edit8: TEdit;
    Button10: TButton;
    CheckBox6: TCheckBox;
    Button11: TButton;
    ComboBox2: TComboBox;
    GroupBox9: TGroupBox;
    Label22: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure TrackBar1Change(Sender: TObject);
    procedure FloatEdit5Change(Sender: TObject);
    procedure IntEdit1Change(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
    procedure CheckBox4Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure ListBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Button8Click(Sender: TObject);
    procedure Button9Click(Sender: TObject);
    procedure Button10Click(Sender: TObject);
    procedure SpeedButton4Click(Sender: TObject);
    procedure Button11Click(Sender: TObject);
  private
    { Private declarations }
    ListBox1HintIndex: integer;
    IgnoreOnChange: boolean;
    TempConversionItems: TConversionItems;
    IntEdit1: TIntEdit;
    IntEdit2: TIntEdit;
    IntEdit3: TIntEdit;
    FloatEdit1: TFloatEdit;
    FloatEdit2: TFloatEdit;
    FloatEdit3: TFloatEdit;
    FloatEdit4: TFloatEdit;
    FloatEdit5: TFloatEdit;
    FloatEdit6: TFloatEdit;
    FloatEdit7: TFloatEdit;
    procedure ReadConfig;
    procedure WriteConfig;
  public
    { Public declarations }
    ConfigData: TConfigData;
    procedure LoadLang;
  published
    procedure ConfigChanged(Sender: TObject);
    procedure ConfigChanging(Sender: TObject; var AllowChange: Boolean);
    procedure ResolveEditValues1(Sender: TObject);
  end;

var
  ConfigForm: TConfigForm;
  PROGRAMNAME: string;

implementation

uses
  MainFormUnit, FileCtrl, Registry, IniFiles,
  SetString; //dla SetToString

{$R *.DFM}

const
  DEFAULT_INPUT_FILES_DIR = '';
  DEFAULT_INPUT_FILES_MASK = '*.txt';
  DEFAULT_FORMAT_FILE_EXTENSION = 'frm';
  DEFAULT_ENABLE_FORMATTING = true;
  DEFAULT_TIMER_INTERVAL = 500;
  DEFAULT_MIN_FILE_AGE = 500;
  DEFAULT_PRIORITY = 2; //real-time priority
  DEFAULT_AUTO_START = false;
  DEFAULT_FONT_NAME = 'Courier New';
  DEFAULT_FONT_SIZE = 12;
  DEFAULT_FONT_CHARSET = 238; //Easter Europe
  DEFAULT_FONT_STYLES = [];
  DEFAULT_MARGIN_LEFT = 12.7;
  DEFAULT_MARGIN_RIGHT = 12.7;
  DEFAULT_MARGIN_TOP = 12.7;
  DEFAULT_MARGIN_BOTTOM = 12.7;
  DEFAULT_ORIENTATION = poPortrait;
  DEFAULT_LINES_PER_INCH = 6;
  DEFAULT_LINES_PER_PAGE = 0;
  DEFAULT_EOP_CODES = [12,26];
  DEFAULT_SKIP_EMPTY_PAGES = true;
  DEFAULT_CLIPPER_COMPATIBLE = TRUE;
  DEFAULT_CODE_PAGE = cp852;
  DEFAULT_USE_CUSTOM_CONVERSION_TABLE = false;
  DEFAULT_LOGO = '';
  DEFAULT_LOGO_LEFT = 12.7;
  DEFAULT_LOGO_TOP = 12.7;
  DEFAULT_LOGO_1PAGE_ONLY = false;
  DEFAULT_PRINTER = '';

  MinPriorityClass = -1;
  MaxPriorityClass = 2;

  PriorityClassValues: array[MinPriorityClass..MaxPriorityClass] of cardinal =
        (IDLE_PRIORITY_CLASS,
         NORMAL_PRIORITY_CLASS,
         HIGH_PRIORITY_CLASS,
         REALTIME_PRIORITY_CLASS);
var
  PriorityClassNames: array[MinPriorityClass..MaxPriorityClass] of string;


procedure SaveCollectionToStream(Collection: TCollection; Stream: TStream);
begin
  with TWriter.Create(Stream, 4096) do
  try
    WriteCollection(Collection);
  finally
    Free;
  end;
end;

procedure LoadCollectionFromStream(Stream: TStream; Collection: TCollection);
begin
  with TReader.Create(Stream, 4096) do
  try
    CheckValue(vaCollection);
    ReadCollection(Collection);
  finally
    Free;
  end;
end;

{}

procedure TConfigForm.FormCreate(Sender: TObject);
var i: integer;
begin
 Label8.Caption:=RString(111);
{komponenty dynamiczne}
  IntEdit1:=TIntEdit.Create(Self);
  with IntEdit1 do begin
          Left := 212;
          Top := 22;
          Width := 50;
          Height := 21;
//          TabOrder := 1;
          Text := '0';
          OnChange := IntEdit1Change;
          OnExit := ResolveEditValues1;
          Parent := GroupBox5;
          Visible := true;
  end;
  IntEdit2:=TIntEdit.Create(Self);
  with IntEdit2 do begin
          Left := 12;
          Top := 90;
          Width := 48;
          Height := 21;
//          TabOrder := 2;
          Text := '0';
          Parent := GroupBox7;
          Visible := true;
  end;
  IntEdit3:=TIntEdit.Create(Self);
  with IntEdit3 do begin
          Left := 70;
          Top := 90;
          Width := 48;
          Height := 21;
          Hint := 'IntEdit3';
          ParentShowHint := False;
          ShowHint := True;
//          TabOrder := 3;
          Text := '0';
          Parent := GroupBox7;
          Visible := true;
  end;
  FloatEdit1:=TFloatEdit.Create(Self);
  with FloatEdit1 do begin
          Left := 44;
          Top := 24;
          Width := 50;
          Height := 21;
//          TabOrder := 0;
          Text := '0';
          OnChange := ConfigChanged;
          Parent := GroupBox4;
          Visible := true;
  end;
  FloatEdit2:=TFloatEdit.Create(Self);
  with FloatEdit2 do begin
          Left := 136;
          Top := 24;
          Width := 50;
          Height := 21;
//          TabOrder := 1;
          Text := '0';
          OnChange := ConfigChanged;
          Parent := GroupBox4;
          Visible := true;
  end;
  FloatEdit3:=TFloatEdit.Create(Self);
  with FloatEdit3 do begin
          Left := 44;
          Top := 56;
          Width := 50;
          Height := 21;
//          TabOrder := 2;
          Text := '0';
          OnChange := ConfigChanged;
          Parent := GroupBox4;
          Visible := true;
  end;
  FloatEdit4:=TFloatEdit.Create(Self);
  with FloatEdit4 do begin
          Left := 136;
          Top := 56;
          Width := 50;
          Height := 21;
//          TabOrder := 3;
          Text := '0';
          OnChange := ConfigChanged;
          Parent := GroupBox4;
          Visible := true;
  end;
  FloatEdit5:=TFloatEdit.Create(Self);
  with FloatEdit5 do begin
          Left := 92;
          Top := 22;
          Width := 50;
          Height := 21;
//          TabOrder := 5;
          Text := '0';
          OnChange := FloatEdit5Change;
          OnExit := ResolveEditValues1;
          Parent := GroupBox5;
          Visible := true;
  end;
  FloatEdit6:=TFloatEdit.Create(Self);
  with FloatEdit6 do begin
          Left := 12;
          Top := 80;
          Width := 50;
          Height := 21;
//          TabOrder := 3;
          Text := '0';
          OnChange := ConfigChanged;
          Parent := GroupBox8;
          Visible := true;
  end;
  FloatEdit7:=TFloatEdit.Create(Self);
  with FloatEdit7 do begin
          Left := 88;
          Top := 80;
          Width := 50;
          Height := 21;
//          TabOrder := 0;
          Text := '0';
          OnChange := FloatEdit5Change;
          OnExit := ResolveEditValues1;
          Parent := GroupBox8;
          Visible := true;
  end;

  combobox2.Items.Clear;
  combobox2.Items.Add(RString(163));
  combobox2.ItemIndex:=0;

  Printer.Refresh; //od渨ie

⌨️ 快捷键说明

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