?
Solved

Text Object Model/RichEdit

Posted on 2000-03-22
2
Medium Priority
?
292 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 300 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

752 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