VC去掉单文档中的菜单,工具栏,状态栏


一、去掉菜单栏

在单文档程序CMainFrame类中找到PreCreateWindow(CREATESTRUCT& cs)函数,按下面加入代码。

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
   return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.hMenu = NULL;//加上这句即可去掉菜单
return TRUE;
}

二、去掉工具栏:

在单文档程序CMainFrame类中找到OnCreate(LPCREATESTRUCT lpCreateStruct)函数,按下面代码进行注释。

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
   return -1;

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
}

// TODO: Delete these three lines if you don't want the toolbar to
// be dockable

return 0;
}

 

三、去掉状态栏:

在单文档程序CMainFrame类中找到OnCreate(LPCREATESTRUCT lpCreateStruct)函数,按下面代码进行注释。

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
   return -1;
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
}

// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);

return 0;
}

你可能感兴趣的:(VC去掉单文档中的菜单,工具栏,状态栏)