Click here to Skip to main content
15,065,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 ?

C++
void CMerilisaRApp::OnButton()
{
    ((CMainFrame*)(AfxGetApp()->GetMainWnd()))->ApplyPolicy();
}



C++
void CMainFrame::ApplyPolicy(void)
{
    m_wndToolBar.RemoveButton(4);
    
}
Posted

1 solution

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?
   
Comments
adityarao31 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 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 19-Sep-12 10:32am
   
Perhaps what you say Is Right,but I feel Visual Studio 2010 is not so stable version
Richard MacCutchan 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)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900