Link to home
Start Free TrialLog in
Avatar of beneke
beneke

asked on

Print preview

I,m a VB programmer and would like to know if C++ does have a print preview function. If so, can a control be written to be used in VB. I don't want it to access any data files. I would like to send normal printer codes and text to it and then would like to see a preview of the possible printout on the screen to be able to decide whether to print it or not
Avatar of TheSnowman
TheSnowman

I'll answer this, but not for zero points.
Avatar of beneke

ASKER

Ok TheSnowman, hope this will go. thanks
C++, the language does not.  It has practically no support for hardware (printers, screens, mice) of any type.  Standard C++ assumes you are working on a computer with 3 standard I/O streams.  These are streams of text characters.  One stream is standard input, which returns characters that are inputted into the program.  Usually these come from the keyboard, but could come from a file, or partically any other source.  There is a standard output stream that takes characters outputted by the program.  These are usually sent to the screen, but might be sent to a printer, file, teletype, brail display or any other device capable of handling the characters.  The final stream is standard error.  It is basically the same as standard output, but is used to display error information.

That is the limits of standard C++'s interaction with hardware.  There is no support for printing, or print preview, there is no support for graphics.

Now that sort of thing is possible in C++.  But only by the use of non-standard, operating system-specific code.  For example the windows operating system provides many API functions that would aid you in printing and displaying a print preview.  The MFC library, a C++ library used for writing windows applications has built in features to make printing and print preview very easy.  Now these are not features of C++, but features of a library written in C++.
Avatar of beneke

ASKER

Thanks for the background
You took the words right out of my mouth...

Basically, the language does not have what you are looking for. You need to use OS-specific API calls and libraries to acomplish this task.

It is possible to write a VB control to do this, but I wouldn't. I bet it has already been done, although I wouldn't know for sure since I am not a VB programmer. But if there is such a control, why reinvent the wheel? Unless it was a square wheel, of course... then you make your own.
Why did you reject the answer?
If you are unsatisfied with nietod's answer, well, let's just say you won't get a better answer. I don't know what you were looking for, but nietod answered your question accurately.
thanks.
Avatar of beneke

ASKER

nietod,

Thanks again, as stated in my Ques I was looking for information as to whether something can be done or not.

Your answer was quite a mouthfull but make sence and as was said by TheSnowman: "Basically, the language does not have what you are looking for. You need to use OS-specific API calls and libraries to acomplish this task."

There is no need for me to reinvent the wheel, the only thing is that I write freeware programs and surely are not going to buy the component. I did write my own but I had to admit that it still need some work cause its to slowwww.

PLEASE lock the Ques again and I will reward you the points.
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of beneke

ASKER

Nietod
I guess that you have noticed when installing software that there are files with the extension of OCX. It's a component and yes, some of them do come with windows, others can be bought for there functionality like doing a print preview. It can do I/O or only either one. In VB we do not have the luxury of having such a component or DLL.

One can send print strings in VB BUT there is now easy way of doing a preview of what you send to the printer. If one is using a data file then it is possible to do it using a report writer.
I may not be a Visual Basic programmer, but I do know it can use DLLs and OCXs. It could do this back in version 3.0 when I dabbled in VB a little bit (well it could use VBX, not OCX, but Microsoft was adding support).
Yes, and you can use the windows API as well, so all of windows print features are available as well as the ability to do print previews (although that would probably be a lot of work.)
Avatar of beneke

ASKER

Nietod

As you said, the APIs are available but it is a LOT of work to be done.

Thanks to the SnowMan aswell for his help. To both of you it's much appreciated.

Bones