Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2001
    Messaggi
    145

    [Delphi 7] Stampare un frame

    Ciao a tutti!
    La mia applicazione ha un TreeView sulla sinistra mentre sulla destra c'è un frameset in cui carico certi frame in base a quallo che l'utente seleziona sul TreeView!
    Un frame è costituito da Label e TEdit che l'utente puo' compilare!
    Una volta che l'utente ha compilato il frame come posso stamparlo?
    In pratica vorrei stampare il frame coi dati immessi mantenendo le stesse distanze fra i vari componenti!

    grazieeeeeeeeeee!

    Ciaoooooooooo

  2. #2
    Moderatore di Programmazione L'avatar di alka
    Registrato dal
    Oct 2001
    residenza
    Reggio Emilia
    Messaggi
    24,466
    Io ho replicato il codice di stampa definito nella classe TForm all'interno di una classe derivata da TFrame; questo è il codice:
    codice:
    procedure TMyFrame.Print;
    var
      PageImage: TBitmap;
      Bits: HBITMAP;
      InfoSize, ImageSize: DWORD;
      Info: PBitmapInfo;
      Image: Pointer;
      dw, dh, pw, ph: Longint;
    begin
      Printer.BeginDoc;
      try
        PageImage := GetPageImage;
        try
          Bits := PageImage.Handle;
          GetDIBSizes(Bits, InfoSize, ImageSize);
          Info := AllocMem(InfoSize);
          try
            Image := AllocMem(ImageSize);
            try
              GetDIB(Bits, 0, Info^, Image^);
              with Info^.bmiHeader do
              begin
                dw := biWidth;
                dh := biHeight;
              end;
              case FPrintScale of
                poProportional:
                begin
                  pw := MulDiv(dw, GetDeviceCaps(Printer.Handle, LOGPIXELSX), 96);
                  ph := MulDiv(dh, GetDeviceCaps(Printer.Handle, LOGPIXELSY), 96);
                end;
                poPrintToFit:
                begin
                  pw := MulDiv(dw, Printer.PageHeight, dh);
                  if pw < Printer.PageWidth then
                    ph := Printer.PageHeight
                  else begin
                    pw := Printer.PageWidth;
                    ph := MulDiv(dh, Printer.PageWidth, dw);
                  end;
                end;
              else
                pw := dw;
                ph := dh;
              end;
              StretchDIBits(Printer.Canvas.Handle, 0, 0, pw, ph, 0, 0, dw, dh,
                Image, Info^, DIB_RGB_COLORS, SRCCOPY);
            finally
              FreeMem(Image, ImageSize);
            end;
          finally
            FreeMem(Info, InfoSize);
          end;
        finally
          PageImage.Free;
        end;
      finally
        Printer.EndDoc;
      end;
    end;
    MARCO BREVEGLIERI
    Software and Web Developer, Teacher and Consultant

    Home | Blog | Delphi Podcast | Twitch | Altro...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.