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
Solved

use win32 API the print rtf and doc

Posted on 2002-04-03
8
522 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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.

789 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