mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Renovate print dialog:
- Fix displaying generated checkboxes in hidden area by adjusting the form's height after generating the checkboxes. - Apply 8px margins on all edges - Replace printer bitmap by clearer TLabel saying "Select printer" - Sanitize component names - Rely on ModalResult of buttons and save a btnCancelClick procedure
This commit is contained in:
@ -3,7 +3,7 @@ object printlistForm: TprintlistForm
|
||||
Top = 91
|
||||
BorderStyle = bsDialog
|
||||
Caption = 'Print List...'
|
||||
ClientHeight = 271
|
||||
ClientHeight = 115
|
||||
ClientWidth = 377
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
@ -16,84 +16,42 @@ object printlistForm: TprintlistForm
|
||||
OnShow = FormShow
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object Image1: TImage
|
||||
Left = 17
|
||||
Top = 25
|
||||
Width = 17
|
||||
Height = 17
|
||||
Picture.Data = {
|
||||
07544269746D617036050000424D360500000000000036040000280000001000
|
||||
0000100000000100080000000000000100000000000000000000000100000001
|
||||
0000000000000000330000006600000099000000CC000000FF00003300000033
|
||||
330000336600003399000033CC000033FF000066000000663300006666000066
|
||||
99000066CC000066FF00009900000099330000996600009999000099CC000099
|
||||
FF0000CC000000CC330000CC660000CC990000CCCC0000CCFF0000FF000000FF
|
||||
330000FF660000FF990000FFCC0000FFFF003300000033003300330066003300
|
||||
99003300CC003300FF00333300003333330033336600333399003333CC003333
|
||||
FF00336600003366330033666600336699003366CC003366FF00339900003399
|
||||
330033996600339999003399CC003399FF0033CC000033CC330033CC660033CC
|
||||
990033CCCC0033CCFF0033FF000033FF330033FF660033FF990033FFCC0033FF
|
||||
FF00660000006600330066006600660099006600CC006600FF00663300006633
|
||||
330066336600663399006633CC006633FF006666000066663300666666006666
|
||||
99006666CC006666FF00669900006699330066996600669999006699CC006699
|
||||
FF0066CC000066CC330066CC660066CC990066CCCC0066CCFF0066FF000066FF
|
||||
330066FF660066FF990066FFCC0066FFFF009900000099003300990066009900
|
||||
99009900CC009900FF00993300009933330099336600993399009933CC009933
|
||||
FF00996600009966330099666600996699009966CC009966FF00999900009999
|
||||
330099996600999999009999CC009999FF0099CC000099CC330099CC660099CC
|
||||
990099CCCC0099CCFF0099FF000099FF330099FF660099FF990099FFCC0099FF
|
||||
FF00CC000000CC003300CC006600CC009900CC00CC00CC00FF00CC330000CC33
|
||||
3300CC336600CC339900CC33CC00CC33FF00CC660000CC663300CC666600CC66
|
||||
9900CC66CC00CC66FF00CC990000CC993300CC996600CC999900CC99CC00CC99
|
||||
FF00CCCC0000CCCC3300CCCC6600CCCC9900CCCCCC00CCCCFF00CCFF0000CCFF
|
||||
3300CCFF6600CCFF9900CCFFCC00CCFFFF00FF000000FF003300FF006600FF00
|
||||
9900FF00CC00FF00FF00FF330000FF333300FF336600FF339900FF33CC00FF33
|
||||
FF00FF660000FF663300FF666600FF669900FF66CC00FF66FF00FF990000FF99
|
||||
3300FF996600FF999900FF99CC00FF99FF00FFCC0000FFCC3300FFCC6600FFCC
|
||||
9900FFCCCC00FFCCFF00FFFF0000FFFF3300FFFF6600FFFF9900FFFFCC00FFFF
|
||||
FF00000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
00009B9B9B9B9B9B0000009B9B9B9B9B9B9B9B9B9B9B0000AC818100009B9B9B
|
||||
9B9B9B9B0000ACAC560000815600009B9B9B9B00ACAC5656AC81810000815600
|
||||
009B9B815656ACACAC81818181000056009B8156ACACACACAC81818181818100
|
||||
009B81D7ACACACACD781818181815681560081D7ACACD7D7ACACAC8181818156
|
||||
560081D7D7D7ACAC0528ACACAC818181560081D7ACAC1E14ACACAC568100AC56
|
||||
56009B8181D7ACACAC8156ACAC00AC56569B9B9B9B8181D756ACACACD7AC009B
|
||||
9B9B9B9B9B9B9B8181ACACD7D7D7AC009B9B9B9B9B9B9B9B9B81D7D7D7D7D7AC
|
||||
00009B9B9B9B9B9B9B9B81D7D7D781819B9B9B9B9B9B9B9B9B9B9B8181819B9B
|
||||
9B9B}
|
||||
Transparent = True
|
||||
object lblSelect: TLabel
|
||||
Left = 8
|
||||
Top = 11
|
||||
Width = 68
|
||||
Height = 13
|
||||
Caption = '&Select printer:'
|
||||
FocusControl = comboPrinters
|
||||
end
|
||||
object ComboBoxPrinters: TComboBox
|
||||
Left = 40
|
||||
Top = 24
|
||||
Width = 233
|
||||
object comboPrinters: TComboBox
|
||||
Left = 82
|
||||
Top = 8
|
||||
Width = 206
|
||||
Height = 21
|
||||
Style = csDropDownList
|
||||
ItemHeight = 13
|
||||
TabOrder = 0
|
||||
OnChange = ComboBoxPrintersChange
|
||||
OnChange = comboPrintersChange
|
||||
end
|
||||
object Button1: TButton
|
||||
Left = 288
|
||||
Top = 23
|
||||
object btnConfigure: TButton
|
||||
Left = 294
|
||||
Top = 8
|
||||
Width = 75
|
||||
Height = 25
|
||||
Caption = 'Configure'
|
||||
TabOrder = 1
|
||||
OnClick = Button1Click
|
||||
OnClick = btnConfigureClick
|
||||
end
|
||||
object GroupBox1: TGroupBox
|
||||
Left = 16
|
||||
Top = 72
|
||||
Width = 257
|
||||
Height = 185
|
||||
object boxColumns: TGroupBox
|
||||
Left = 8
|
||||
Top = 39
|
||||
Width = 280
|
||||
Height = 68
|
||||
Anchors = [akLeft, akTop, akRight, akBottom]
|
||||
Caption = 'Print what...'
|
||||
TabOrder = 2
|
||||
object CheckBox1: TCheckBox
|
||||
object chkAllColumns: TCheckBox
|
||||
Left = 16
|
||||
Top = 24
|
||||
Width = 97
|
||||
@ -102,33 +60,34 @@ object printlistForm: TprintlistForm
|
||||
Checked = True
|
||||
State = cbChecked
|
||||
TabOrder = 0
|
||||
OnClick = CheckBox1Click
|
||||
OnClick = chkAllColumnsClick
|
||||
end
|
||||
end
|
||||
object Button2: TButton
|
||||
Left = 288
|
||||
Top = 232
|
||||
object btnCancel: TButton
|
||||
Left = 294
|
||||
Top = 82
|
||||
Width = 75
|
||||
Height = 25
|
||||
Anchors = [akRight, akBottom]
|
||||
Cancel = True
|
||||
Caption = 'Cancel'
|
||||
ModalResult = 2
|
||||
TabOrder = 4
|
||||
OnClick = Button2Click
|
||||
end
|
||||
object Button3: TButton
|
||||
Left = 288
|
||||
Top = 200
|
||||
object btnPrint: TButton
|
||||
Left = 294
|
||||
Top = 50
|
||||
Width = 75
|
||||
Height = 25
|
||||
Anchors = [akRight, akBottom]
|
||||
Caption = 'Print'
|
||||
Default = True
|
||||
ModalResult = 1
|
||||
TabOrder = 3
|
||||
OnClick = Button3Click
|
||||
OnClick = btnPrintClick
|
||||
end
|
||||
object PrinterSetupDialog1: TPrinterSetupDialog
|
||||
Left = 288
|
||||
object PrinterSetup: TPrinterSetupDialog
|
||||
Left = 216
|
||||
Top = 56
|
||||
end
|
||||
end
|
||||
|
@ -10,24 +10,23 @@ interface
|
||||
|
||||
uses
|
||||
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
||||
StdCtrls, printers, comctrls, ExtCtrls, VirtualTrees;
|
||||
StdCtrls, printers, comctrls, ExtCtrls, VirtualTrees, Math;
|
||||
|
||||
type
|
||||
TprintlistForm = class(TForm)
|
||||
ComboBoxPrinters: TComboBox;
|
||||
Button1: TButton;
|
||||
GroupBox1: TGroupBox;
|
||||
Button2: TButton;
|
||||
Button3: TButton;
|
||||
PrinterSetupDialog1: TPrinterSetupDialog;
|
||||
CheckBox1: TCheckBox;
|
||||
Image1: TImage;
|
||||
comboPrinters: TComboBox;
|
||||
btnConfigure: TButton;
|
||||
boxColumns: TGroupBox;
|
||||
btnCancel: TButton;
|
||||
btnPrint: TButton;
|
||||
PrinterSetup: TPrinterSetupDialog;
|
||||
chkAllColumns: TCheckBox;
|
||||
lblSelect: TLabel;
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure Button2Click(Sender: TObject);
|
||||
procedure Button3Click(Sender: TObject);
|
||||
procedure CheckBox1Click(Sender: TObject);
|
||||
procedure ComboBoxPrintersChange(Sender: TObject);
|
||||
procedure btnConfigureClick(Sender: TObject);
|
||||
procedure btnPrintClick(Sender: TObject);
|
||||
procedure chkAllColumnsClick(Sender: TObject);
|
||||
procedure comboPrintersChange(Sender: TObject);
|
||||
private
|
||||
list : TVirtualStringTree;
|
||||
title : String;
|
||||
@ -61,13 +60,16 @@ end;
|
||||
|
||||
procedure TprintlistForm.FormShow(Sender: TObject);
|
||||
var
|
||||
i,t : Integer;
|
||||
i, chkTop, chkCount : Integer;
|
||||
cwin : TMDIChild;
|
||||
chk : TCheckBox;
|
||||
const
|
||||
chkHeight = 23;
|
||||
begin
|
||||
// show!
|
||||
Screen.Cursor := crHourGlass;
|
||||
ComboBoxPrinters.Items := Printer.printers;
|
||||
ComboBoxPrinters.ItemIndex := Printer.printerIndex;
|
||||
comboPrinters.Items := Printer.printers;
|
||||
comboPrinters.ItemIndex := Printer.printerIndex;
|
||||
|
||||
cwin := Mainform.ChildWin;
|
||||
|
||||
@ -91,42 +93,45 @@ begin
|
||||
|
||||
|
||||
// add one CheckBox per list-column
|
||||
t := 2;
|
||||
CheckBox1.Checked := true;
|
||||
for i:=0 to list.Header.Columns.count-1 do begin
|
||||
with TCheckBox.Create(self) do begin
|
||||
parent := GroupBox1;
|
||||
Caption := list.Header.Columns[i].Text;
|
||||
checked := true;
|
||||
enabled := false;
|
||||
if i mod 2 = 0 then begin
|
||||
inc(t);
|
||||
left := 16;
|
||||
end
|
||||
else
|
||||
left := 130;
|
||||
top := t * 23;
|
||||
tag := 1;
|
||||
end;
|
||||
chkTop := 2;
|
||||
chkCount := 0;
|
||||
chkAllColumns.Checked := True;
|
||||
for i:=0 to list.Header.Columns.count-1 do
|
||||
begin
|
||||
// Skip hidden columns
|
||||
if not (coVisible in list.Header.Columns[i].Options) then
|
||||
continue;
|
||||
|
||||
chk := TCheckBox.Create(self);
|
||||
chk.Parent := boxColumns;
|
||||
chk.Caption := list.Header.Columns[i].Text;
|
||||
chk.Checked := True;
|
||||
chk.Enabled := False;
|
||||
if chkCount mod 2 = 0 then begin
|
||||
inc(chkTop);
|
||||
chk.Left := 16;
|
||||
end else
|
||||
chk.Left := 130;
|
||||
chk.Top := chkTop * chkHeight;
|
||||
chk.Tag := 1;
|
||||
inc(chkCount);
|
||||
end;
|
||||
Height := boxColumns.Top
|
||||
+ (3 * chkHeight) // "All columns checkbox + space
|
||||
+ (Height - boxColumns.Top - boxColumns.Height) // Bottom rest
|
||||
+ (Ceil(chkCount/2) * chkHeight); // Height of generated checkboxes
|
||||
Screen.Cursor := crDefault;
|
||||
end;
|
||||
|
||||
procedure TprintlistForm.Button1Click(Sender: TObject);
|
||||
procedure TprintlistForm.btnConfigureClick(Sender: TObject);
|
||||
begin
|
||||
Screen.Cursor := crHourglass;
|
||||
printerSetupDialog1.Execute;
|
||||
ComboBoxPrinters.ItemIndex := Printer.PrinterIndex;
|
||||
printerSetup.Execute;
|
||||
comboPrinters.ItemIndex := Printer.PrinterIndex;
|
||||
Screen.Cursor := crDefault;
|
||||
end;
|
||||
|
||||
procedure TprintlistForm.Button2Click(Sender: TObject);
|
||||
begin
|
||||
close;
|
||||
end;
|
||||
|
||||
|
||||
procedure TprintlistForm.Button3Click(Sender: TObject);
|
||||
procedure TprintlistForm.btnPrintClick(Sender: TObject);
|
||||
var
|
||||
lspace, rspace, i, j, k, limiter, breite, hoehe, colwidth : Integer;
|
||||
Cols : TStringList;
|
||||
@ -216,30 +221,31 @@ begin
|
||||
end;
|
||||
Printer.EndDoc;
|
||||
Screen.Cursor := crDefault;
|
||||
close;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TprintlistForm.CheckBox1Click(Sender: TObject);
|
||||
procedure TprintlistForm.chkAllColumnsClick(Sender: TObject);
|
||||
var i : Integer;
|
||||
begin
|
||||
// toggle checkboxes-enabled
|
||||
for i:=ComponentCount-1 downto 0 do begin
|
||||
if Components[i].tag = 1 then begin
|
||||
(Components[i] as TCheckBox).enabled := not CheckBox1.checked;
|
||||
if CheckBox1.checked then
|
||||
(Components[i] as TCheckBox).checked := true;
|
||||
for i:=ComponentCount-1 downto 0 do
|
||||
begin
|
||||
if Components[i].tag = 1 then
|
||||
begin
|
||||
(Components[i] as TCheckBox).enabled := not chkAllColumns.checked;
|
||||
if chkAllColumns.Checked then
|
||||
(Components[i] as TCheckBox).Checked := true;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TprintlistForm.ComboBoxPrintersChange(Sender: TObject);
|
||||
procedure TprintlistForm.comboPrintersChange(Sender: TObject);
|
||||
begin
|
||||
// chose printer
|
||||
Screen.Cursor := crHourglass;
|
||||
Printer.PrinterIndex := ComboBoxPrinters.ItemIndex;
|
||||
Printer.PrinterIndex := comboPrinters.ItemIndex;
|
||||
Screen.Cursor := crDefault;
|
||||
end;
|
||||
|
||||
|
Reference in New Issue
Block a user