![]() |
How to change button image? |
Post Reply ![]() |
Author | |
brianh ![]() Groupie ![]() Joined: 30 April 2004 Location: United Kingdom Status: Offline Points: 83 |
![]() ![]() ![]() ![]() ![]() Posted: 02 July 2004 at 10:00am |
I have a command bar button that can be toggled on/off and I want to change the button image depending on whether it's checked or not. Does anyone know the best way to do this? Thanks. |
|
![]() |
|
brianh ![]() Groupie ![]() Joined: 30 April 2004 Location: United Kingdom Status: Offline Points: 83 |
![]() ![]() ![]() ![]() ![]() |
I have managed to solve the problem by using the following update handler for the button: HICON m_hIconSingleProd ; ... void CMyClass::OnUpdateSingleProduct(CCmdUI* pCmdUI) CXTPControl* pCtl = CXTPControl::FromUI( pCmdUI ) ; Although this works it doesn't seem very efficient, is there a better way? Also the image for this command in the menu is now offset upwards from where it should be, any ideas why? |
|
![]() |
|
brianh ![]() Groupie ![]() Joined: 30 April 2004 Location: United Kingdom Status: Offline Points: 83 |
![]() ![]() ![]() ![]() ![]() |
I know why the icon in the menu was offset, I was using LoadIcon() to load it and this only loads icons of the default system size so it was enlarging the icon thus causing the alignment problem. I changed this to use LoadImage() and the icon in the menu is now correctly positioned - what's more it changes with the toolbar icon. :)
|
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Easer way to change IconId of control: pCtl->SetIconId(m_bSingleProduct? ID_SINGLE_PRODUCT: ID_MULTI_PRODUCT)
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
brianh ![]() Groupie ![]() Joined: 30 April 2004 Location: United Kingdom Status: Offline Points: 83 |
![]() ![]() ![]() ![]() ![]() |
I had seen this function but I couldn't see how to add the icons and get their ids in the first place. Can you explain how this is done? Thanks |
|
![]() |
|
clintsinger ![]() Newbie ![]() Joined: 15 May 2003 Location: Canada Status: Offline Points: 9 |
![]() ![]() ![]() ![]() ![]() |
I too would like to see how an icon is accessed. I have tried to add icon resources and then point the SetIconId to the corresponding resource id but all that happens is that the area on toolbar where the icon should appear is blank I am doing the call from an OnUpdate(CCmdUI* pCmdUI) method and calling CXTPControl* pCtl = CXTPControl::FromUI( pCmdUI ) ; to get the control. Anyone have any ideas? |
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
List all your code related this problem.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
bluesaphire ![]() Newbie ![]() ![]() Joined: 07 August 2006 Location: India Status: Offline Points: 14 |
![]() ![]() ![]() ![]() ![]() |
Try this depending upon the flag checked or unchecked call the setcustomicon function accordingly
if( m_bSingleProduct )
{ pControl->SetIconId(ID_SINGLE_PRODUCT); HICON hIcon; hIcon = AfxGetApp()->LoadIcon(ID_SINGLE_PRODUCT); }
else {
pControl->SetIconId(ID_MULTIPLE_PRODUCT);
HICON hIcon; hIcon = AfxGetApp()->LoadIcon(ID_MULTIPLE_PRODUCT); }
I guess this is what you looking for? |
|
![]() |
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 |