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

x
?
Solved

Converting a CPicture to a CBitmap

Posted on 1998-05-20
2
Medium Priority
?
431 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 400 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

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

916 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