Solved

OLE container conversion....

Posted on 1997-03-17
3
249 Views
Last Modified: 2013-11-25
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.)
0
Comment
Question by:rvenkat
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
mikeblas earned 100 total points
Comment Utility

1) Get the selected OLE item
2) Ask it to render itself as a bitmap.  You can use GetClipboardData() to do this for most objects.  For some objects, you'll have to work directly with IViewObject::Draw() to capture a bitmap.  Some objects don't support directly rendering themselves as bitmaps.
3) close the OLE object.
4) Destroy the OLE object
5) make the bitmap from step 2 a part of your document.

.B ekiM
0
 

Author Comment

by:rvenkat
Comment Utility
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);



0
 
LVL 11

Expert Comment

by:mikeblas
Comment Utility
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

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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 Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

771 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

11 Experts available now in Live!

Get 1:1 Help Now