Solved

Converting a CPicture to a CBitmap

Posted on 1998-05-20
2
412 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

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