diff --git a/WinPrint.RES b/WinPrint.RES index 024c06e..2fcf44c 100644 Binary files a/WinPrint.RES and b/WinPrint.RES differ diff --git a/WinPrint.bdsproj b/WinPrint.bdsproj index 60b8089..48ea9fa 100644 --- a/WinPrint.bdsproj +++ b/WinPrint.bdsproj @@ -150,7 +150,7 @@ 1 5 0 - 59 + 60 False True False @@ -162,7 +162,7 @@ GNU GPL Software WinPrint - 1.5.0.59 + 1.5.0.60 WinPrint Przemysław Czerkas & Mieczysław Nalewaj diff --git a/WinPrint.cfg b/WinPrint.cfg index 5076182..7bcfcc5 100644 --- a/WinPrint.cfg +++ b/WinPrint.cfg @@ -33,5 +33,5 @@ -K$00400000 -E"executable" -N0"units" --LE"C:\Documents and Settings\XPMUser\Moje dokumenty\Borland Studio Projects\Bpl" --LN"C:\Documents and Settings\XPMUser\Moje dokumenty\Borland Studio Projects\Bpl" +-LE"C:\Documents and Settings\User\Moje dokumenty\Borland Studio Projects\Bpl" +-LN"C:\Documents and Settings\User\Moje dokumenty\Borland Studio Projects\Bpl" diff --git a/changelog.txt b/changelog.txt index ae57bfe..3716657 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,10 @@ Changelog of WinPrint ===================== +WinPrint 1.5.0.60 +----------------- + - [NEW] Automatic printer switching when changing the printer list and default printer + WinPrint 1.5.0.59 ----------------- - [ADD] Added code pages CP-668, CP-774 and CP-851 to supported ones diff --git a/readme.txt b/readme.txt index 3eb78a4..5ac6a00 100644 --- a/readme.txt +++ b/readme.txt @@ -13,7 +13,7 @@ COPYRIGHT --------- Copyright (C) 2004-2008 Przemyslaw Czerkas - 2008-2022 Mieczyslaw Nalewaj + 2008-2023 Mieczyslaw Nalewaj See GPL.TXT for copyright and license details. diff --git a/source/ConfigFormUnit.pas b/source/ConfigFormUnit.pas index f788de3..383d795 100644 --- a/source/ConfigFormUnit.pas +++ b/source/ConfigFormUnit.pas @@ -70,7 +70,7 @@ TConfigData = record LogoTop: double; Logo1PageOnly: boolean; IgnoreEmptyFiles: boolean; - PrinterId: integer; + PrinterName: string; PortCapturing: integer; KeepInputFiles: boolean; SpecialSettings: integer; @@ -627,14 +627,14 @@ procedure TConfigForm.ReadConfig; KeepInputFiles:=ReadBool(section,'KeepInputFiles',DEFAULT_KEEP_INPUT_FILES); SpecialSettings:=ReadInteger(section,'SpecialSettings',DEFAULT_SPECIAL_SETTINGS); - i := ComboBox2.Items.IndexOf(ReadString(section,'Printer',DEFAULT_PRINTER)); + PrinterName:=ReadString(section,'Printer',DEFAULT_PRINTER); + i := ComboBox2.Items.IndexOf(PrinterName); if i>=0 then begin ComboBox2.ItemIndex:= i; - PrinterId:= i-1; end else begin ComboBox2.ItemIndex:= 0; - PrinterId:=-1; + PrinterName:=''; end; finally @@ -837,7 +837,7 @@ procedure TConfigForm.ReadConfig; except KeepInputFiles:=DEFAULT_KEEP_INPUT_FILES; end; - PrinterId:=-1; + PrinterName:=''; end else begin @@ -873,7 +873,7 @@ procedure TConfigForm.ReadConfig; IgnoreEmptyFiles:=DEFAULT_IGNORE_EMPTY_FILES; KeepInputFiles:=DEFAULT_KEEP_INPUT_FILES; SpecialSettings:=DEFAULT_SPECIAL_SETTINGS; - PrinterId:=-1; + PrinterName:=''; end; finally CloseKey; diff --git a/source/MainFormUnit.pas b/source/MainFormUnit.pas index e1c443c..3c8feec 100644 --- a/source/MainFormUnit.pas +++ b/source/MainFormUnit.pas @@ -409,6 +409,10 @@ function TMainForm.ProcessFile; SrcCodePage : TCodePage; OwnNLSCodePage :TCodePage; fattr : Integer; + PrinterId : Integer; + Device, Driver, Port: array[0..255] of Char; + DevMode: THandle; + CurrentPrinterName: string; Header : Record FileHeader : tBitmapFileHeader; @@ -426,13 +430,13 @@ function TMainForm.ProcessFile; result:=true; try InputFileName:=ConfigForm.ConfigData.InputFilesDir+SearchRec.Name; - + if ConfigForm.ConfigData.KeepInputFiles then begin GetSystemTime(NowSystemTime); TmpFileName:=ChangeFileExt(InputFileName,'.tmp~'+IntToStr(SystemTimeToInt64(NowSystemTime) div 1000000)); //w setkach milisekund end - else begin + else begin TmpFileName:=ChangeFileExt(InputFileName,'.tmp~'); end; if FileExists(TmpFileName) then DeleteFile(TmpFileName); @@ -455,13 +459,13 @@ function TMainForm.ProcessFile; begin //krytyczny blad podczas tworzenia pliku spoolera - zakoncz aplikacje MustExit:=true; - raise EInOutError.Create(RString(506)); + raise EInOutError.Create(RString(506)); end else CloseHandle(HandleToFile); end; InputFileName := TmpFileName; end; - + TempConfigData:=ConfigForm.ConfigData; if TempConfigData.EnableFormatting then @@ -573,13 +577,27 @@ function TMainForm.ProcessFile; kopii := TempConfigData.NumberOfCopies; if kopii<1 then kopii:=1 else if kopii>99 then kopii:=99; + + Printer.Refresh; //odswiez zainstalowane drukarki + if Printer.Printers.Count=0 then kopii:=0 //brak drukarek + else if TempConfigData.PrinterName = '' then begin //domyslna + Printer.PrinterIndex:= -1; //ustaw drukarke domyslna + Printer.GetPrinter(Device, Driver, Port, DevMode); //pobierz ustawienia by sprawdzic czy istnieje domyslna + CurrentPrinterName := Device; //konwersja typow + if CurrentPrinterName='' then kopii:=0; //nie ma ustawionej drukarki domyslnej wiec nic nie drukuj + end else begin //nie domyslna wiec szuka id + for PrinterId:=0 to Printer.Printers.Count - 1 do + if CompareText(printer.Printers.Strings[PrinterId], TempConfigData.PrinterName)=0 then break; //znalazlo drukarke + if PrinterId>=Printer.Printers.Count then kopii:=0 //nie znalazlo wiec nic nie drukuj + else Printer.PrinterIndex:= PrinterId; //ustaw drukarke + end; + while (kopii>0) do begin try //procedure drukujaca StringList PrintStrings('Dokument programu '+PROGRAMNAME+' - '+SearchRec.Name, StringList, CodePageInfo[SrcCodePage].CpNr, - TempConfigData.PrinterId, cMILTOINCH*TempConfigData.MarginLeft, cMILTOINCH*TempConfigData.MarginRight, cMILTOINCH*TempConfigData.MarginTop, diff --git a/source/PrintStringsUnit.pas b/source/PrintStringsUnit.pas index 0946f4d..0c00bed 100644 --- a/source/PrintStringsUnit.pas +++ b/source/PrintStringsUnit.pas @@ -113,7 +113,6 @@ interface function PrintStrings(Title: string; srclines: TStrings; const CpNr: integer; - const PrinterId: integer; const leftmargin,rightmargin,topmargin,bottommargin: single; const orientation: TPrinterOrientation; const linesPerInch: single; @@ -138,7 +137,6 @@ implementation function PrintStrings(Title: string; srclines: TStrings; const CpNr: integer; - const PrinterId: integer; const leftmargin,rightmargin,topmargin,bottommargin: single; const orientation: TPrinterOrientation; const linesPerInch: single; @@ -761,9 +759,6 @@ function PrintStrings(Title: string; pagecount := 0; textstart := 0; -// Printer.Refresh; //odswiez zainstalowane drukarki -// Printer.PrinterIndex:=-1; //wybierz domyslna drukarke - Printer.PrinterIndex:= PrinterId; Printer.GetPrinter(Device, Driver, Port, DevMode); //przeladuj ustawienia drukarki by poprawnie wczytalo wielkosc strony itp Printer.SetPrinter(Device, Driver, Port, 0); Printer.Copies:= 1;