![]() |
Can I get the HBitmap from a toolbar button |
Post Reply ![]() |
Author | |
tralfaz ![]() Groupie ![]() Joined: 21 June 2009 Status: Offline Points: 36 |
![]() ![]() ![]() ![]() ![]() 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 |
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hi,
Maybe you have assiciated icon - not bitmap. check
IconCopy.GetIcon()
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
tralfaz ![]() Groupie ![]() Joined: 21 June 2009 Status: Offline Points: 36 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Check this:
CXTPImageManagerIconHandle IconHandle = pIcon->GetIcon();
CXTPImageManagerIconHandle IconCopy; IconCopy.CopyHandle(IconHandle); ASSERT(IconCopy.GetBitmap() || IconCopy.GetIcon());
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
tralfaz ![]() Groupie ![]() Joined: 21 June 2009 Status: Offline Points: 36 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
tralfaz ![]() Groupie ![]() Joined: 21 June 2009 Status: Offline Points: 36 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |