![]() |
using setcustomicon functionality |
Post Reply
|
| Author | |
venkyhyd
Groupie
Joined: 29 June 2006 Location: India Status: Offline Points: 70 |
Post Options
Thanks(0)
Quote Reply
Topic: using setcustomicon functionalityPosted: 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
|
|
![]() |
|
Bart
Newbie
Joined: 17 July 2006 Status: Offline Points: 9 |
Post Options
Thanks(0)
Quote Reply
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?).
|
|
![]() |
|
venkyhyd
Groupie
Joined: 29 June 2006 Location: India Status: Offline Points: 70 |
Post Options
Thanks(0)
Quote Reply
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 ![]() |
|
![]() |
|
Bart
Newbie
Joined: 17 July 2006 Status: Offline Points: 9 |
Post Options
Thanks(0)
Quote Reply
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! |
|
![]() |
|
Bart
Newbie
Joined: 17 July 2006 Status: Offline Points: 9 |
Post Options
Thanks(0)
Quote Reply
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?
|
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
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 |
|
![]() |
|
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 |