![]() |
Dynamic Toolbar icon |
Post Reply ![]() |
Author | |
AndyKir ![]() Newbie ![]() Joined: 07 August 2009 Location: United States Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() Posted: 12 August 2009 at 2:47pm |
Hi,
how can I dynamically change one icon on the toolbar. I load the toolbar: CXTPToolBar* pToolBarFile = (CXTPToolBar*) pCommandBars->Add(_T("File"), xtpBarTop); if (!pToolBarFile || !pToolBarFile->LoadToolBar(IDR_TOOLBAR_DVD))... then I have a code to update it: void CMainFrame::OnUpdateSwitchToCDDVD(CCmdUI *pCmdUI) { bool bCD = theApp.IsMediaCD(); pCmdUI->Enable(!IsInProcess()); pCmdUI->SetCheck(!bCD); #ifdef USE_CODEJOCK_MFC_EXTENSION CXTPControl* pControl = GetCommandBars()->GetAt(1)->GetControl(4); pControl->SetIconId(bCD ? XXXXX : YYYYY); pControl->SetCaption(bCD ? _T("CD") : _T("DVD")); #endif } What "Icon's identifier to be set." in function CXTPControl::SetIconId means? And my question what to use as "XXXXX : YYYYY"? I tried: pCommandBars->GetImageManager()->SetIcon(IDB_CD, ID_SWITCH_CD_DVD, xtpImageNormal); pCommandBars->GetImageManager()->SetIcon(IDB_DVD, ID_SWITCH_CD_DVD, xtpImageChecked); and pCommandBars->GetImageManager()->SetIcon(IDB_CD, ID_SWITCH_CD_DVD); pCommandBars->GetImageManager()->SetIcon(IDB_DVD, ID_SWITCH_DVD_CD); no luck. Any suggestions? Thanks! |
|
![]() |
|
mgampi ![]() Senior Member ![]() ![]() Joined: 14 July 2003 Status: Offline Points: 1201 |
![]() ![]() ![]() ![]() ![]() |
Hi;
I do it this way: void CMyApp::OnUpdateMyCommand(CCmdUI* pCmdUI) { CXTPControl* pPopup = CXTPControl::FromUI(pCmdUI); if (pPopup) { pPopup->SetIconId(MyNewId); } } |
|
Martin Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0 Platform: Windows 10 v 22H2 (64bit) Language: VC++ 2022 |
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Yes, use FromUI and load using
pCommandBars->GetImageManager()->SetIcon(ID_SWITCH_CD_DVD, ID_SWITCH_CD_DVD); where ID_SWITCH_CD_DVD _Icon_ resource.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
AndyKir ![]() Newbie ![]() Joined: 07 August 2009 Location: United States Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() |
Олег,
can you please take a look at the example I tried to build (I used your new project template and cleaned up it) What am I doing wrong? And one more question - how do I remove icon from a toolbar button (so it would have an icon in one state and no icon in another)? Disclosure: I do have one year support. Thanks! uploads/20090813_112231_CJtest.zip |
|
![]() |
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 |