Solved

Text Object Model/RichEdit

Posted on 2000-03-22
2
275 Views
Last Modified: 2013-11-20
In the Platform SDK the Save method is defined as (defined in TOM.H)

STDMETHODIMP ITextDocument::Save(
  VARIANT *pVar,
  long Flags,
  long CodePage
);
Parameters pVar  [in] The save target. This parameter is a VARIANT, which can be a file name, an IStream, or null.

My question is: How the heck do I get an IStream in a VARIANT so ITextDocument::Save will save to my stream?
If I use a BSTR for file name it works fine.

Thanks,
Tony.

Here's my code:
      ITextDocument *pTextDoc;
      GetIRichEditOle()->QueryInterface(IID_ITextDocument, (void **) &pTextDoc);
      IMyTextDocument *pMyTextDoc = new IMyTextDocument(pTextDoc);
     
      IStream *pStream = NULL;
      CreateStreamOnHGlobal( NULL, TRUE, &pStream);

      VARIANT Var;
      VariantInit(&Var);
      Var.vt = VT_UNKNOWN; //BSTR okay
      Var.punkVal = pStream; //"C:\\Test.rtf" okay

      pMyTextDoc->Save(&Var, 0, 0);

0
Comment
Question by:Tony_Sebastian
2 Comments
 
LVL 1

Accepted Solution

by:
yarond earned 100 total points
ID: 2660282
Just a guess, but there are two things you might want to try.
1. try passing it as VT_DISPATCH using pdispVal.
2. try not allocating your IStream as HGlobal. Maybe there is some sort of a memory reallocation problems here. Unlikely, but might be worth a try.
0
 

Author Comment

by:Tony_Sebastian
ID: 2661162
I'm using streamin and streamout, I initially wanted to use TOM because I saw the HTML flag and thought it would convert the RTF to html, but it doesn't, you have to stream HTML in to use the flag.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need to retreive data from .TFS file exported by DVR 8 176
Define unique primary key 9 89
Hibernate methods 2 67
zeroFront challenge 7 79
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

930 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

8 Experts available now in Live!

Get 1:1 Help Now