MFC取消MDI、SDI的状态栏、工具栏、菜单栏

来源:互联网 发布:淘宝情趣内衣模特原片 编辑:程序博客网 时间:2024/06/03 02:48

MFC取消MDI、SDI的状态栏、工具栏、菜单栏

蒋明原

一、取消MDI状态栏、工具栏、菜单栏

a) 在CMainFrame类里面增加WM_ACTIVE消息处理,在OnActive消息处理函数里面增加CWnd::SetMenu(NULL);

void CMainFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)

{

CMDIFrameWnd::OnActivate(nState, pWndOther, bMinimized);

// TODO: Add your message handler code here

CWnd::SetMenu(NULL);

}

b) 在CMainFrame类,OnCreate消息处理函数里面注释添加工具栏、状态栏的代码,OnCreate消息处理函数成为:

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)

{

if (CMDIFrameWnd::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

}

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

m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);

EnableDocking(CBRS_ALIGN_ANY);

DockControlBar(&m_wndToolBar);

*/

return 0;

}

二、取消SDI状态栏、工具栏、菜单栏

a) 同样也是操作CMainFrame类,在OnPreCreateWindow里面增加cs.hMenu=NULL;

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;

}

b) 在CMainFrame类,OnCreate消息处理函数里面注释添加工具栏、状态栏的代码,OnCreate消息处理函数成为:

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

}

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

m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);

EnableDocking(CBRS_ALIGN_ANY);

DockControlBar(&m_wndToolBar);

*/

return 0;

}

原创粉丝点击