Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - I hope to chage icon on commandbar
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

I hope to chage icon on commandbar

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


Joined: 17 September 2008
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote copycdx2 Quote  Post ReplyReply Direct Link To This Post Topic: I hope to chage icon on commandbar
    Posted: 04 March 2009 at 3:03am
first, load prestate.
 
LoadCommandBars(XTP_REG_TOOLBAR);
 
I use commandbars with icon.
below code.
 
  pCommandBars->GetImageManager()->SetIcon( IDI_NC_LOGIN, IDI_NC_LOGIN );
  pCommandBars->GetImageManager()->SetIcon( IDI_NC_LOGOUT, IDI_NC_LOGOUT );
 
 
I hope to change icon in order to display toggle-state.
but, iconimage is not change.
 
 
 CXTPCommandBars* pCommandBars = GetCommandBars();
 if(pCommandBars == NULL)
 {
  TRACE0("Failed to create command bars object.\n");
  return;      // fail to create
 }

 CXTPToolBar* pToolBar = (CXTPToolBar*)pCommandBars->GetToolBar(IDR_TOOLBAR_NC02);
 if( pToolBar )
 {
  CXTPControls* pControls = pToolBar->GetControls();
  if( pControls )
  {
   CXTPControl* pCtrl = pControls->FindControl( ID_NCLOGIN );
   if( pCtrl )
   {
    if( bLoged )
     pCtrl->SetIconId(IDI_NC_LOGIN);
    else
     pCtrl->SetIconId(IDI_NC_LOGOUT);

    RecalcLayout(FALSE);
    pCommandBars->RedrawCommandBars();
    RedrawWindow();
   }
  }
 }

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: 04 March 2009 at 3:37am
Hi,
 
Code looks right. Are you sure you call it after LoadCommandBars ? pCtrl  not NULL ?
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
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.047 seconds.