![]() |
About Dynamically Remove Button From ToolBar |
Post Reply ![]() |
Author | |
martypku ![]() Newbie ![]() Joined: 17 September 2006 Status: Offline Points: 11 |
![]() ![]() ![]() ![]() ![]() 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.
|
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
martypku ![]() Newbie ![]() Joined: 17 September 2006 Status: Offline Points: 11 |
![]() ![]() ![]() ![]() ![]() |
Thanks, it works!
|
|
![]() |
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 |