Solved

Converting a CPicture to a CBitmap

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Importing Special Characters in Dynamics GP Through Integration Manager 3 97
centeredAverage challenge 8 188
modThree challenge 4 155
sumHeights2  challenge 7 140
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

710 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