Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MFC VC++
I have written only this code in MDI application
My toolbar button gets removed by On Button.
The issue is that If I run and test the application to remove the button two or three times , The next time I dont require to press button,toolbar button gets automatically removed.Even after clean and rebuild ,even after closing project and
Rebuiding again toolbar button does not reappear.What is this bug or intellisence
Can anyone tell me What is this ?
 
void CMerilisaRApp::OnButton()
{
    ((CMainFrame*)(AfxGetApp()->GetMainWnd()))->ApplyPolicy();
}
 

void CMainFrame::ApplyPolicy(void)
{
    m_wndToolBar.RemoveButton(4);
    
}
Posted 19-Sep-12 0:45am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You should first add a test for that button existing. You should also use button identifiers rather than indices in case your code gets called multiple times. Are you really sure that you want this removed rather than disabled?
  Permalink  
Comments
adityarao31 at 19-Sep-12 7:34am
   
Yah your suggestion is good ,but I am sure code is inserted at a place and unless
click event is raised it is not getting called,this is something very strange,I am running application and finding that button is not there
Richard MacCutchan at 19-Sep-12 8:34am
   
It's impossible to suggest anything more since we do not know what is going on in your program. Unfortunately the only way to make progress with issues like this is to spend time with the debugger.
adityarao31 at 19-Sep-12 10:32am
   
Perhaps what you say Is Right,but I feel Visual Studio 2010 is not so stable version
Richard MacCutchan at 19-Sep-12 10:46am
   
No, I'm pretty sure you are doing something wrong, but, as I said, without a lot more information it's impossible to guess what.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 CHill60 360
1 Sarvesh Kumar Gupta 238
2 OriginalGriff 218
3 Sergey Alexandrovich Kryukov 153
4 DamithSL 153


Advertise | Privacy | Mobile
Web01 | 2.8.140709.1 | Last Updated 19 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid