Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Print preview

Posted on 1999-09-07
14
Medium Priority
?
306 Views
Last Modified: 2010-04-02
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
0
Comment
Question by:beneke
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 4
14 Comments
 

Expert Comment

by:TheSnowman
ID: 2029047
I'll answer this, but not for zero points.
0
 

Author Comment

by:beneke
ID: 2029603
Ok TheSnowman, hope this will go. thanks
0
 
LVL 22

Expert Comment

by:nietod
ID: 2029859
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++.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:beneke
ID: 2030410
Thanks for the background
0
 

Expert Comment

by:TheSnowman
ID: 2030414
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.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2030458
Why did you reject the answer?
0
 

Expert Comment

by:TheSnowman
ID: 2030502
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.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2030597
thanks.
0
 

Author Comment

by:beneke
ID: 2031319
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.
0
 
LVL 22

Accepted Solution

by:
nietod earned 40 total points
ID: 2031401
>> are not going to buy the component
What component?  the windows print features are part of the windows OS.  If you run windows you already bought it.

>> I did write my own but I had to admit that it
>> still need some work cause its to slowwww.
How?  are you writing directly to the printer file?  That is not really recommended in Windows.  It should not be slow though, assuming you are writting reasjnably large blocks of data.
0
 

Author Comment

by:beneke
ID: 2034057
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.
0
 

Expert Comment

by:TheSnowman
ID: 2034202
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).
0
 
LVL 22

Expert Comment

by:nietod
ID: 2034383
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.)
0
 

Author Comment

by:beneke
ID: 2035850
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
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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.

670 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