Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Can I get the HBitmap from a toolbar button
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Can I get the HBitmap from a toolbar button

 Post Reply Post Reply
Author
Message
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 Topic: Can I get the HBitmap from a toolbar button
    Posted: 20 July 2009 at 1:34pm
I have the ID to the toolbar button. Can I get the HBitmap associated with the button programmatically?

I tried this and HBitmap is always NULL.

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

XP Pro SP3 / VS2008 C++ / Xtreme CommandBars v13.1.0
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: 22 July 2009 at 4:01am
Hi,
 
Maybe you have assiciated icon - not bitmap. check
IconCopy.GetIcon()
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: 22 July 2009 at 9:08am
I've tried several different ways to extract the hbitmap from a toolbar.

I created the toolbar using:
    CXTPTabManagerItem* pItem = CreateToolbar(pCommandBars, pToolBar, Index, _TT("Main"), IDR_MAINFRAME3, true, true, false);

How do I get the hbitmap from one of the buttons using it's command ID?

I've tried this approach too
        CXTPControl* pCtrl = pCommandBars->FindControl(XTPControlType::xtpControlButton, CmdID, true, true);
        if (pCtrl) {
            CXTPImageManagerIcon* pIcon = pCtrl->GetImage();
            if (pIcon) {
                CXTPImageManagerIconHandle IconHandle = pIcon->GetIcon();

XP Pro SP3 / VS2008 C++ / Xtreme CommandBars v13.1.0
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: 24 July 2009 at 3:31am
Check this:
 
CXTPImageManagerIconHandle IconHandle = pIcon->GetIcon();
        CXTPImageManagerIconHandle IconCopy;
        IconCopy.CopyHandle(IconHandle);
       
      ASSERT(IconCopy.GetBitmap() || IconCopy.GetIcon());
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: 24 July 2009 at 10:52am
Should pIcon come from
    CXTPImageManagerIcon* pIcon = XTPImageManager()->GetImage( CmdID, 16);

or

        CXTPControl* pCtrl = pCommandBars->FindControl(XTPControlType::xtpControlButton, CmdID, true, true);
        if (pCtrl) {
            CXTPImageManagerIcon* pIcon = pCtrl->GetImage();


or does it matter?

XP Pro SP3 / VS2008 C++ / Xtreme CommandBars v13.1.0
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: 24 July 2009 at 2:11pm
Oleg,

That code did return an hIcon, at least it was not null. However, the hIcon would not display when draw with pDC->DrawState.

I was able to solve my problem by passing the pDC to pIcon->Draw(pDC, CPoint) - that worked!

Thanks

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.063 seconds.