Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Dynamically creating toolbar with images
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Dynamically creating toolbar with images

 Post Reply Post Reply
Author
Message
danpetitt View Drop Down
Senior Member
Senior Member


Joined: 17 July 2005
Location: United Kingdom
Status: Offline
Points: 109
Post Options Post Options   Thanks (0) Thanks(0)   Quote danpetitt Quote  Post ReplyReply Direct Link To This Post Topic: Dynamically creating toolbar with images
    Posted: 23 March 2010 at 3:16pm
I am creating a plugin system for my app and one of the things is for the plugin to be able to specify the buttons on a toolbar with caption and images.

What I need to know is how do I load a toolbar control with an image from a file?

VERIFY( m_wndToolBar.CreateToolBar( WS_TABSTOP | WS_VISIBLE | WS_CHILD | CBRS_TOOLTIPS | CBRS_SIZE_DYNAMIC, this ) );

m_wndToolBar.SetBarID( IDR_TOOLBAR );

CXTPControl *pControl = m_wndToolBar.GetControls()->Add(xtpControlButton, ID_TOOLBAR_NEW);
pControl->SetBeginGroup( TRUE );
pControl->SetStyle( xtpButtonIconAndCaption );


So with the above example I was looking for something like:
pControl->LoadIcon( "d:\image.png" );
Back to Top
danpetitt View Drop Down
Senior Member
Senior Member


Joined: 17 July 2005
Location: United Kingdom
Status: Offline
Points: 109
Post Options Post Options   Thanks (0) Thanks(0)   Quote danpetitt Quote  Post ReplyReply Direct Link To This Post Posted: 23 March 2010 at 3:43pm
I have got it I think:

HBITMAP hBitmap = CXTPImageManagerIcon::LoadBitmapFromFile( "d:\\image.png" );

CXTPImageManagerIconHandle hIcon( hBitmap );
UINT uIconID = m_wndToolBar.GetImageManager()->AddCustomIcon( hIcon );

pControl->SetIconId( uIconID );


Seems to work okay. But do I need to free or release this bitmap at all?
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.047 seconds.