Solved

OLE container conversion....

Posted on 1997-03-17
3
253 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
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sumHeights2  challenge 7 115
Where to obtain Oracle Data Provider for .NET 3.5 7 54
Detect file exist or not 3 179
What .NET URL re-routing tool did I use? 2 74
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…
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…
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…

856 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