Print Page | Close Window

About Dynamically Remove Button From ToolBar

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=5096
Printed Date: 01 October 2024 at 2:04pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: About Dynamically Remove Button From ToolBar
Posted By: martypku
Subject: About Dynamically Remove Button From ToolBar
Date Posted: 19 September 2006 at 11:52pm
I want to remove button from a toolbar dynamically.
 
I use the following code:
 
  CXTPControl* pControl = pToolBar->GetControls()->FindControl(nCmdID);
  if(pControl == NULL) continue;
  pToolBar->GetControls()->Remove(pControl);
 
If I remove all buttons from a toolbar, I want to remove the toolbar also. So I write:
 
  int nTbBtnCount = pToolBar->GetControls()->GetCount();
  if(nTbBtnCount  == 0)
  {
   pToolBar->GetControls()->ClearOriginalControls();
   GetCommandBars()->Remove(pToolBar);
  }
 
This is supposed to be right. However, I find that when the toolbar is visible(sometimes it is not the only case), the toolbar buttons include "close" and "toolbar options" buttons, which are system buttons. So my question is how I know the toolbar has no my own button.



Replies:
Posted By: Oleg
Date Posted: 20 September 2006 at 1:16am
Hello,
 
You can add some method which loop  controls and check if control with pControl->IsTemporary()  == FALSE exists.
 
BOOL HasButtons(CXTPToolBar* pToolBar)
{
  for (int i = 0; i < pToolBar->GetControls()->GetCount(); i++) 
  {
     if (!pToolBar->GetControl(i)->IsTemporary())
        return TRUE;
  }
  return FALSE: 
}


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


Posted By: martypku
Date Posted: 20 September 2006 at 1:43am
Thanks, it works!



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