Removing ToolBar & Menu
-
Hi, I created an SDI Application.I want remove the Toolbar and Menu from my Application. For that I created a Class from CFrameWnd and attached it to the DocumentTemplate and Changed the dafault menu item as NULL.I am getting the output window with a lot of assertion failure.What all steps I need to follow to remove the ToolBar and Menu from the Application. Help please. SSN
-
Hi, I created an SDI Application.I want remove the Toolbar and Menu from my Application. For that I created a Class from CFrameWnd and attached it to the DocumentTemplate and Changed the dafault menu item as NULL.I am getting the output window with a lot of assertion failure.What all steps I need to follow to remove the ToolBar and Menu from the Application. Help please. SSN
*IF* you are using VC6, Removing Menu: BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { cs.hMenu = NULL; return CFrameWnd::PreCreateWindow(cs); } I belive previous version of MFC were getting p*ssed if you try this... So old aproach was create window with menu. Create own message WM_APP+100, post this message from OnCreate, and when you get this message do something like this: HMENU h = GetMenu(); SetMenu(NULL); DestroyMenu(h); Toolbar is easy, change on create to look something like this: int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; return 0; }
-
Hi, I created an SDI Application.I want remove the Toolbar and Menu from my Application. For that I created a Class from CFrameWnd and attached it to the DocumentTemplate and Changed the dafault menu item as NULL.I am getting the output window with a lot of assertion failure.What all steps I need to follow to remove the ToolBar and Menu from the Application. Help please. SSN
The toolbar you can remove when you are creating your SDI application, you'll find an option, to create or not to create the tool bar there. To remove menu, you have to override
CFrameWnd::LoadFrame()
of your Frame window and place a code inside it, like this:BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) { BOOL bRetVal = CFrameWnd::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext); if(bRetVal){ GetMenu()->DestroyMenu(); SetMenu(NULL); } return bRetVal; }
Philip Patrick "Two beer or not two beer?" Web-site: www.saintopatrick.com
-
*IF* you are using VC6, Removing Menu: BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { cs.hMenu = NULL; return CFrameWnd::PreCreateWindow(cs); } I belive previous version of MFC were getting p*ssed if you try this... So old aproach was create window with menu. Create own message WM_APP+100, post this message from OnCreate, and when you get this message do something like this: HMENU h = GetMenu(); SetMenu(NULL); DestroyMenu(h); Toolbar is easy, change on create to look something like this: int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; return 0; }