Solved

Print Screen FCN in Borland C++ Builder

Posted on 1998-06-15
5
502 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
  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 pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

808 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