123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- unit ubarcodeform;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, StBarC, ExtCtrls, ComCtrls, Typinfo;
- type
- TfmBarCodeForm = class(TForm)
- pnTop: TPanel;
- StBarCode1: TStBarCode;
- pnBottom: TPanel;
- sb: TStatusBar;
- pnB1: TPanel;
- lbValue: TLabel;
- edValue: TEdit;
- pnB2: TPanel;
- lbSize: TLabel;
- edSize: TEdit;
- udBarWidth: TUpDown;
- pnB3: TPanel;
- lbFormat: TLabel;
- coBarCodeType: TComboBox;
- coCode128Subsets: TComboBox;
- pnB4: TPanel;
- cbShowCode: TCheckBox;
- cbAddCheckChar: TCheckBox;
- pnBLast: TPanel;
- Button1: TButton;
- Label1: TLabel;
- edFontSize: TEdit;
- udFotnSize: TUpDown;
- procedure Button1Click(Sender: TObject);
- procedure edValueChange(Sender: TObject);
- procedure cbShowCodeClick(Sender: TObject);
- procedure edSizeChange(Sender: TObject);
- procedure FormResize(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure coBarCodeTypeChange(Sender: TObject);
- procedure cbAddCheckCharClick(Sender: TObject);
- procedure coCode128SubsetsChange(Sender: TObject);
- procedure edFontSizeChange(Sender: TObject);
- private
- { Déclarations privées }
- name : String;
- version : String;
- procedure buildBarCodeTypes();
- procedure buildCode128Subsets();
- public
- { Déclarations publiques }
- end;
- var
- fmBarCodeForm: TfmBarCodeForm;
- implementation
- uses StrUtils;
- {$R *.dfm}
- procedure TfmBarCodeForm.Button1Click(Sender: TObject);
- begin
- StBarCode1.CopyToClipboard ;
- end;
- procedure TfmBarCodeForm.edValueChange(Sender: TObject);
- var s : String;
- begin
- s := edValue.Text;
- {
- if (coBarCodeType.ItemIndex = ord(bcEAN_13))
- and (length (s) < 12) or (length(s) > 13) then
- begin
- s := '';
- end;
- }
- StBarCode1.Code := s;
- end;
- procedure TfmBarCodeForm.cbShowCodeClick(Sender: TObject);
- begin
- StBarCode1.ShowCode := (sender as TCheckBox).Checked;
- end;
- procedure TfmBarCodeForm.edSizeChange(Sender: TObject);
- begin
- StBarCode1.BarWidth := StrToFloat((sender as TEdit).Text);
- end;
- procedure TfmBarCodeForm.FormResize(Sender: TObject);
- begin
- self.Caption := self.name + ' - '
- + IntToStr(StBarCode1.Width) + 'x' + IntToStr(StBarCode1.Height);
- end;
- procedure TfmBarCodeForm.coBarCodeTypeChange(Sender: TObject);
- var this : TComboBox;
- begin
- this := sender as TComboBox;
- sb.SimpleText := 'Selected ' + IntToStr(this.ItemIndex);
- coCode128Subsets.Visible := this.ItemIndex = ord(bcCode128);
- StBarCode1.BarCodeType := TStBarCodeType(this.ItemIndex);
- end;
- procedure TfmBarCodeForm.buildBarCodeTypes();
- var i : Integer;
- s : String;
- begin
- for i := ord(low(TstBarCodeType)) to ord(high(TstBarCodeType)) do
- begin
- s := getEnumName(typeInfo(TStBarCodeType), i);
- s := Midstr(s, 3, 100);
- coBarCodeType.Items.Add(s);
- end;
- coBarCodeType.ItemIndex := ord(bcCode39);
- StBarCode1.BarCodeType := bcCode39;
- end;
- procedure TfmBarCodeForm.buildCode128Subsets();
- var i : Integer;
- s : String;
- begin
- for i := ord(low(TStCode128CodeSubset)) to ord(high(TStCode128CodeSubset)) do
- begin
- s := getEnumName(typeInfo(TStCode128CodeSubset), i);
- s := Midstr(s, 3, 100);
- coCode128Subsets.Items.Add(s);
- end;
- coCode128Subsets.ItemIndex := ord(csCodeA);
- coCode128Subsets.Visible := FALSE;
- end;
- procedure TfmBarCodeForm.FormCreate(Sender: TObject);
- begin
- self.version := '$Id: ubarcodeform.pas,v 1.2 2009-04-16 13:30:36 marand Exp $';
- self.name := 'OSInet barcode generator';
- sb.SimplePanel := True;
- sb.SimpleText := self.name + ' - ' + self.version;
- buildBarCodeTypes;
- buildCode128Subsets;
- end;
- procedure TfmBarCodeForm.cbAddCheckCharClick(Sender: TObject);
- begin
- StBarCode1.AddCheckChar := (sender as TCheckBox).Checked;
- end;
- procedure TfmBarCodeForm.coCode128SubsetsChange(Sender: TObject);
- begin
- StBarCode1.Code128Subset := TStCode128CodeSubset((sender as TComboBox).ItemIndex);
- end;
- procedure TfmBarCodeForm.edFontSizeChange(Sender: TObject);
- begin
- StBarCode1.Font.Size := StrToInt(edFontSize.Text);
- end;
- end.
|