MainFrm.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:6k
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- // This file is a part of the XTREME TOOLKIT PRO MFC class library.
- // (c)1998-2008 Codejock Software, All Rights Reserved.
- //
- // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
- // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
- // CONSENT OF CODEJOCK SOFTWARE.
- //
- // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
- // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
- // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
- // SINGLE COMPUTER.
- //
- // CONTACT INFORMATION:
- // support@codejock.com
- // http://www.codejock.com
- //
- /////////////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "CustomizeDlg.h"
- #include "CustomizePageTools.h"
- #include "ControlTools.h"
- #include "MainFrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_CREATE()
- ON_WM_CLOSE()
- ON_WM_GETMINMAXINFO()
- //}}AFX_MSG_MAP
- ON_COMMAND(XTP_ID_CUSTOMIZE, OnCustomize)
- ON_XTP_CREATECONTROL()
- ON_XTP_EXECUTE(ID_TOOLS_TOOLITEM, OnToolsItem)
- END_MESSAGE_MAP()
- static UINT indicators[] =
- {
- ID_SEPARATOR, // status line indicator
- ID_INDICATOR_CAPS,
- ID_INDICATOR_NUM,
- ID_INDICATOR_SCRL,
- };
- static const TCHAR _lpszProfile[] = _T("CommandBarsProfile3");
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
- CMainFrame::CMainFrame()
- {
- // TODO: add member initialization code here
- }
- CMainFrame::~CMainFrame()
- {
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- // Create Status bar.
- // Important: All control bars including the Status Bar
- // must be created before CommandBars....
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status barn");
- return -1; // fail to create
- }
- // Initialize the command bars
- if (!InitCommandBars())
- return -1;
- // Get a pointer to the command bars object.
- CXTPCommandBars* pCommandBars = GetCommandBars();
- if(pCommandBars == NULL)
- {
- TRACE0("Failed to create command bars object.n");
- return -1; // fail to create
- }
- // Add the menu bar
- CXTPMenuBar* pMenuBar = pCommandBars->SetMenu(
- _T("Menu Bar"), IDR_MAINFRAME);
- if(pMenuBar == NULL)
- {
- TRACE0("Failed to create menu bar.n");
- return -1; // fail to create
- }
- pMenuBar->SetFlags(xtpFlagAddMDISysPopup);
- pMenuBar->AddMDIMenu(IDR_CUSTOMTYPE);
- // Create ToolBar
- CXTPToolBar* pToolBar = (CXTPToolBar*)
- pCommandBars->Add(_T("Standard"), xtpBarTop);
- if (!pToolBar || !pToolBar->LoadToolBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbarn");
- return -1;
- }
- // Set Office 2003 Theme
- CXTPPaintManager::SetTheme(xtpThemeOffice2003);
- CXTPOffice2003Theme::LoadModernToolbarIcons(IDR_MAINFRAME);
- pCommandBars->GetShortcutManager()->SetAccelerators(IDR_MAINFRAME);
- pCommandBars->GetContextMenus()->Add(IDR_CONTEXT_MENU);
-
- LoadCommandBars(_lpszProfile);
- if (!CCustomizePageTools::LoadTools(_lpszProfile))
- {
- CToolRec toolNotepad(_T("Notepad"), _T("notepad.exe"));
- CToolRec toolPaint(_T("Paint"), _T("mspaint.exe"));
- CToolRec toolExplorer(_T("Explorer"), _T("explorer.exe"));
- CCustomizePageTools::m_lstTools.AddTail(toolNotepad);
- CCustomizePageTools::m_lstTools.AddTail(toolPaint);
- CCustomizePageTools::m_lstTools.AddTail(toolExplorer);
- CCustomizePageTools::UpdateIcons();
- }
- return 0;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- if( !CMDIFrameWnd::PreCreateWindow(cs) )
- return FALSE;
- cs.lpszClass = _T("XTPMainFrame");
- CXTPDrawHelpers::RegisterWndClass(AfxGetInstanceHandle(), cs.lpszClass,
- CS_DBLCLKS, AfxGetApp()->LoadIcon(IDR_MAINFRAME));
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CMDIFrameWnd::AssertValid();
- }
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CMDIFrameWnd::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- void CMainFrame::OnCustomize()
- {
- CXTPCustomizeSheet cs(GetCommandBars());
- CXTPCustomizeKeyboardPage pageKeyboard(&cs);
- cs.AddPage(&pageKeyboard);
- pageKeyboard.AddCategories(IDR_CUSTOMTYPE);
- CXTPCustomizeMenusPage pageMenus(&cs);
- cs.AddPage(&pageMenus);
- CCustomizePageTools pageTools;
- cs.AddPage(&pageTools);
- CXTPCustomizeOptionsPage pageOptions(&cs);
- cs.AddPage(&pageOptions);
- CXTPCustomizeCommandsPage* pCommands = cs.GetCommandsPage();
- pCommands->AddCategories(IDR_CUSTOMTYPE);
- pCommands->InsertAllCommandsCategory();
- pCommands->InsertBuiltInMenus(IDR_CUSTOMTYPE);
- pCommands->InsertNewMenuCategory();
- cs.DoModal();
- }
- void CMainFrame::OnClose()
- {
- SaveCommandBars(_lpszProfile);
- CCustomizePageTools::SaveTools(_lpszProfile);
- CMDIFrameWnd::OnClose();
- }
- int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)
- {
- if (lpCreateControl->nID == ID_TOOLS_TOOLS)
- {
- lpCreateControl->pControl = new CControlTools();
- return TRUE;
- }
- return FALSE;
- }
- void CMainFrame::OnToolsItem(NMHDR* pNMHDR, LRESULT* pResult)
- {
- CXTPControl* pControl = ((NMXTPCONTROL*)pNMHDR)->pControl;
- CToolRec* pTool = (CToolRec*)pControl->GetTag();
- if (!pTool)
- return;
- CString strArg = pTool->m_strArg;
- CString strDir = pTool->m_strDir;
- // launch the process.
- ::ShellExecute( NULL, _T( "open" ), pTool->m_strCmd, strArg, strDir, SW_SHOW);
- *pResult = 1;
- }
- void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
- {
- lpMMI->ptMinTrackSize.x = 400;
- lpMMI->ptMinTrackSize.y = 400;
- CMDIFrameWnd::OnGetMinMaxInfo(lpMMI);
- }