Solved

Text Object Model/RichEdit

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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 video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

759 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

19 Experts available now in Live!

Get 1:1 Help Now