Solved

Print Screen FCN in Borland C++ Builder

Posted on 1998-06-15
5
504 Views
Last Modified: 2012-08-14
My users requested a screen print function in the Application that I created for them.  How can
I implement this??
0
Comment
Question by:cwilliso
  • 3
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 100 total points
ID: 1165972
If you want to print your own window:

1. Use PrintDlg function to display a Print dialog box and get the DC of the selected printer.
2. Send the WM_PRINT or WM_PRINTCLIENT messages with the printer DC to your window.


If you want to print the full screen:

Check out the Win32 SDK sample "Wincap32: Window Screen Capture". The Wincap32 sample captures portions of the screen, specific windows, or the entire screen and saves it to a file or prints it. The sample uses DIB functions to do most of the capturing, printing, and saving.

0
 

Author Comment

by:cwilliso
ID: 1165973
any sample code??  It could be any application -- It would all be the same code to
print out the application's client area.  I don't have much time, unfortunately.
Can't find a Property or Method to get the DC of the printer.  How to send a WM_PRINT
message to the main application window?
0
 
LVL 23

Expert Comment

by:chensu
ID: 1165974
>Can't find a Property or Method to get the DC of the printer.

Look into the Win32 SDK sample "Printer: Printing". The Printer sample shows how to print using both the CreateDC and the PrinterDlg methods for acquiring a printer HDC.

>How to send a WM_PRINT message to the main application window?

It is just like a normal message. Use PostMessage or SendMessage with the window handle, HDC and the flags.
0
 

Author Comment

by:cwilliso
ID: 1165975
The actual answer is:

this->Print();
0
 
LVL 23

Expert Comment

by:chensu
ID: 1165976
I am not familiar with Borland C++ Builder. But I am sure this->Print() actually sends the WM_PRINT message. MFC also has a member function CWnd::Print, which wraps the WM_PRINT message.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question