Solved

Help! MFC Active Control driving me bonkers!

Posted on 1998-05-14
2
206 Views
Last Modified: 2013-11-25
It's a simple problem, but the answer eludes me. I have tried some methods but I've had NO success. So I'm BEGGING for someone to help me on this! :)
How do you find out the Width and Height of a bitmap object in an Active X control?? The only way it appears you can access the information it through the GetPictureDispatch function in CPictureHolder. This is what I've tried so far..

//Else draw it in Bitmap's Length and Width
LPPICTURE pPict = NULL;
LPPICTUREDISP pPictDisp = m_cPicHolder.GetPictureDispatch();

if ((pPictDisp != NULL) && 
SUCCEEDED(pPictDisp->QueryInterface(IID_IPicture, (LPVOID*)&pPict)))
{
ASSERT(pPict != NULL);

OLE_XSIZE_HIMETRIC hmWidth;
OLE_YSIZE_HIMETRIC hmHeight;

pPict->get_Width(&hmWidth);
pPict->get_Height(&hmHeight);
rect = rcBounds;
rect.right = rect.left + hmWidth;
rect.bottom = rect.top + hmHeight;
m_cPicHolder.Render(pdc, rect, rcBounds);
pPict->Release();
// Added in for DEBUG
char buffer[20];
_itoa( hmWidth, buffer, 10 );
CString debugStr(buffer);
pdc->ExtTextOut(rect.left, (rect.top + rect.bottom)/2, ETO_CLIPPED, rect, debugStr, debugStr.GetLength(), NULL);
// End DEBUG

and of course it FAILS miserably! Gives me some outrageous numbers for the width and height. Please, someone please explain to me what the story is here!
Thanks :)

RickMan
0
Comment
Question by:rickmanx
[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: 1311126
Try this
HBITMAP hBitmap;
pPict->get_Handle((OLE_HANDLE *)&hBitmap);

BITMAP bm;
::GetObject(hBitmap, sizeof(bm), &bm);

int nWidth = bm.bmWidth;
int nHeight = bm.bmHeight;
0
 

Author Comment

by:rickmanx
ID: 1311127
I couldn't rest easy till I found out! It works perfectly! Thanks a bunch!
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

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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.
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…

728 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