Précédent   Forum du club des développeurs et IT Pro > Autres langages > Pascal > Lazarus
Lazarus Forum d'entraide sur Lazarus, l'EDI RAD multiplateforme basé sur Free Pascal
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 17/11/2012, 11h43   #1
ovni76
Membre régulier
 
Homme Jean
Retraité
Inscription : juillet 2008
Messages : 222
Détails du profil
Informations personnelles :
Nom : Homme Jean
Localisation : France, Seine Maritime (Haute Normandie)

Informations professionnelles :
Activité : Retraité

Informations forums :
Inscription : juillet 2008
Messages : 222
Points : 97
Points : 97
Par défaut Lire la configuration d'une imprimante et la modifier

Bonjour,
Je suis linux et lazarus, après la découverte de lazreport et je cherche à pouvoir utiliser l'impression dans une application et donc de connaître la configuration d'une imprimante et de la changer si nécessaire toujours dans l'application en direct par des lignes de commandes.
J'ai essayé d'apprendre avec l'exemple dans lazarus "frmselprinter" mais je n'y arrive pas, avec une incompréhension sur le résultat de l'évaluation via Crt+F7.
Je copie l'extrait du programme et je m'explique
Code :
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
 
procedure TForm1.UpdatePrinterInfo;
begin
  try
    ck := SGrid.FixedRows;
    SGrid.Clean;
    with Printer do
    begin
      if Printers.Count=0 then
      begin
        AddInfo('printer', 'pas d''imprimante installée');
        exit;
      end;
      AddInfo('Printer',Printers[PrinterIndex]);
 
      Edit1.Text:=(Printers[PrinterIndex]);
      Edit2.Text:=IntToStr(Printer.PageWidth);
 
      case Orientation of
        poPortrait : AddInfo('Orientation','Portrait');
        poLandscape : AddInfo('Orientation','Landscape');
        poReverseLandscape : AddInfo('Orientation','ReverseLandscape');
        poReversePortrait  :AddInfo('Orientation','ReversePortrait');
      end;
      case PrinterType of
        ptLocal: AddInfo('PrinterType','Local');
        ptNetWork: AddInfo('PrinterType','Network');
      end;
      case PrinterState of
        psNoDefine: AddInfo('PrinterState','Undefined');
        psReady:AddInfo('PrinterState','Ready');
        psPrinting:AddInfo('PrinterState','Printing');
        psStopped:AddInfo('PrinterState','Stopped');
      end;
      AddInfo('Resolution X,Y',IntToStr(XDPI)+','+IntToStr(YDPI)+' dpi');
      AddInfo('PaperSize',PaperSize.PaperName);
      with Printer.PaperSize.PaperRect.PhysicalRect do
      begin
        AddInfo('Page Width', FormatDots(Right-Left));
        AddInfo('Page Height', FormatDots(Bottom-Top));
      end;
      AddInfo('Printable Width',FormatDots(PageWidth));
      AddInfo('Printable Height',FormatDots(PageHeight));
      AddInfo('Copies',IntToStr(Copies));
      if CanRenderCopies then
        AddInfo('CanRenderCopies','true')
      else
        AddInfo('CanRenderCopies','false');
 
      if not CanPrint then
        Application.MessageBox('Selected printer cannot print currently!',
          'Warning',mb_iconexclamation);
    end;
  except on E:Exception do
      Application.MessageBox(PChar(e.message),'Error',mb_iconhand);
  end;
end;
J'ai ajouté 2 Edit pour afficher les informations.

Première incompréhension :
Case Orientation pour moi normalement Orientation est une valeur qui devrait pouvoir être affiché dans l'évaluateur, mais non et toujours selon mon raisonnement la ligne
poPortrait : AddInfo('Orientation','Portrait'); de cette case et utilisée si la valeur d'Orientation est égale à poPortrait suis-je dans le vrai ou bien j'ai tout oublié ?

Deuxième incompréhension :
Je n'arrive pas à transmettre un changement d'orientation à l'imprimante ni un changement de taille imprimable.
Je peux le rélaiser en utilisant les composants Printer ou Print existants mais pas en ligne de commande dans mon application.
Alors comment faire ?
Merci d'avance pour votre aide
ovni76 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/11/2012, 13h07   #2
selzig
Membre émérite
 
Homme Gilles
Enseignant
Inscription : novembre 2006
Messages : 807
Détails du profil
Informations personnelles :
Nom : Homme Gilles
Âge : 54
Localisation : France, Calvados (Basse Normandie)

Informations professionnelles :
Activité : Enseignant

Informations forums :
Inscription : novembre 2006
Messages : 807
Points : 955
Points : 955
Bonjour Jean,

je vous conseille d'aller sur le site de Lazarus.freepascal.org et d'utiliser le lien Search avec le terme poPortrait (ou autres paramètres). Les comportements diffèrent d'un OS à l'autre et de plus, l'ordre de déclaration des paramètres influent sur le résultat.

Cordialement. Gilles
selzig est déconnecté   Envoyer un message privé Réponse avec citation 10
Réponse Cette discussion est résolue.
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 08h18.


 
 
 
 
Partenaires

Hébergement Web