// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#include "stdafx.h"
#include "VisualStudioDemo.h"
#include "FindComboBox.h"
#include "OptionsDlg.h"
#include "MainFrm.h"
#include "ChildFrm.h"
#include "UndoBar.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWndEx)
const int iMaxUserToolbars = 10;
const UINT uiFirstUserToolBarId = AFX_IDW_CONTROLBAR_FIRST + 40;
const UINT uiLastUserToolBarId = uiFirstUserToolBarId + iMaxUserToolbars - 1;
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWndEx)
ON_WM_CREATE()
ON_COMMAND(ID_WINDOW_MANAGER, OnWindowManager)
ON_COMMAND(ID_HELP_KEYBOARDMAP, OnHelpKeyboardmap)
ON_COMMAND(ID_FILE_NEW_PROJECT, OnFileNewProject)
ON_COMMAND(ID_FILE_NEW_BLANK_SOLUTION, OnFileNewBlankSolution)
ON_COMMAND(ID_FILE_OPEN_SOLUTION, OnFileOpenSolution)
ON_COMMAND(ID_FILE_CLOSE_SOLUTION, OnFileCloseSolution)
ON_COMMAND(ID_FILE_SAVE_ALL, OnFileSaveAll)
ON_COMMAND(ID_VIEW_REFRESH, OnViewRefresh)
ON_COMMAND(ID_TOOLS_CONNECT_TO_DATABASE, OnToolsConnectToDatabase)
ON_COMMAND(ID_TOOLS_DEBUG_PROCESSES, OnToolsDebugProcesses)
ON_COMMAND(ID_VIEW_FULLSCREEN, OnViewFullScreen)
ON_COMMAND(ID_TOOLS_OPTIONS, OnToolsOptions)
ON_COMMAND(ID_HELP_WEB, OnHelpWeb)
ON_COMMAND(ID_MDI_MOVE_TO_NEXT_GROUP, OnMdiMoveToNextGroup)
ON_COMMAND(ID_MDI_MOVE_TO_PREV_GROUP, OnMdiMoveToPrevGroup)
ON_COMMAND(ID_MDI_NEW_HORZ_TAB_GROUP, OnMdiNewHorzTabGroup)
ON_COMMAND(ID_MDI_NEW_VERT_GROUP, OnMdiNewVertGroup)
ON_COMMAND(ID_MDI_CANCEL, OnMdiCancel)
ON_WM_CLOSE()
ON_COMMAND(ID_VIEW_CLASS, OnViewClass)
ON_UPDATE_COMMAND_UI(ID_VIEW_CLASS, OnUpdateViewClass)
ON_COMMAND(ID_VIEW_FILE, OnViewFile)
ON_UPDATE_COMMAND_UI(ID_VIEW_FILE, OnUpdateViewFile)
ON_COMMAND(ID_VIEW_RESOURCE, OnViewResource)
ON_UPDATE_COMMAND_UI(ID_VIEW_RESOURCE, OnUpdateViewResource)
ON_COMMAND(ID_VIEW_PROPERTIES, OnViewProperties)
ON_UPDATE_COMMAND_UI(ID_VIEW_PROPERTIES, OnUpdateViewProperties)
ON_COMMAND(ID_VIEW_OUTPUT, OnViewOutput)
ON_UPDATE_COMMAND_UI(ID_VIEW_OUTPUT, OnUpdateViewOutput)
ON_COMMAND(ID_VIEW_WATCH, OnViewWatch)
ON_UPDATE_COMMAND_UI(ID_VIEW_WATCH, OnUpdateViewWatch)
ON_COMMAND(ID_VIEW_DYNAMICHELP, OnViewDynamichelp)
ON_UPDATE_COMMAND_UI(ID_VIEW_DYNAMICHELP, OnUpdateViewDynamichelp)
ON_COMMAND(ID_MDI_TABBED_DOCUMENT, OnMdiTabbedDocument)
ON_UPDATE_COMMAND_UI(ID_MDI_TABBED_DOCUMENT, OnUpdateMdiTabbedDocument)
ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize)
ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset)
ON_REGISTERED_MESSAGE(AFX_WM_ON_GET_TAB_TOOLTIP, OnGetTabToolTip)
ON_REGISTERED_MESSAGE(AFX_WM_CUSTOMIZEHELP, OnHelpCustomizeToolbars)
ON_REGISTERED_MESSAGE(AFX_WM_CREATETOOLBAR, OnToolbarCreateNew)
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()
{
CMFCPopupMenu::SetForceShadow(TRUE);
m_bCanConvertControlBarToMDIChild = TRUE;
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1)
return -1;
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005));
CMFCToolBarComboBoxButton::SetFlatMode();
// Load toolbar user images:
if (m_UserImages.Load(_T(".\\UserImages.bmp")))
{
CMFCToolBar::SetUserImages(&m_UserImages);
}
CMFCToolBar::EnableQuickCustomization();
// Create menu bar:
if (!m_wndMenuBar.Create(this))
{
TRACE0("Failed to create menubar\n");
return -1; // fail to create
}
m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY);
// Menu will not take the focus on activation:
CMFCPopupMenu::SetForceMenuFocus(FALSE);
// Create Resource toolbar:
if (!m_wndToolbarResource.Create(this, WS_CHILD|CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE|CBRS_SIZE_DYNAMIC| CBRS_GRIPPER | CBRS_BORDER_3D, IDR_TOOLBAR_RESOURCE) || !m_wndToolbarResource.LoadToolBar(IDR_TOOLBAR_RESOURCE))
{
TRACE0("Failed to create build toolbar\n");
return FALSE; // fail to create
}
// Create main toolbar:
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
}
BOOL bValidString;
CString strMainToolbarTitle;
bValidString = strMainToolbarTitle.LoadString(IDS_MAIN_TOOLBAR);
m_wndToolBar.SetWindowText(strMainToolbarTitle);
// Create Build toolbar:
if (!m_wndToolbarBuild.Create(this, WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE|CBRS_SIZE_DYNAMIC| CBRS_GRIPPER | CBRS_BORDER_3D, ID_VIEW_BUILD_TOOLBAR) || !m_wndToolbarBuild.LoadToolBar(IDR_BUILD))
{
TRACE0("Failed to create build toolbar\n");
return FALSE; // fail to create
}
CString strBuildToolbarTitle;
bValidString = strBuildToolbarTitle.LoadString(IDS_BUILD_TOOLBAR);
m_wndToolbarBuild.SetWindowText(strBuildToolbarTitle);
// Create Edit toolbar:
if (!m_wndToolbarEdit.Create(this, WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE|CBRS_SIZE_DYNAMIC| CBRS_GRIPPER | CBRS_BORDER_3D, ID_VIEW_EDIT_TOOLBAR) || !m_wndToolbarEdit.LoadToolBar(IDR_EDIT))
{
TRACE0("Failed to create edit toolbar\n");
return FALSE; // fail to create
}
CString strEditToolbarTitle;
bValidString = strEditToolbarTitle.LoadString(IDS_EDIT_TOOLBAR);
m_wndToolbarEdit.SetWindowText(strEditToolbarTitle);
// Load menu items images(not placed on the standard toolbars):
CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES);
// Create status bar:
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
}
m_wndStatusBar.SetPaneStyle(0, SBPS_STRETCH);
// Create docking control windows:
if (!CreateDockingBars())
{
return -1;
}
m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, _T("Customize..."));
m_wndToolbarBuild.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, _T("Customize..."));
m_wndToolbarEdit.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, _T("Customize..."));
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolbarBuild.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolbarEdit.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolbarResource.EnableDocking(CBRS_ALIGN_ANY);
m_wndClassView.EnableDocking(CBRS_ALIGN_ANY);
m_wndResourceView.EnableDocking(CBRS_ALIGN_ANY);
m_wndFileView.EnableDocking(CBRS_ALIGN_ANY);
m_wndOutputView.EnableDocking(CBRS_ALIGN_ANY);
m_wndDynamicHelpView.EnableDocking(CBRS_ALIGN_ANY);
m_wndPropertiesBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndWatchBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
EnableAutoHidePanes(CBRS_ALIGN_ANY);
DockPane(&m_wndMenuBar);
DockPane(&m_wndToolBar);
DockPane(&m_wndPropertiesBar);
DockPane(&m_wndToolbarBuild);
DockPaneLeftOf(&m_wndToolbarEdit, &m_wndToolbarBuild);
DockPane(&m_wndClassView);
CDockablePa