Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - How to change the icon dynamicaly?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to change the icon dynamicaly?

 Post Reply Post Reply
Author
Message
freehawk View Drop Down
Groupie
Groupie


Joined: 22 April 2004
Status: Offline
Points: 95
Post Options Post Options   Thanks (0) Thanks(0)   Quote freehawk Quote  Post ReplyReply Direct Link To This Post Topic: How to change the icon dynamicaly?
    Posted: 07 October 2004 at 3:37am

Hello

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

Thanks

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 07 October 2004 at 6:24am
So you need to change icon or add animated icon?
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
freehawk View Drop Down
Groupie
Groupie


Joined: 22 April 2004
Status: Offline
Points: 95
Post Options Post Options   Thanks (0) Thanks(0)   Quote freehawk Quote  Post ReplyReply Direct Link To This Post 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?

Back to Top
freehawk View Drop Down
Groupie
Groupie


Joined: 22 April 2004
Status: Offline
Points: 95
Post Options Post Options   Thanks (0) Thanks(0)   Quote freehawk Quote  Post ReplyReply Direct Link To This Post 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?

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
freehawk View Drop Down
Groupie
Groupie


Joined: 22 April 2004
Status: Offline
Points: 95
Post Options Post Options   Thanks (0) Thanks(0)   Quote freehawk Quote  Post ReplyReply Direct Link To This Post 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);
 }

}

 

 

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.063 seconds.