INTRODUCTION AND RELEVANT INFORMATION:
I am maintaining an old application and I need to implement feature that generates reports based on data calculated from a database. User must also have an additional option of printing the file ( user must be able to choose printer, and must be able to see print preview ).
To improve my chances of getting satisfactory answer, allow me to additionally clarify matters with a small "example":
- User presses a button -> application calculates data; // Done
- Application creates file and populates it with the result; // Done
- User gets informed that report is generated; // Done
- User presses another button that is charged for printing; // Stuck here!
- Print preview pops up and an option to run print dialog. // Stuck here
- User starts the print dialog, chooses the printer and application prints the file;
The application is coded in C++
using raw WinAPI
( no MFC
). I am working on Windows XP
.
PROBLEM:
I was able to successfully use OLE Automation
to generate/save Word and Excel reports but I can not solve the printing task.
If I use OLE Automation
to show Excel's print dialog/print preview, there is a following problem that might occur :
User can simply click "Close Print Preview", or can simply close print property sheet and return to the document which might compromise document's data.
Therefore, I need a solution for generating a print preview for the user, in a way that protects document data.
Furthermore, user should be able to choose the printer that will print the file.
QUESTION:
INTRODUCTORY NOTES:
The question is too broad to be answered in one post so I must limit myself only for seeking advice / general concept / pointing in the right direction.
THE ACTUAL QUESTIONS :
I did the best I could with the OLE Automation
and Excel / Word files, but as you can see there are problems with generating a print preview, hence the following questions :
1. Since this is my first time to tackle this kind of task, can you recommend me the proper way to handle it ( general concepts of course )?
2. Is there a chance that there is a workaround for my printing problem ( like sending WM_PRINTCLIENT
message to the Word / Excel or something like that )?
REMARKS :
Again, I realize the question is too broad so just give me general concepts / pointers, so I could post separate questions if I get stuck somewhere in the way.
I do not need to use Word / Excel and OLE Automation
, it was my choice at the moment.
If you can recommend better solution I will gladly accept. I do not wish to use libraries.
If additional information is required, ask and I will edit my post.