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 : 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
 
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