Print Page | Close Window

How to get bitmap and not glyph

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=13537
Printed Date: 27 February 2025 at 5:17pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to get bitmap and not glyph
Posted By: rdhd
Subject: How to get bitmap and not glyph
Date Posted: 01 March 2009 at 6:15pm
I am doing the following:
 

pIcon = XTPImageManager()->GetImage( nID, 16);

CXTPImageManagerIconHandle IconHandle = pIcon->GetIcon();

hbm = IconHandle.GetBitmap();

I expected to get a handle to a bitmap for the input command id (nID). Instead what I get is the entire glyph the bitmap is part of. I stepped into the code and found that m_pRInfo contians a member, "rc" that has the location of the command in the glyph but the code appears to just return a handle to a glyph. How do I get an individual bitmap of the size I have asked for?
 

HBITMAP CXTPImageManagerIconHandle::GetBitmap() const

{

ASSERT(IsAlpha());

if (m_hBitmap)

return m_hBitmap;

if (m_pRInfo && m_pRInfo->pResource && m_pRInfo->pResource->m_hbmpImage)

return m_pRInfo->pResource->m_hbmpImage;

ASSERT(FALSE);

return NULL;

}




Replies:
Posted By: Oleg
Date Posted: 02 March 2009 at 12:37am
Hi,
 
Just make individual copy of this handle:
 

CXTPImageManagerIconHandle IconHandle = pIcon->GetIcon();

CXTPImageManagerIconHandle IconCopy;
IconCopy.CopyHandle(IconHandle);


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: rdhd
Date Posted: 02 March 2009 at 11:02am

Thanks that seems to work. I went back to V11 when our code was working and it appears there has been a fairly significant change in the underlying CodeJock code in V12 that now is rippling its way thru our products. I can understand why CodeJock made the underlying archetectural change to how the images are stored and displayed.

But why the change in the seamantics of the GetImage method so that it returns the entire glyph instead of the bitmap of the command ID that is passed in?
 
Should I start checking the version of CJ at runtime to deduce the semantics of various api calls? Or was this change in the semantics of GetImage something that was accidental?


Posted By: Oleg
Date Posted: 03 March 2009 at 12:52am
Hello,
 
You can call
XTPImageManager()->m_bUseResources = FALSE;
to return it all back.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: rdhd
Date Posted: 03 March 2009 at 12:51pm
Why change the previous behavior by default? There have been other issues like this with V12 where previous behavior is changed and to change it back we have to set a flag (accelerators on shortcut menus comes to mind). I would have thought m_bUseResources would default to FALSE and if I want to turn it on I would specifically do so and hence know or understand the repercussions and additional coding that is then necessary. Release notes could indicate the new functionality, why it was added and how to turn it on and any known issues when it is turned on.
 
We started out late with CJ (version 11) so we have only lived thru one version change (we are in the process of moving to 13 but are now wondering what will bite us next). These sort of semantic/behavior changes are catching us flat footed and we are beginning to wonder about the approach CJ is taking when producing a new version. Basically we are spending resources trying to fix what used to work. Setting a new flag is not much trouble. Finding out what caused the regression and how to get back to the start point is time consuming.


Posted By: Oleg
Date Posted: 04 March 2009 at 3:38am
Hi,
 
It was in release notes for 11.2.1 version and marked as important change.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: tralfaz
Date Posted: 19 July 2009 at 2:49pm
This is not working for me

    CXTPImageManagerIcon* pIcon = XTPImageManager()->GetImage( CmdID, 16);
    if (pIcon) {
        CXTPImageManagerIconHandle IconHandle = pIcon->GetIcon();
        CXTPImageManagerIconHandle IconCopy;
        IconCopy.CopyHandle(IconHandle);
        if (IconCopy!= NULL) {
            hBM = (HBITMAP)IconCopy.GetBitmap();
        }
    }

pIcon is good and contains the correct information, but the HBITMAP is always null. The toolbar button with CmdID exists. Used this to create the toolbar

    CXTPTabManagerItem* pItem = CreateToolbar(pCommandBars, pToolBar, Index, _TT("Main"), IDR_MAINFRAME3, true, true, false);

Can you tell me how to get the HBitmap from an ID?


-------------

XP Pro SP3 / VS2008 C++ / Xtreme CommandBars v13.1.0



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net