Solved

use win32 API the print rtf and doc

Posted on 2002-04-03
8
510 Views
Last Modified: 2012-06-21
hi

I want to use win32 API to write to print rtf or word doc.
can anyone nhelp me. (i use addjob, setjob, createfile but it just can print text file)

thank
0
Comment
Question by:DouglasKwong
8 Comments
 
LVL 10

Accepted Solution

by:
makerp earned 50 total points
ID: 6917481
you will need to either,

learn the word doc format and write binary files using that...

or

use the word active x control from within your code to create word docs, that will be much easier and less prone to error, especially if the word format changes with new releasees of word

Paul
0
 
LVL 12

Expert Comment

by:pjknibbs
ID: 6917507
You don't need the Word activeX control at all. If all you need to do is handle RTF files, and the formatting of said files isn't too complex, I suggest you investigate the RichEdit control--this is capable of reading and writing RTF files and allowing full control over the editing of these files.

In point of fact, the WordPad wordprocessor which ships with many versions of Windows is little more than a wrapper window around a RichEdit control, so you can test out the functionality of the control for yourself before you ever start testing code!
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6917595
MFC provides a class, CRichEditView.  It can printout the formatted RTF.  You can use AppWizard to create a simple SDI app, with the default view set to CRichEditView.  It even provides a Print Preview feature because the excellent programmers at Microsoft though that would be nice.

If you don't want to use MFC, you can trace into the code to see what it is doing and then use the relevant portions (at some leve, MFC is just a bunch of calls to Win32 APIs).  As I recall there is some tricky business involved in calculating the page sizes and so forth.

-- Dan
0
 
LVL 86

Expert Comment

by:jkr
ID: 6917773
Hmm, why don't you just use

ShellExecute ( NULL, "print", "c:\\path\\myfile.doc", NULL, NULL, SW_HIDE);

or

ShellExecute ( NULL, "print", "c:\\path\\myfile.rtf", NULL, NULL, SW_HIDE);

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 12

Expert Comment

by:pjknibbs
ID: 6920206
DanRollins: CRichEditView is just a wrapper round a RichEdit control, as it happens. You can use RichEdit controls the same way you do edit controls, no need for MFC at all.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6920293
pjknibbs,

>> no need for MFC at all.

I see that you are unfamiliar with MFC and/or the CRichEditView.  MFC handles the very thing that DouglasKwong desires: a way to print out a hardcopy of the formatted RTF.  It does this by providing a LOT of code to make it happen.  Pagination alone is a major headache.

The RicheEdit common control does not provide any of that capability.

-- Dan
0
 
LVL 11

Expert Comment

by:griessh
ID: 6957208
Dear DouglasKwong

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "makerp"

comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points. The link to the Community Support area is: http://www.experts-exchange.com/commspt/

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 6979186
Force accepted


** Mindphaser - Community Support Moderator **
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now