Eine aufbereitete Darstellung der Quelle

 
     
 
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung


Quelle  PrintDialogEx.pas   Sprache: Delphi

 

unit PrintDialogEx;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
interface
uses
  //----------------------------------------------------------------------------
  //
  //----------------------------------------------------------------------------
  language,Utilities,
  //----------------------------------------------------------------------------
  //
  //----------------------------------------------------------------------------
  Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,
  ExtDlgs,extctrls,stdctrls,CommDlg,Dlgs,Strutils,Menus;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
type
  { TPrintDialogEx }
  TPrintDialogEx= class(TPrintDialog)
  private
    FExtendedPanel:TPanel;
    FComboBox:TComboBox;
    FComboBoxVisible:Boolean;
    FComboBoxEnabled:Boolean;
    FComboBoxItem:TStringlist;
    FComboBoxIndex:Integer;
    procedure FComboBoxChange(Sender:TObject);
    procedure SetComboBoxItem(const Value:TStringlist);
  protected
    procedure DoShow;override;
    function GetStaticRect:TRect;
    function TaskModalDialog(DialogFunc:Pointer;var DialogData):Bool;override;
  public
    constructor Create(AOwner:TComponent);override;
    destructor Destroy;override;
    property ComboBoxIndex:Integer read FComboBoxIndex;
  published
    property ComboBoxVisible
      :Boolean read FComboBoxVisible write FComboBoxVisible;
    property ComboBoxEnabled
      :Boolean read FComboBoxEnabled write FComboBoxEnabled;
    property ComboBoxItem:TStringlist read FComboBoxItem write SetComboBoxItem;
  end;
  //----------------------------------------------------------------------------
  //
  //----------------------------------------------------------------------------
procedure Register;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
implementation
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
constructor TPrintDialogEx.Create(AOwner:TComponent);
begin
  inherited;
  FComboBoxVisible:=false;
  FComboBoxEnabled:=True;
  FComboBoxItem:=TStringlist.Create;
  FComboBoxItem.Add('All Pages');
  FComboBoxItem.Add('Odd Pages');
  FComboBoxItem.Add('Even Pages');
  FExtendedPanel:=TPanel.Create(self);
  with FExtendedPanel do begin
    Name:='';
    //Caption:='';
    SetBounds(0,0,169,200);//(204, 5, 169, 200);
    BevelOuter:=bvNone;
    BorderWidth:=6;
    TabOrder:=1;
    FComboBox:=TComboBox.Create(self);
    with FComboBox do begin
      Name:='ComboBox1';
      Text:='';
      SetBounds(2,7,180,28);
      Style:=csDropDownList;
      Parent:=FExtendedPanel;
    end;
  end;
  FComboBoxIndex:=0;
end;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
destructor TPrintDialogEx.Destroy;
begin
  FComboBoxItem.Free;
  FExtendedPanel.Free;
  inherited Free;
end;
//----------------------------------------------------------------------------
//
//the callback function  patch text for Labels
//
//----------------------------------------------------------------------------
function EnumProc(AHandle:HWND;Lines:TStrings):Boolean;stdcall;
var
  buf,Caption: Array [0..255] of char;
  CN:String;
  V:String;
  procedure settle(n:Integer;S:String);
  begin
    if V=S then begin
      CN:=trans(lang,n,S);
      if (n=200) and (lang=german) then  //Markierung
        CN:='Aktuelle Seite';
      SetWindowText(AHandle,pchar(CN));
    end;
  end;
begin
  result:=True;
  GetClassname(AHandle,buf,256);
  GetWindowText(AHandle,Caption,256);
  V:=Caption;
  settle(200,'&Markierung');
  settle(201,'Druckbereich');
  settle(202,'A&lles');
  settle(203,'&Seiten');
  settle(204,'&von:');
  settle(205,'&bis:');
  settle(206,'Exemplare');
  settle(207,'An&zahl Exemplare:');
  settle(208,'OK');
  settle(209,'Abbrechen');
  settle(210,'Standort:');
  settle(211,'Abbrechen');
  settle(212,'Drucker');
  settle(213,'&Name:');
  settle(214,'&Eigenschaften...');
  settle(215,'Status:');
  settle(216,'Bereit');
  settle(217,'Typ:');
  settle(218,'Kommentar:');
  settle(219,'S&ortieren');
  settle(220,'Drucken');
end;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
procedure TPrintDialogEx.DoShow;
var
  PreviewRect,StaticRect:TRect;
begin
  EnumChildWindows(Handle,@EnumProc,0);
  { Set preview area to entire dialog }
  GetClientRect(Handle,PreviewRect);
  StaticRect:=GetStaticRect;
  { Move extended area to right of static area }
  PreviewRect.Left:=StaticRect.Left;
  PreviewRect.Top:=StaticRect.Bottom;
  Inc(PreviewRect.Top,4);
  FExtendedPanel.BoundsRect:=PreviewRect;
  FExtendedPanel.ParentWindow:=Handle;
  FComboBox.Items.Assign(FComboBoxItem);
  with FComboBox do begin
    Enabled:=FComboBoxEnabled;
    Visible:=FComboBoxVisible;
    try
      ItemIndex:=FComboBoxIndex;
    except
      on Exception do
        ItemIndex:=0;
    end;
    OnChange:=FComboBoxChange;
  end;
  inherited DoShow;
end;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
procedure TPrintDialogEx.FComboBoxChange(Sender:TObject);
begin
  FComboBoxIndex:=FComboBox.ItemIndex;
end;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
function TPrintDialogEx.GetStaticRect:TRect;
begin
  if Handle<>0 then begin
    GetWindowRect(GetDlgItem(Handle,grp1),result);//print range group box
    MapWindowPoints(0,Handle,result,2);
  end
  else
    result:=Rect(0,0,0,0)
end;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
procedure TPrintDialogEx.SetComboBoxItem(const Value:TStringlist);
begin
  if Assigned(FComboBoxItem) then
    FComboBoxItem.Assign(Value)
  else
    FComboBoxItem:=Value;
end;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
function TPrintDialogEx.TaskModalDialog(DialogFunc:Pointer;var DialogData):Bool;
begin
  TPrintDlg(DialogData).Flags:=TPrintDlg(DialogData)
    .Flags or PD_ENABLESETUPTEMPLATE;
  TPrintDlg(DialogData).lpSetupTemplateName:=Template;
  result:= inherited TaskModalDialog(DialogFunc,DialogData);
end;
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
procedure Register;
begin
  RegisterComponents('LS',[TPrintDialogEx]);
end;
end.
//----------------------------------------------------------------------------
//Ende dieser Quelle
//----------------------------------------------------------------------------

Messung
CHZG
99979797

¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet am  2026-11-25) ¤

*© Formatika GbR, Deutschland







                                                                                                                                                                                                                                                                                                                                                                                                     

 

Neuigkeiten

Aktuelles
Motto des Tages

Open Source Software


Gedichte
Musik
Bilder

Jenseits des Üblichen

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1,188,838
#Domains=906,785