Solved

Converting a CPicture to a CBitmap

Posted on 1998-05-20
2
414 Views
Last Modified: 2013-11-20
I am retreiving a CPicture from an OCX control.  I need to turn it into a CBitmap and I am having problems.  I use CBitmap::FromHandle(HANDLE) using the CPicture::GetHandle(), but the header is corrupted and the image is off by several bytes.  
0
Comment
Question by:twain052098
2 Comments
 
LVL 7

Accepted Solution

by:
galkin earned 100 total points
ID: 1313569
Try this.

LPPICTURE lpPicture;
CBitmap bm;
if(SUCEEDED(m_lpDispatch->QueryInterface(IID_IPicture, (LPVOID *)&lpPicture)))
{
HBITMAP hbm;
lpPicture->get_Handle((OLE_HANDLE *)&hbm);
bm.Attach(hbm);
lpPicture->Release();
}
0
 

Author Comment

by:twain052098
ID: 1313570
Great Thanks for the help.  Convertion of the m_lpDispatch was the trick.  Thanks!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Get filename and folder into excel 7 84
Expand to include initial dialog with two choices. 9 85
fizzArray2 challenge 1 101
Annoying "thing" blocks my view 4 130
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

713 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