Print Page | Close Window

Dynamically creating toolbar with images

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=16499
Printed Date: 21 June 2025 at 12:21am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Dynamically creating toolbar with images
Posted By: danpetitt
Subject: Dynamically creating toolbar with images
Date 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" );



Replies:
Posted By: danpetitt
Date 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?



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