Solved

Text Object Model/RichEdit

Posted on 2000-03-22
2
289 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
[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
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

717 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