Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 217853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:41:47+00:00 2026-05-11T18:41:47+00:00

I have TPanel. On this Panel there is an TImage descendant , few other

  • 0

I have TPanel. On this Panel there is an TImage descendant , few other panels with controls, etc. In fact, picture contains some diagram, while additional panels with labels are created during runtime to provide user with additional info.
Recently I was told, that it would be nice, if it was possible to print this panel, and have it on the paper just as it appears in form. Any clues, how to do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:41:47+00:00Added an answer on May 11, 2026 at 6:41 pm

    I found an old usenet post that provides a solution, by copying the contents of the panel to a bitmap, which can be printed:

    procedure TFormPrintWindows.ButtonPrintPanelClick(Sender: TObject);
      var
        Bitmap       :  TBitmap;
        FromLeft     :  INTEGER;
        FromTop      :  INTEGER;
        PrintedWidth :  INTEGER;
        PrintedHeight:  INTEGER;
    begin
      Printer.BeginDoc;
      TRY
        Bitmap := TBitmap.Create;
        TRY
          Bitmap.Width  := Panel1.Width;
          Bitmap.Height := Panel1.Height;
          Bitmap.PixelFormat := pf24bit;  // avoid palettes
    
          // Copy the Panel area from the Form into a separate Bitmap
          Bitmap.Canvas.CopyRect(Rect(0,0, Bitmap.Width,Bitmap.Height),
                                 FormPrintWindows.Canvas,
                                 Rect(Panel1.Left, Panel1.Top,
                                      Panel1.Left + Panel1.Width-1,
                                      Panel1.Top  + Panel1.Height-1) );
    
          // Assumes 10% left, right and top margin
          // Assumes bitmap aspect ratio > ~0.75 for portrait mode
          PrintedWidth  := MulDiv(Printer.PageWidth, 80,100);  // 80%
          PrintedHeight := MulDiv(PrintedWidth, Bitmap.Height, Bitmap.Width);
          FromLeft      := MulDiv(Printer.PageWidth, 10,100);  // 10%
          FromTop       := MulDiv(Printer.PageHeight,10,100);  // 10%
    
          PrintBitmap(Printer.Canvas,
            Rect(FromLeft, FromTop,
                 FromLeft + PrintedWidth,
                 FromTop  + PrintedHeight),
            Bitmap);
        FINALLY
          Bitmap.Free
        END;
      FINALLY
        Printer.EndDoc
      END
    
    end;
    

    and add

    //Source of Code: 
    //http://www.swissdelphicenter.ch/torry/showcode.php?id=744
    //Which refers to a posting to borland.public.delphi.winapi by Rodney E Geraghty, 8/8/97.
    
    procedure PrintBitmap(Canvas: TCanvas; DestRect: TRect; Bitmap: TBitmap);
    var
      BitmapHeader: pBitmapInfo;
      BitmapImage: Pointer;
      HeaderSize: DWORD;
      ImageSize: DWORD;
    begin
      GetDIBSizes(Bitmap.Handle, HeaderSize, ImageSize);
      GetMem(BitmapHeader, HeaderSize);
      GetMem(BitmapImage, ImageSize);
      try
        GetDIB(Bitmap.Handle, Bitmap.Palette, BitmapHeader^, BitmapImage^);
        StretchDIBits(Canvas.Handle,
          DestRect.Left, DestRect.Top,    // Destination Origin
          DestRect.Right - DestRect.Left, // Destination Width
          DestRect.Bottom - DestRect.Top, // Destination Height
          0, 0,                           // Source Origin
          Bitmap.Width, Bitmap.Height,    // Source Width & Height
          BitmapImage,
          TBitmapInfo(BitmapHeader^),
          DIB_RGB_COLORS,
          SRCCOPY)
      finally
        FreeMem(BitmapHeader);
        FreeMem(BitmapImage)
      end
    end {PrintBitmap};
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Delphi 2007 VCL TPanel with a TPopupMenu assigned to it. There
I have a TabControl, and I am using a TPanel to group my controls
There are several third-pary controls (such as the Raize Components ) which have a
I have a TGraphicControl descendant which paints rather slowly. There's also a TWinControl descendant,
I need to draw on a TPanel, ideally directly so I don't have another
have written this little class, which generates a UUID every time an object of
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
This is a continuation of a previous post: TPanel color is black no matter
have tables like this Table checklist idCardno name permAddress datetime Table persons name idcardno
have Googled the cr*p out of this one so apologies if the answer is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.