Link to home
Start Free TrialLog in
Avatar of rvenkat
rvenkat

asked on

OLE container conversion....

How would one write code to change an OLE embedded item to a graphic in an OLE container Applictaion written in MFC C++ using the rich edit control?
(The ctrl+shift+F9 combo in WORD changes an embedded OLE item to a graphic.)
ASKER CERTIFIED SOLUTION
Avatar of mikeblas
mikeblas

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rvenkat
rvenkat

ASKER

Mike this is the sample code I had. I just wanted to veify whether this is what you meant by rendering object as BITMAP.
I copy the ole item to the clipboard and recreate it as a static object. Is the static object a bitmap/graphic?


//I get the OLE container item
CNOTESCntrItem* pItem = (CNOTESCntrItem *)                                                   pDoc->GetNextItem(pos);            

//I copy it to the clipboard
pItem->CopyToClipboard();

//then I create a new OLE object
pStaticItem = new CNOTESCntrItem(NULL, GetDocument());

//Then I select the Ole container object in the richedit control
//and delete it
GetRichEditCtrl().SetSel(pItem->m_lBeg, pItem->m_lBeg+1);
GetRichEditCtrl().Clear();
            
//Now using the new container itemn object  I create a STATIC //object frm the clipboard and insert it. IS THIS WHAT YOU MEAN BY RENDER AS A //BITMAP???
if(pStaticItem->CreateStaticFromClipboard(OLERENDER_DRAW,0,NULL))
   InsertItem(pStaticItem);



You can use  the CreateStaticFromClipboard() function to get a static OLE object that is a particular format you want, but you're not asking for any format in particular since you're passing zero for the clipboard format and NULL for the LPFORMATETC parameter.

Even if you asked for CF_BITMAP, you'd still find that you're creating a static OLE object.  Maybe that's what you want: you can paste that into your rich edit control and let the edit control do the work.

Unfortunately, I'm not familiar with the Word command you mention and, in Word 97, it doesn't appear to do anything.  But your question led me to believe that you wanted a plain old HBITMAP without OLE involved at all, but maybe that's not the case.

.B ekiM