Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

OLE container conversion....

Posted on 1997-03-17
3
Medium Priority
?
259 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 200 total points
ID: 1300255

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
ID: 1300256
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
ID: 1300257
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…

824 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