Problème impression couleur

Résolu
kacola Messages postés 30 Date d'inscription jeudi 27 mai 2004 Statut Membre Dernière intervention 10 janvier 2008 - 21 nov. 2007 à 21:23
kacola Messages postés 30 Date d'inscription jeudi 27 mai 2004 Statut Membre Dernière intervention 10 janvier 2008 - 22 nov. 2007 à 16:49
Bonjour, j'ai une imprimante couleur Canon MP780 et une Laser N&B Canon (qui est par défaut),
Je souhaite imprimer une image (un jpeg) en couleur, mais voici mon problème:

Lorsque je mets la Canon MP780 par défaut, le code suivant imprime correctement en couleur:

procedure TForm1.Button1Click(Sender: TObject);
var  image_jpeg : TjpegImage;
begin
       image_jpeg := TjpegImage.Create;
       image_jpeg.LoadFromFile('C:\QCM\Images\image_0_Impression.jpg');
       printer.begindoc;
       Printer.Canvas.StretchDraw(Rect(0,0,3393,4886),image_jpeg);
       printer.Enddoc;



end;


Mais lorsque je mets la Laser par défaut et que j'ajoute 'printer.PrinterIndex: =3' qui est l'index de la MP780
le code suivant imprime uniquement en noir et blanc:

procedure TForm1.Button1Click(Sender: TObject);
var  image_jpeg : TjpegImage;
begin
       printer.PrinterIndex:=3;
       image_jpeg := TjpegImage.Create;
       image_jpeg.LoadFromFile('C:\QCM\Images\image_0_Impression.jpg');
       printer.begindoc;
       Printer.Canvas.StretchDraw(Rect(0,0,3393,4886),image_jpeg);
       printer.Enddoc;



end;



L'ajout de la ligne 'printer.PrinterIndex:=3' donne une impression en N&B.
J'ai absolument besoin d'avoir ma Laser en défaut et dimprimer en couleur sur la MP780

Config:
Windows Vista  (Ne marche pas non plus sous XP).
Delphi Turbo.
Canon MP780 (ce n'est pas l'imprimante, j'ai essayé sur une autre imprimante et sur un createur de pdf)

Merci beaucoup de toute aide.
Kacola.

2 réponses

bongenie Messages postés 15 Date d'inscription samedi 8 janvier 2005 Statut Membre Dernière intervention 28 octobre 2010
21 nov. 2007 à 23:55
Tu devrais trouver ton bonheur la dedans :


Commentaire de [auteur/SALIMDZ2004/310360.aspx salimdz2004] le 20/04/2007 03:23:57

[codes/CHANGER-IMPRIMANTE-DEFAUT-WINDOWS_12335.aspx# ] j'ai modifier le programme mnt il marche avec la Base de Registre

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, Inifiles;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    Label1: TLabel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    procedure FormCreate(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

  procedure Liste_Imprimante(Destino : TStrings);
  procedure Selectionne_Imprimante(Imprimante : String);

implementation
uses Registry;
{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
//
end;

procedure Liste_Imprimante(Destino : TStrings);
var
    RegCode             : TRegistry;
    Str                 : String;
    vtCount, i          : Integer;
begin
Destino.Clear;
RegCode := TRegistry.Create;
try
RegCode.RootKey := HKEY_CURRENT_USER;
if RegCode.OpenKey('Software\Microsoft\Windows NT\CurrentVersion\Devices',False)
then RegCode.GetValueNames(Destino);
finally
RegCode.CloseKey;
RegCode.Free;
end;
end;

procedure Selectionne_Imprimante(Imprimante : String);
var
    RegCode             : TRegistry;
    Str, Str1           : String;
    Arr_Tmp             : Array[0..64] of Char;
    vtCount, i          : Integer;
begin
RegCode := TRegistry.Create;
try
RegCode.RootKey := HKEY_CURRENT_USER;
if RegCode.OpenKey('Software\Microsoft\Windows NT\CurrentVersion\Devices',False)
then begin
     if RegCode.ValueExists(Imprimante)
     then begin
          Str1 := RegCode.ReadString(Imprimante);
          Str := Imprimante + ',' + Str1;
          RegCode.CloseKey;
          RegCode.RootKey := HKEY_CURRENT_USER;
          if RegCode.OpenKey('Software\Microsoft\Windows NT\CurrentVersion\Windows',False)
          then begin
               if RegCode.ValueExists('Device')
               then RegCode.WriteString('Device',Str);
               //Windows Refresh changes :
               StrCopy(Arr_Tmp, 'windows');
               SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, LongInt(@Arr_Tmp));
               end;
          end;
     end;
finally
RegCode.CloseKey;
RegCode.Free;
end;

end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
Liste_Imprimante(ListBox1.Items);
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
begin
if (ListBox1.ItemIndex <> -1)
then Selectionne_Imprimante(ListBox1.Items[ListBox1.ItemIndex]);
end;

end.
3
kacola Messages postés 30 Date d'inscription jeudi 27 mai 2004 Statut Membre Dernière intervention 10 janvier 2008
22 nov. 2007 à 16:49
Merci beaucoup, c'est exactement ce que j'attendais, un moyen de changer l'imprimante par defaut.
je vais pouvoir m'en sortir je pense, MERCI encore!!!

Kacola.
0
Rejoignez-nous