Print Page | Close Window

How to change the icon dynamicaly?

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=1245
Printed Date: 16 July 2025 at 9:07am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to change the icon dynamicaly?
Posted By: freehawk
Subject: How to change the icon dynamicaly?
Date Posted: 07 October 2004 at 3:37am

Hello

How to change icon, animation in toolbar dynamicaly? Please help me.

Thanks




Replies:
Posted By: Oleg
Date Posted: 07 October 2004 at 6:24am
So you need to change icon or add animated icon?

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


Posted By: freehawk
Date Posted: 07 October 2004 at 8:20pm

Yes.

I want to do the following somethings

1.After clicked a button in toolbar, I want to change the icon of button to a animation, and then clicked the animation button once more, I need to change it to icon.

2.I need to display some icons in toolbar (not button), and dynamicaly change them to animations or other icons.

Please help me.

Thanks

 

 

 

Originally posted by oleg oleg wrote:

So you need to change icon or add animated icon?



Posted By: freehawk
Date Posted: 11 October 2004 at 3:02am

I added the following code to my project , but the icon of button in toolbar can not be changed. Please help me why.

 CXTPCommandBars* pCommandBar = GetCommandBars();
 if (!pCommandBar)
  return;

 CXTPControl* pCtl = pCommandBar->FindControl( xtpControlButton, ID_ANIMATION_TEST, TRUE, TRUE );
 if ( pCtl )
 {
  pCtl->SetIconId(IDB_BITMAP1);
}

 

Originally posted by freehawk freehawk wrote:

Yes.

I want to do the following somethings

1.After clicked a button in toolbar, I want to change the icon of button to a animation, and then clicked the animation button once more, I need to change it to icon.

2.I need to display some icons in toolbar (not button), and dynamicaly change them to animations or other icons.

Please help me.

Thanks

 

 

 

Originally posted by oleg oleg wrote:

So you need to change icon or add animated icon?



Posted By: Oleg
Date Posted: 12 October 2004 at 2:18am

index in SetIconId points to icon in IconManager.

in OnCreate:

pCommandBars()->GetImageManager()->SetIcons(IDB_BITMAP 1,....)

 

if Customization is enabled in your program, don't use FindControl, user can move/delete button.

Use Update Handler to update button's icon.

void CCustomThemesView::OnUpdateBack(CCmdUI* pCmdUI)
{
 
 CXTPControl* pPopup = CXTPControl::FromUI(pCmdUI));


 if (pPopup)
 { 
  pPopup->SetIconId(m_bEdit? ID_EDIT_COPY: ID_EDIT_PASTE);
 }

}

 

 



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


Posted By: freehawk
Date Posted: 12 October 2004 at 3:11am

Thank you very much.

By your way, I can change it, now there is a problem. when I clicked the button, the program crashed. I dont know why. Please help me.

My source code is as the following

1. OnCreate()

 UINT nCommands[] = {1,2};
 GetCommandBars()->GetImageManager()->SetIcons(ID B_BITMAP1, nCommands, 2, CSize(16, 16) );

2.void CMainFrame::OnUpdateAnimationTest(CCmdUI* pCmdUI)
{
  pCmdUI->Enable(TRUE);

 CXTPControl* pControl = CXTPControl::FromUI(pCmdUI);

 pControl->SetIconId(m_bTestIconFlg? 1: 2);

}

Is it right?

 

 

Originally posted by oleg oleg wrote:

index in SetIconId points to icon in IconManager.

in OnCreate:

pCommandBars()->GetImageManager()->SetIcons(IDB_BITMAP 1,....)

 

if Customization is enabled in your program, don't use FindControl, user can move/delete button.

Use Update Handler to update button's icon.

void CCustomThemesView::OnUpdateBack(CCmdUI* pCmdUI)
{
 
 CXTPControl* pPopup = CXTPControl::FromUI(pCmdUI));


 if (pPopup)
 { 
  pPopup->SetIconId(m_bEdit? ID_EDIT_COPY: ID_EDIT_PASTE);
 }

}

 

 




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