MainFrm.cpp
上传用户:szcysw
上传日期:2013-03-11
资源大小:6752k
文件大小:3k
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "DialogBar.h"
- #include "MainFrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- ON_WM_CREATE()
- //响应来自工具“测试”按钮的信息
- ON_COMMAND(IDC_BUTTON_INTOOLBAR,RefectMessage)
- //禁用或启用“测试”按钮
- ON_UPDATE_COMMAND_UI(IDC_BUTTON_INTOOLBAR, OnupdataButton)
- END_MESSAGE_MAP()
- static UINT indicators[] =
- {
- ID_SEPARATOR, // status line indicator
- ID_INDICATOR_CAPS,
- ID_INDICATOR_NUM,
- ID_INDICATOR_SCRL,
- };
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
- CMainFrame::CMainFrame()
- {
- ENABLE=1;
-
- }
- CMainFrame::~CMainFrame()
- {
- }
- void CMainFrame::OnupdataButton(CCmdUI* pCmdUI)
- {
- if(ENABLE)
- {
- //禁用控件
- pCmdUI->Enable(0);
- ENABLE=!ENABLE;
- }
- else
- {
- //启用用控件
- pCmdUI->Enable(1);
- ENABLE=!ENABLE;
- }
- }
- 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 toolbarn");
- return -1; // fail to create
- }
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status barn");
- return -1; // fail to create
- }
-
- //创建对话框工具条
- //设置基对齐方式在左边对齐,支持快速提示,支持动态停泊
- if( !DialogTooBar.Create( this, IDD_DIALOG_TOOLBAR, CBRS_LEFT|CBRS_TOOLTIPS|CBRS_FLYBY, ID_MYDIALOGBAR) )
- {
-
- AfxMessageBox("对话框工具条创建出错");
- return -1; // fail to create
- }
- EnableDocking(CBRS_ALIGN_ANY) ;
- //启用对话框工具条的任意停泊特性
- DialogTooBar.EnableDocking(CBRS_ALIGN_ANY);
- //将对话框工具条停放在窗左边
- DockControlBar(&DialogTooBar);
- // TODO: Delete these three lines if you don't want the toolbar to
- // be dockable
- m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
-
- DockControlBar(&m_wndToolBar);
- return 0;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- if( !CFrameWnd::PreCreateWindow(cs) )
- return FALSE;
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CFrameWnd::AssertValid();
- }
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CFrameWnd::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- void CMainFrame::RefectMessage()
- {
- AfxMessageBox("主窗口收到来自于对话框工具条信息");
- }
- BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam)
- {
- // TODO: Add your specialized code here and/or call the base class
-
- return CFrameWnd::OnCommand(wParam, lParam);
- }