Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

OLE container conversion....

Posted on 1997-03-17
3
Medium Priority
?
257 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
[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
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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…

688 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