mfc删除默认工具栏(mfc remove default toolbar)

编程入门 行业动态 更新时间:2024-10-20 05:20:26
mfc删除默认工具栏(mfc remove default toolbar)

我在学校项目的mfc制作简单的桌面游戏,我设法使我的应用程序全屏并删除菜单栏但我无法找到如何从我的应用程序或状态栏中删除默认的内置工具栏。 我尝试了所有想到的东西...是否有某种get函数可以从你的CWnd对象调用来检索工具栏和状态栏?

I've making simple desktop game in mfc for school project, I've managed to make my app be full screen and to remove menu bar but I can't find out how to remove default built in toolbar from my app or status bar. I tried everything that came across my mind...is there some kind of get function to call from your CWnd object to retrieve toolbar and status bar?

最满意答案

ToolBar和StatusBar的创建在CMainFrame类中。 如果您不需要它们,可以轻松删除它们,如下所示:

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; // *** creation of ToolBar starts, just remark/delete the whole block if you dont't want it if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } // *** creation of ToolBar ends ------------------------------------------------------- // *** creation of StatusBar starts, just remark/delete the whole block if you dont't want it if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } // *** creation of StatusBar ends ------------------------------------------------------- // *** you have to remark/delete these lines too, if you removed the ToolBar above m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); // *** ToolBar extra ends ------------------------------------------------------- return 0;

}

The creation of ToolBar and StatusBar is inside the CMainFrame class. You can easily remove them if you do not need them as follows:

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; // *** creation of ToolBar starts, just remark/delete the whole block if you dont't want it if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } // *** creation of ToolBar ends ------------------------------------------------------- // *** creation of StatusBar starts, just remark/delete the whole block if you dont't want it if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } // *** creation of StatusBar ends ------------------------------------------------------- // *** you have to remark/delete these lines too, if you removed the ToolBar above m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); // *** ToolBar extra ends ------------------------------------------------------- return 0;

}

更多推荐

本文发布于:2023-08-04 14:17:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1415982.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:工具栏   mfc   remove   toolbar   default

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!