Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Help! MFC Active Control driving me bonkers!

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

Technology Partners: 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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…

636 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