Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - How to get bitmap and not glyph
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to get bitmap and not glyph

 Post Reply Post Reply
Author
Message
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 899
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post Topic: How to get bitmap and not glyph
    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;

}

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 899
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 899
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
tralfaz View Drop Down
Groupie
Groupie


Joined: 21 June 2009
Status: Offline
Points: 36
Post Options Post Options   Thanks (0) Thanks(0)   Quote tralfaz Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.043 seconds.