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

  • Home
  • SEARCH
  • 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 888569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:25:14+00:00 2026-05-15T13:25:14+00:00

I need to copy a form (Delphi 2007) to the clipboard as an image

  • 0

I need to copy a form (Delphi 2007) to the clipboard as an image to paste what the user can see into a word document. The clipboard part is not really a problem. The questions is how to get a bitmap for the form.

Searching has turned up multiple options.

  • Call GetFormImage
  • Use the PrintWindow API function that is part of the GDI+
  • Send a WM_PRINT message
  • Copy the Canvas for the current form using Canvas.CopyRect
  • I also found a component called TExcellentFormPrinter that has a solution that claims to works better than any of these options, but I don’t know what method it is using.

All of these options seem to have different problems. Most of the information I am finding seems to be outdated. I can’t seem any good source that compares the different options with enough detail for me to make a choice. Any advice on which option to go with.

I have tried these on my form and they all seem to work OK, I just trying to avoid problems down the road. Any advice on what solution to go with?

Update: What Potential Problems with GetFormImage?
Andreas asked what the problem is with GetFormImage. Hopefully nothing anymore, that is part of what I am trying to get an answer to. What has me concerned is so many of my search results seem to be suggesting creative alternatives to using GetFormImage. I was hoping the answers would clear up the waters a little bit.

I would be really happy with an answer that got a lot of up votes that said – GetFormImage used to have some problems but there is no reason not to use it now. 🙂

As to the actual problem with GetFormImage. One issue for some users was only the visible part of the form would appear in the image (i.e. you can’t capture a hidden or overlapped window). That is not really an issue for me as my entire form is visible.

1) The bigger issues deal with specific support required from the controls on your form. The Delphi 4 Fixes and Known issues page list has this entry (note it is listed as “Deferred to Next”). I could not find a QC entry that showed this resolved:

Area: vcl\core vcl classes

Reference Number: 1088 (Published: 12/16/98)
Status: Deferred to Next
Rel Date Reported: 8/6/98 Severity:
Commonly Encountered Type: Basic
Functionality Failure Problem:

The problem is with GetFormImage most nest windows controls like comboboxes, etc. are drawn blank.

2) I am also using the DevExpress controls. At one time their controls (fixed at the end of 2006) did not support the PaintTo messages that GetFormImage was using. This is fixed in the DevExpress release I am using, but it raises other issues with me, what is the chance that other control I am using may not work correctly?

3) Here is a more recent (2010) post on the Embarcadero Groups. The user was having trouble using GetFormImage where part of the graph they were showing on screen did not appear in the final image. They also needed the form caption included (which I do not) and they took the Canvas.CopyRect approach outlined in this post.

4) Here is the quote from the TExcellentImagePrinter page. I would have no problem buying their product if needed. There component looks like it was last updated in 2002 (There is a Delphi 2007 trial version though). I can’t tell if I really need to go that direction or not.

You can try using GetFormImage or
Form.Print. Try dropping a ComboBox
down on a form, then call GetFormImage
or Form.Print. If you get a
printout, do you see the text in the
ComboBox? No? Neither does anyone
else! This is only a small example of
the problems you will encounter when
printing VCL forms.

You can also try using Borland’s
TI-3155 “A better way to print a
form”. I wrote the TI when I worked at
Borland as a stop gap measure. While
it will print the combobox text, it
will fail on many printers, it can’t
print the entire form if your user has
resized the form, and it can’t print
forms that are hidden from view or is
located partially off the screen. The
code basically produces a screenshot,
and to print an image reliably, you
would probably want to take a look at
our TExcellentImagePrinter product!
Why? Simply put, it can require a
couple of thousand lines of low level
graphics code to get bitmaps to print
well under Windows.

  • 1 1 Answer
  • 1 View
  • 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-15T13:25:15+00:00Added an answer on May 15, 2026 at 1:25 pm

    I do not know what the problem is with GetFormImage, but an option that you have not tried (at least not explicitly) is

    procedure TForm1.FormClick(Sender: TObject);
    var
      bm: TBitmap;
    begin
    
      bm := TBitmap.Create;
      try
        bm.SetSize(ClientWidth, ClientHeight);
        BitBlt(bm.Canvas.Handle, 0, 0, ClientWidth, ClientHeight, Canvas.Handle, 0, 0, SRCCOPY);
        Clipboard.Assign(bm);
      finally
        bm.Free;
      end;
    
    end;
    

    In almost all cases I would expect this to produce the same result as

    bm := GetFormImage;
    try
      Clipboard.Assign(bm);
    finally
      bm.Free;
    end;
    

    though. (Also, the Canvas.CopyRect procedure employes StretchBlt which I would expect to produce the same result as BitBlt when no stretching is applied.)

    Method 2

    You can always use Print Screen:

    procedure TForm1.FormClick(Sender: TObject);
    begin
      keybd_event(VK_SNAPSHOT, 1, 0, 0);
    end;
    

    This will also capture the border and the title bar. If you only wish to obtain the client area, you can crop the image:

    procedure TForm1.FormClick(Sender: TObject);
    var
      bm, bm2: TBitmap;
      DX, DY: integer;
    begin
      Clipboard.Clear;
      keybd_event(VK_SNAPSHOT, 1, 0, 0);
      repeat
        Application.ProcessMessages;
      until Clipboard.HasFormat(CF_BITMAP);
      bm := TBitmap.Create;
      try
        bm.Assign(Clipboard);
        bm2 := TBitmap.Create;
        try
          bm2.SetSize(ClientWidth, ClientHeight);
          DX := (Width - ClientWidth) div 2;
          DY := GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYSIZEFRAME );
          BitBlt(bm2.Canvas.Handle, 0, 0, ClientWidth, ClientHeight, bm.Canvas.Handle, DX, DY, SRCCOPY);
          Clipboard.Assign(bm2);
        finally
          bm2.Free;
        end;
      finally
        bm.Free;
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a application to copy text and images form PowerPoint to Word. I
I need to Read files form Linux , copy them into the another computer(Windows
I need to copy a directory form one source form multiple destination . For
I copy a sheet from html page.Because I need the sheet structure,the paste as
I have a situation where I need to copy all of the form fields
I need to write a code that will copy one set of form values
I need to copy several files to remote server. for database in `mysql -Bseshow
I need to copy two linked lists recursively and return a new list .
I need to copy files and directories within a directory. Suppose there is only
I need to copy an object that has a pretty deep hierarchy of member

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.