IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage Delphi Discussion :

Changer de bac imprimante...


Sujet :

Langage Delphi

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2002
    Messages
    131
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2002
    Messages : 131
    Points : 51
    Points
    51
    Par défaut Changer de bac imprimante...
    Bonjour,

    Avec delphi et quickreport, le paramètre OutPutBin pour selectionner le bac imprimante ne fonctionne pas !

    Y-a-t-il un autre moyen de choisir un bac impirmnante sous delphi ?

    Merci d'avance pour votre aide.. :-)

  2. #2
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Salut ,

    Je te propose 2 procedures.

    une pour obtenir les paramètres de ton imprimante et une pour les définir

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    procedure SetPrinterSettings(FPrinter: TPrinter;FormatdePapier,BacAlimentation,Orientation:smallint);
    var
      FDevice: PChar;
      FDriver: PChar;
      FPort: PChar;
      DeviceMode: THandle;
      DevMode: PDeviceMode;
    begin
      {pour obtenir les paramètres actuels}
     
      FPrinter.GetPrinter(FDevice, FDriver, FPort, DeviceMode);
      {lock de l'imprimante}
      DevMode := GlobalLock(DeviceMode);
     
      {Choix du type de papier}
      if FormatdePapier<>-1 then
      if ((DevMode^.dmFields and DM_PAPERSIZE) = DM_PAPERSIZE) then
      begin
        DevMode^.dmFields := DevMode^.dmFields or DM_PAPERSIZE;
        DevMode^.dmPaperSize := FormatdePapier;
      end;
     
      {Choix du bac d'alimentation}
      if BacAlimentation<>-1 then
      if  ((DevMode^.dmFields and DM_DEFAULTSOURCE) = DM_DEFAULTSOURCE) then
      begin
        DevMode^.dmFields := DevMode^.dmFields or DM_DEFAULTSOURCE;
        DevMode^.dmDefaultSource := BacAlimentation;
      end;
     
      {Orientation du papier}
      if Orientation<>-1 then
      if  ((DevMode^.dmFields and DM_ORIENTATION) = DM_ORIENTATION) then
      begin
        DevMode^.dmFields := DevMode^.dmFields or DM_ORIENTATION;
        DevMode^.dmOrientation := Orientation;
      end;
     
      {set a printer settings}
      FPrinter.SetPrinter(FDevice, FDriver, FPort, DeviceMode);
     
      {unlock de l'imprimante}
      GlobalUnlock(DeviceMode);
    end;
     
    procedure GetPrinterSettings(FPrinter: TPrinter;var FormatdePapier,BacAlimentation,Orientation:smallint);
    var
      FDevice: PChar;
      FDriver: PChar;
      FPort: PChar;
      DeviceMode: THandle;
      DevMode: PDeviceMode;
      Driver_Info2: PDriverInfo2;
      Retrieved: dword;
      hPrinter: THandle;
    begin
      //ouverture du pilote d'imprimante
      Printer.GetPrinter(FDevice, FDriver, FPort, DeviceMode);
      if DeviceMode = 0 then
        Printer.GetPrinter(FDevice, FDriver, FPort, DeviceMode);
      OpenPrinter(FDevice, hPrinter, nil);
      GetMem(Driver_Info2, 255);
      GetPrinterDriver(hPrinter, nil, 2, Driver_info_2, 255, Retrieved);
      StrLCopy(FDriver, PChar(ExtractFileName(StrPas(Driver_Info2^.PDriverPath)) + #0), 63);
      FreeMem(Driver_info_2, 255);
      //Lock de l'imprimante
      DevMode := GlobalLock(DeviceMode);
     
     
      //obtention des paramètres
      FormatdePapier:=-1;
      BacAlimentation:=-1;
      Orientation:=-1;
     
      if ((DevMode^.dmFields and DM_PAPERSIZE) = DM_PAPERSIZE) 
      then FormatdePapier:=DevMode^.dmPaperSize;
     
      if  ((DevMode^.dmFields and DM_DEFAULTSOURCE) = DM_DEFAULTSOURCE) 
      then BacAlimentation:=DevMode^.dmDefaultSource;
     
      if ((DevMode^.dmFields and DM_ORIENTATION) = DM_ORIENTATION) 
      then Orientation:=DevMode^.dmOrientation;
     
     
      GlobalUnlock(DeviceMode);
    end;

    Voici les paramètres que FormatdePapier,BacAlimentation et Orientation peuvent prendre :
    -1 (moins un) : dans le cas du GetPrinterSettings, celà signifie que l'imprimante ne peux pas te renvoyer les informations, dans le cas du Set celà signifie que tu ne veux pas changer ce paramètre.

    Pour FormatdePapier :
    Valeur Signification
    DMPAPER_LETTER Letter, 8 1/2- by 11-inches
    DMPAPER_LEGAL Legal, 8 1/2- by 14-inches
    DMPAPER_A4 A4 Sheet, 210- by 297-millimeters
    DMPAPER_CSHEET C Sheet, 17- by 22-inches
    DMPAPER_DSHEET D Sheet, 22- by 34-inches
    DMPAPER_ESHEET E Sheet, 34- by 44-inches
    DMPAPER_LETTERSMALL Letter Small, 8 1/2- by 11-inches
    DMPAPER_TABLOID Tabloid, 11- by 17-inches
    DMPAPER_LEDGER Ledger, 17- by 11-inches
    DMPAPER_STATEMENT Statement, 5 1/2- by 8 1/2-inches
    DMPAPER_EXECUTIVE Executive, 7 1/4- by 10 1/2-inches
    DMPAPER_A3 A3 sheet, 297- by 420-millimeters
    DMPAPER_A4SMALL A4 small sheet, 210- by 297-millimeters
    DMPAPER_A5 A5 sheet, 148- by 210-millimeters
    DMPAPER_B4 B4 sheet, 250- by 354-millimeters
    DMPAPER_B5 B5 sheet, 182- by 257-millimeter paper
    DMPAPER_FOLIO Folio, 8 1/2- by 13-inch paper
    DMPAPER_QUARTO Quarto, 215- by 275-millimeter paper
    DMPAPER_10X14 10- by 14-inch sheet
    DMPAPER_11X17 11- by 17-inch sheet
    DMPAPER_NOTE Note, 8 1/2- by 11-inches
    DMPAPER_ENV_9 #9 Envelope, 3 7/8- by 8 7/8-inches
    DMPAPER_ENV_10 #10 Envelope, 4 1/8- by 9 1/2-inches
    DMPAPER_ENV_11 #11 Envelope, 4 1/2- by 10 3/8-inches
    DMPAPER_ENV_12 #12 Envelope, 4 3/4- by 11-inches
    DMPAPER_ENV_14 #14 Envelope, 5- by 11 1/2-inches
    DMPAPER_ENV_DL DL Envelope, 110- by 220-millimeters
    DMPAPER_ENV_C5 C5 Envelope, 162- by 229-millimeters
    DMPAPER_ENV_C3 C3 Envelope, 324- by 458-millimeters
    DMPAPER_ENV_C4 C4 Envelope, 229- by 324-millimeters
    DMPAPER_ENV_C6 C6 Envelope, 114- by 162-millimeters
    DMPAPER_ENV_C65 C65 Envelope, 114- by 229-millimeters
    DMPAPER_ENV_B4 B4 Envelope, 250- by 353-millimeters
    DMPAPER_ENV_B5 B5 Envelope, 176- by 250-millimeters
    DMPAPER_ENV_B6 B6 Envelope, 176- by 125-millimeters
    DMPAPER_ENV_ITALY Italy Envelope, 110- by 230-millimeters
    DMPAPER_ENV_MONARCH Monarch Envelope, 3 7/8- by 7 1/2-inches
    DMPAPER_ENV_PERSONAL 6 3/4 Envelope, 3 5/8- by 6 1/2-inches
    DMPAPER_FANFOLD_US US Std Fanfold, 14 7/8- by 11-inches
    DMPAPER_FANFOLD_STD_GERMAN German Std Fanfold, 8 1/2- by 12-inches
    DMPAPER_FANFOLD_LGL_GERMAN German Legal Fanfold, 8 1/2- by 13-inches
    Pour BacAlimentation :
    DMBIN_UPPER
    DMBIN_FIRST
    DMBIN_ONLYONE
    DMBIN_LOWER
    DMBIN_MIDDLE
    DMBIN_MANUAL
    DMBIN_ENVELOPE
    DMBIN_ENVMANUAL
    DMBIN_AUTO
    DMBIN_TRACTOR
    DMBIN_SMALLFMT
    DMBIN_LARGEFMT
    DMBIN_LARGECAPACITY
    DMBIN_CASSETTE
    DMBIN_FORMSOURCE
    DMBIN_LAST
    Et pour Orientation :
    DMORIENT_PORTRAIT
    DMORIENT_LANDSCAPE
    Tu retrouveras toutes ces constantes dans le fichier Windows.pas de ton Delphi, ou bien dans l'aide de la SDK de Microsoft à la rubrique DEVMODE.

    Exemples pour choisir le bac d'alim, le format du papier, etc...:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    SetPrinterSettings(Printer,DMPAPER_A4_TRANSVERSE,DMBIN_TRACTOR,DMORIENT_LANDSCAPE);
    SetPrinterSettings(Printer,-1,DMBIN_LOWER,-1);
    SetPrinterSettings(Printer,-1,DMBIN_AUTO,-1);
    SetPrinterSettings(Printer,-1,DMBIN_MANUAL,DMORIENT_PORTRAIT);
    Bon dev
    Bidouilleuse Delphi

Discussions similaires

  1. Utilisation des bacs imprimantes
    Par verdurand dans le forum AS/400
    Réponses: 4
    Dernier message: 21/08/2007, 14h29
  2. Bac imprimante Excel
    Par AlAIN01 dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 02/09/2006, 11h24
  3. [C#] Choix bac imprimante
    Par JuJu° dans le forum Windows Forms
    Réponses: 2
    Dernier message: 28/07/2006, 17h45
  4. Changer de bacs de papier pour les impression
    Par Yphon dans le forum API, COM et SDKs
    Réponses: 1
    Dernier message: 21/01/2006, 20h31

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo