Bonjour,
Je suis sous linux fedora 16 et cherche à comprendre comment dialoguer dans une application avec une imprimante pour cela, je cherche à comprendre comment fonctionne l'exemple du composant printers/samples/dialog/selectprinter.lpi et son unité frmselprinter.pas dont ci-dessous la partie que je cherche à analyser.

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
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]);
      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;
et plus particulièrement la partie extraite ci-dessous

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
AddInfo('Printer',Printers[PrinterIndex]);
      case Orientation of
        poPortrait : AddInfo('Orientation','Portrait');
        poLandscape : AddInfo('Orientation','Landscape');
        poReverseLandscape : AddInfo('Orientation','ReverseLandscape');
        poReversePortrait  :AddInfo('Orientation','ReversePortrait');
      end;
Cette section fait appel en premier à l'unité Printers pour la première ligne j'arrive à afficher dans un Edit.Text sur l'unité appelante la valeur du résultat de Printers[PrinterIndex] qui est une variable de type Stringm.
Mais si j'ai compris que la ligne Case Orientation of appel aussi l'unité Printers je n'arrive
pas à lire la valeur de résultat dans l'unité appelante sauf erreur celle-ci est de type TPrinterOrientation.
Comment afficher de résultat dans un Edit.Text
et autre question en cherchant les info de l'unité TPrinter je trouve un type déclaré en virtual comment lire ou afficher ce type de données dans une fiche.
Merci d'avane