Print Page | Close Window

using setcustomicon functionality

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=4743
Printed Date: 11 November 2025 at 12:36am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: using setcustomicon functionality
Posted By: venkyhyd
Subject: using setcustomicon functionality
Date Posted: 05 August 2006 at 7:36am
Hi,
 
i want to load a icon from the resources on to the toolbar button.
i am getting the handle to the desired control with the following code.
 
 

CXTPCommandBars* pCommandBars = GetCommandBars();

CXTPToolBar* pMYTOOLBAR=pCommandBars->GetToolBar(IDR_MAINFRAME);

CXTPControl* pControl=pMYTOOLBAR->GetControls()->GetAt(1);

Can yoy please help me in using setcustomicon function to load an icon(say IDR_NEWICON from the resources)

Thanks

 




Replies:
Posted By: Bart
Date Posted: 07 August 2006 at 7:56am
I'd like to do the same thing actually, replacing a toolbar button image at runtime. Or is this only possible by re-setting the entire toolbar image (used in the creation process?).


Posted By: venkyhyd
Date Posted: 07 August 2006 at 11:14pm
Hi,
Now i could be able to set the custom icon at runtime using the following code
//to get the handle to a particular button in the toolbar

CXTPCommandBars* pCommandBars = GetCommandBars();

CXTPToolBar* pMYTOOLBAR=pCommandBars->GetToolBar(IDR_MAINFRAME);

int i=pMYTOOLBAR->GetControls()->GetCount();

CXTPControl* pControl=pMYTOOLBAR->GetControls()->GetAt(1);//here i am trying to get handle for the second button

//To get the handle to the icon IDI_ATOM present in the resources
pControl->SetIconId(IDI_ATOM);

HICON hIcon;

hIcon = AfxGetApp()->LoadIcon(IDI_ATOM);

pControl->SetCustomIcon(hIcon);//loading the icon onto the control

Hope this is clear enough
 


Posted By: Bart
Date Posted: 08 August 2006 at 1:26am
Exactly what I needed! ([edit]well, unless using CXTPControlPopupColor, see below...)
Thank you for your contribution and help!


Posted By: Bart
Date Posted: 08 August 2006 at 5:16am
Hmmm, discovered a few issues though:
 
When using this on CXTPControlPopupColor, it doesnt redraw properly if done from the UpdateUI handler (C++). When you move the mouse over it, the icon changes, but drawing is still wrong, as then the displayed color is no longer visible....
 
I'll thing I'll try to make 2 buttons, only showing the one thats applicable, even though that will make for some odd code and duplicate UI handling . Another option is chaning the overall toolbar's bitmap - if that can be changed runtime, but that has the disadvantage of duplicating the bitmap,
 
SetCustomIcon sounds nice, but in this case not a solution, unless I'm doing something wrong?
 


Posted By: Oleg
Date Posted: 14 August 2006 at 9:09am
Don't use SetCustomIcon for this porpose.
 
Add icon to ImageManager:
 
pCommandBars->GetImageManager()->SetIcon(...);


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



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