MainFrm.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:29k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. // This file is a part of the XTREME TOOLKIT PRO MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include "GUI_VisualStudio.h"
  22. #include "MainFrm.h"
  23. #include "DynamicHelpView.h"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CMainFrame
  31. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  32. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  33. //{{AFX_MSG_MAP(CMainFrame)
  34. ON_WM_CREATE()
  35. ON_COMMAND(ID_WINDOW_AUTOHIDEALL, OnWindowAutohideall)
  36. ON_COMMAND(ID_WINDOW_MORE, OnWindowMore)
  37. ON_WM_CLOSE()
  38. //}}AFX_MSG_MAP
  39. ON_MESSAGE(XTPWM_DOCKINGPANE_NOTIFY, OnDockingPaneNotify)
  40. ON_COMMAND(ID_VIEW_FULLSCREEN, OnFullScreen)
  41. ON_UPDATE_COMMAND_UI(ID_VIEW_FULLSCREEN, OnUpdateFullScreen)
  42. ON_COMMAND_RANGE(ID_VIEW_SOLUTIONEXPLORER, ID_HELP_DYNAMICHELP, OnShowView)
  43. ON_COMMAND_RANGE(ID_FILE_NEW_PROJECT + 1, 200, OnEmptyCommandRange)
  44. ON_COMMAND(XTP_ID_CUSTOMIZE, OnCustomize)
  45. ON_XTP_CREATECONTROL()
  46. ON_COMMAND_RANGE(ID_THEME_VC6, ID_THEME_VC9, OnTheme)
  47. ON_UPDATE_COMMAND_UI_RANGE(ID_THEME_VC6, ID_THEME_VC9, OnUpdateTheme)
  48. #ifdef _XTP_INCLUDE_SKINFRAMEWORK
  49. ON_COMMAND_RANGE(ID_SKINFRAMEWORK_VISTABLUE, ID_SKINFRAMEWORK_SYSTEM, OnSkinFramework)
  50. ON_COMMAND_RANGE(ID_THEME_SKINFRAMEWORK, ID_THEME_SKINFRAMEWORK, OnEmptyCommandRange)
  51. #endif
  52. ON_XTP_EXECUTE(ID_EDIT_STATE, OnEditState)
  53. ON_UPDATE_COMMAND_UI(ID_EDIT_STATE, OnUpdateEditState)
  54. ON_XTP_EXECUTE(ID_EDIT_PLATFORM, OnEditPlatform)
  55. ON_UPDATE_COMMAND_UI(ID_EDIT_PLATFORM, OnUpdateEditPlatform)
  56. ON_WM_ACTIVATE()
  57. END_MESSAGE_MAP()
  58. static UINT indicators[] =
  59. {
  60. ID_SEPARATOR,           // status line indicator
  61. ID_INDICATOR_CAPS,
  62. ID_INDICATOR_NUM,
  63. ID_INDICATOR_SCRL,
  64. };
  65. /////////////////////////////////////////////////////////////////////////////
  66. // CMainFrame construction/destruction
  67. CMainFrame::CMainFrame()
  68. {
  69. m_nState = 1;
  70. m_nPlatform = 0;
  71. m_bFullScreen = FALSE;
  72. // get path of executable
  73. TCHAR szBuff[_MAX_PATH];
  74. VERIFY(::GetModuleFileName(AfxGetInstanceHandle(), szBuff, _MAX_PATH));
  75. LPTSTR lpszExt = _tcsrchr(szBuff, '.');
  76. lstrcpy(lpszExt, _T(".xml"));
  77. m_strIniFileName = szBuff;
  78. m_pFullScreenLayout = NULL;
  79. m_rcMainFrame.SetRectEmpty();
  80. m_nTheme = ID_THEME_VC9;
  81. #ifdef _XTP_INCLUDE_SKINFRAMEWORK
  82. XTPSkinManager()->GetResourceFile()->SetModuleHandle(AfxGetInstanceHandle());
  83. #endif
  84. }
  85. CMainFrame::~CMainFrame()
  86. {
  87. if (m_pFullScreenLayout)
  88. {
  89. delete m_pFullScreenLayout;
  90. }
  91. }
  92. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  93. {
  94. if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  95. return -1;
  96. if (!m_wndStatusBar.Create(this) ||
  97. !m_wndStatusBar.SetIndicators(indicators,
  98.   sizeof(indicators)/sizeof(UINT)))
  99. {
  100. TRACE0("Failed to create status barn");
  101. return -1;      // fail to create
  102. }
  103. if (!InitCommandBars())
  104. return -1;
  105. CXTPPaintManager::SetTheme(xtpThemeVisualStudio2008);
  106. CXTPCommandBars* pCommandBars = GetCommandBars();
  107. CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAINFRAME);
  108. pMenuBar->SetFlags(xtpFlagIgnoreSetMenuMessage);
  109. CXTPToolBar* pCommandBar = (CXTPToolBar*)pCommandBars->Add(_T("Standard"), xtpBarTop);
  110. if (!pCommandBar ||
  111. !pCommandBar->LoadToolBar(IDR_MAINFRAME))
  112. {
  113. TRACE0("Failed to create toolbarn");
  114. return -1;
  115. }
  116. CXTPToolBar* pWebBar = (CXTPToolBar*)pCommandBars->Add(_T("Web"), xtpBarTop);
  117. if (!pWebBar ||
  118. !pWebBar->LoadToolBar(IDR_TOOLBAR_WEB))
  119. {
  120. TRACE0("Failed to create toolbarn");
  121. return -1;
  122. }
  123. CXTPToolBar* pThemeBar = (CXTPToolBar*)pCommandBars->Add(_T("Theme"), xtpBarTop);
  124. if (!pThemeBar ||
  125. !pThemeBar->LoadToolBar(IDR_TOOLBAR_THEME))
  126. {
  127. TRACE0("Failed to create toolbarn");
  128. return -1;
  129. }
  130. DockRightOf(pThemeBar, pWebBar);
  131. CXTPToolBar* pFullScreenBar = (CXTPToolBar*)pCommandBars->Add(_T("Full Screen"), xtpBarTop);
  132. if (!pFullScreenBar ||
  133. !pFullScreenBar->LoadToolBar(IDR_TOOLBAR_FULLSCREEN))
  134. {
  135. TRACE0("Failed to create toolbarn");
  136. return -1;
  137. }
  138. pFullScreenBar->SetVisible(FALSE);
  139. XTPPaintManager()->GetIconsInfo()->bUseDisabledIcons = TRUE;
  140. XTPImageManager()->SetIcons(IDR_TOOLBAR_EXT);
  141. pCommandBars->GetCommandBarsOptions()->ShowKeyboardCues(xtpKeyboardCuesShowWindowsDefault);
  142. pCommandBars->GetToolTipContext()->SetStyle(xtpToolTipOffice);
  143. pCommandBars->GetShortcutManager()->SetAccelerators(IDR_MAINFRAME);
  144. CreateToolBox();
  145. m_paneManager.InstallDockingPanes(this);
  146. m_paneManager.SetTheme(xtpPaneThemeVisualStudio2005);
  147. m_paneManager.CreatePane(
  148. ID_WINDOWS_OUTPUT, CRect(0, 0, 150, 120), xtpPaneDockBottom);
  149. CXTPDockingPane* paneToolBox = m_paneManager.CreatePane(
  150. ID_VIEW_TOOLBOX, CRect(0, 0, 200, 120), xtpPaneDockRight);
  151. CXTPDockingPane* paneClassView = m_paneManager.CreatePane(
  152. ID_VIEW_CLASSVIEW, CRect(0, 0, 230, 140), xtpPaneDockLeft);
  153. CXTPDockingPane* paneSolutionExplorer = m_paneManager.CreatePane(
  154. ID_VIEW_SOLUTIONEXPLORER, CRect(0, 0, 230, 140), xtpPaneDockLeft);
  155. CXTPDockingPane* paneResourceView = m_paneManager.CreatePane(
  156. ID_VIEW_RESOURCEVIEW, CRect(0, 0, 230, 140), xtpPaneDockLeft);
  157. CXTPDockingPane* paneHelpView =m_paneManager.CreatePane(
  158. ID_HELP_DYNAMICHELP, CRect(0, 0, 210, 140), xtpPaneDockBottom, paneToolBox);
  159. paneHelpView->Close();
  160. m_paneManager.AttachPane(paneClassView, paneSolutionExplorer);
  161. m_paneManager.AttachPane(paneResourceView, paneClassView);
  162. paneClassView->Select();
  163. m_paneManager.CreatePane(
  164. ID_VIEW_PROPERTIESWINDOW, CRect(0, 0, 180, 140), xtpPaneDockBottom, paneClassView);
  165. m_paneManager.EnableKeyboardNavigate();
  166. //CXTPPropExchangeIniFile px(TRUE, 0, _T("Settings")); // To serialize to ini file
  167. CXTPPropExchangeXMLNode px(TRUE, 0, _T("Settings"));   // To serialize to XML file
  168. if (px.LoadFromFile(m_strIniFileName))
  169. {
  170. CXTPPropExchangeSection pxTaskPanel(px.GetSection(_T("TaskPanel")));
  171. m_wndTaskPanel.GetGroups()->DoPropExchange(&pxTaskPanel);
  172. CXTPPropExchangeSection pxNormalLayout(px.GetSection(_T("NormalLayout")));
  173. ExchangeLayout(&pxNormalLayout);
  174. m_pFullScreenLayout = DYNAMIC_DOWNCAST(CXTPPropExchangeXMLNode, px.GetSection(_T("FullScreenLayout")));
  175. ASSERT(m_pFullScreenLayout);
  176. }
  177. else
  178. {
  179. ResetToolboxItems();
  180. }
  181. CXTPImageManager* pImageManager = pCommandBars->GetImageManager();
  182. pImageManager->InternalAddRef();
  183. m_paneManager.SetImageManager(pImageManager);
  184. m_paneManager.SetAlphaDockingContext(TRUE);
  185. m_paneManager.SetShowDockingContextStickers(TRUE);
  186. m_paneManager.SetShowContentsWhileDragging(TRUE);
  187. m_paneManager.SetDefaultPaneOptions(xtpPaneHasMenuButton);
  188. VERIFY(m_MTIClientWnd.Attach(this, TRUE));
  189. m_MTIClientWnd.EnableToolTips();
  190. m_MTIClientWnd.GetPaintManager()->m_bShowIcons = FALSE;
  191. m_MTIClientWnd.SetNewTabPosition(xtpWorkspaceNewTabLeftMost);
  192. m_MTIClientWnd.SetFlags(xtpWorkspaceHideArrowsAlways | xtpWorkspaceShowActiveFiles);
  193. return 0;
  194. }
  195. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  196. {
  197. if( !CMDIFrameWnd::PreCreateWindow(cs) )
  198. return FALSE;
  199. cs.lpszClass = _T("XTPMainFrame");
  200. CXTPDrawHelpers::RegisterWndClass(AfxGetInstanceHandle(), cs.lpszClass, 
  201. CS_DBLCLKS, AfxGetApp()->LoadIcon(IDR_MAINFRAME));
  202. return TRUE;
  203. }
  204. /////////////////////////////////////////////////////////////////////////////
  205. // CMainFrame diagnostics
  206. #ifdef _DEBUG
  207. void CMainFrame::AssertValid() const
  208. {
  209. CMDIFrameWnd::AssertValid();
  210. }
  211. void CMainFrame::Dump(CDumpContext& dc) const
  212. {
  213. CMDIFrameWnd::Dump(dc);
  214. }
  215. #endif //_DEBUG
  216. /////////////////////////////////////////////////////////////////////////////
  217. // CMainFrame message handlers
  218. CXTPTaskPanelGroup* CMainFrame::CreateToolboxGroup(UINT nID)
  219. {
  220. CXTPTaskPanelGroup* pFolder = m_wndTaskPanel.AddGroup(nID);
  221. CXTPTaskPanelGroupItem* pPointer = pFolder->AddLinkItem(ID_TOOLBOXITEM_POINTER, 0);
  222. pPointer->SetItemSelected(TRUE);
  223. pPointer->AllowDrag(FALSE);
  224. pPointer->AllowDrop(FALSE);
  225. return pFolder;
  226. }
  227. void CMainFrame::ResetToolboxItems()
  228. {
  229. m_wndTaskPanel.GetGroups()->Clear(FALSE);
  230. CXTPTaskPanelGroup* pFolderPropertyPanes = CreateToolboxGroup(ID_TOOLBOXFOLDER_PROPERTYPANES);
  231. CXTPTaskPanelGroup* pFolderData = CreateToolboxGroup(ID_TOOLBOXFOLDER_DATA);
  232. pFolderData->AddLinkItem(ID_TOOLBOXITEM_DATASET                 ,26);
  233. pFolderData->AddLinkItem(ID_TOOLBOXITEM_OLEDBDATAADAPTER        ,27);
  234. pFolderData->AddLinkItem(ID_TOOLBOXITEM_OLEDBCONNECTION         ,28);
  235. pFolderData->AddLinkItem(ID_TOOLBOXITEM_OLEDBCOMMAND            ,29);
  236. pFolderData->AddLinkItem(ID_TOOLBOXITEM_SQLDATAADAPTER          ,30);
  237. pFolderData->AddLinkItem(ID_TOOLBOXITEM_SQLCONNECTION           ,31);
  238. pFolderData->AddLinkItem(ID_TOOLBOXITEM_SQLCOMMAND              ,32);
  239. pFolderData->AddLinkItem(ID_TOOLBOXITEM_DATAVIEW                ,33);
  240. CXTPTaskPanelGroup* pFolderComponents = CreateToolboxGroup(ID_TOOLBOXFOLDER_COMPONENTS);
  241. pFolderComponents->AddLinkItem(ID_TOOLBOXITEM_FILESYSTEMWATCHER     ,34);
  242. pFolderComponents->AddLinkItem(ID_TOOLBOXITEM_EVENTLOG              ,35);
  243. pFolderComponents->AddLinkItem(ID_TOOLBOXITEM_DIRECTORYENTRY        ,36);
  244. pFolderComponents->AddLinkItem(ID_TOOLBOXITEM_DIRECTORYSEARCHER     ,37);
  245. pFolderComponents->AddLinkItem(ID_TOOLBOXITEM_MESSAGEQUEUE          ,38);
  246. pFolderComponents->AddLinkItem(ID_TOOLBOXITEM_PERFORMANCECOUNTER    ,39);
  247. pFolderComponents->AddLinkItem(ID_TOOLBOXITEM_PROCESS               ,40);
  248. pFolderComponents->AddLinkItem(ID_TOOLBOXITEM_SERVICECONTROLLER     ,41);
  249. pFolderComponents->AddLinkItem(ID_TOOLBOXITEM_TIMER                 ,42);
  250. CXTPTaskPanelGroup* pFolderWindowsForms = CreateToolboxGroup(ID_TOOLBOXFOLDER_WINDOWSFORMS);
  251. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_BUTTON,             1);
  252. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_CHECK_BOX,              2);
  253. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_EDIT_CONTROL,           3);
  254. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_COMBO_BOX,              4);
  255. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_LIST_BOX,               5);
  256. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_GROUP_BOX,              6);
  257. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_RADIO_BUTTON,           7);
  258. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_STATIC_TEXT,            8);
  259. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_PICTURE_CONTROL,        9);
  260. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_HORIZONTAL_SCROLL_BAR,  10);
  261. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_VERTICAL_SCROLL_BAR,    11);
  262. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_SLIDER_CONTROL,     12);
  263. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_SPIN_CONTROL,           13);
  264. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_PROGRESS_CONTROL,       14);
  265. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_HOT_KEY,                15);
  266. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_LIST_CONTROL,           16);
  267. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_TREE_CONTROL,           17);
  268. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_TAB_CONTROL,            18);
  269. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_ANIMATION_CONTROL,      19);
  270. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_RICH_EDIT_CONTROL,      20);
  271. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_DATE_TIME_PICKER,       21);
  272. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_MONTH_CALENDAR_CONTROL,22);
  273. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_IP_ADDRESS_CONTROL, 23);
  274. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_EXTENDED_COMBO_BOX, 24);
  275. pFolderWindowsForms->AddLinkItem(ID_TOOLBOXITEM_CUSTOM_CONTROL,     25);
  276. CreateToolboxGroup(ID_TOOLBOXFOLDER_CLIPBOARDRING);
  277. CreateToolboxGroup(ID_TOOLBOXFOLDER_GENERAL);
  278. pFolderPropertyPanes->SetExpanded(TRUE);
  279. }
  280. CWnd* CMainFrame::CreateToolBox()
  281. {
  282. if (!m_wndTaskPanel.GetSafeHwnd())
  283. {
  284. if (!m_wndTaskPanel.Create(WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN, CRect(0, 0, 0, 0), this, 0))
  285. return FALSE;
  286. m_wndTaskPanel.SetOwner(this);
  287. m_wndTaskPanel.GetImageManager()->SetIcons(IDB_TOOLBOXICONS, 0, 0, CSize(16, 16));
  288. m_wndTaskPanel.SetBehaviour(xtpTaskPanelBehaviourExplorer);
  289. m_wndTaskPanel.SetTheme(xtpTaskPanelThemeToolboxWhidbey);
  290. m_wndTaskPanel.SetHotTrackStyle(xtpTaskPanelHighlightItem);
  291. m_wndTaskPanel.SetSelectItemOnFocus(TRUE);
  292. m_wndTaskPanel.SetSingleSelection();
  293. m_wndTaskPanel.AllowDrag(TRUE);
  294. }
  295. return &m_wndTaskPanel;
  296. }
  297. void CMainFrame::ShowDockingPanePopupMenu(CXTPDockingPane* pPopupPane, CPoint pt, LPRECT lprcExclude)
  298. {
  299. CMenu menu;
  300. VERIFY(menu.LoadMenu(IDR_POPUP_PANES));
  301. CMenu* pPopup = menu.GetSubMenu(0);
  302. if (pPopupPane->IsHidden())
  303. {
  304. pPopup->CheckMenuItem(ID_POPUP_AUTOHIDE, MF_BYCOMMAND|MF_CHECKED);
  305. pPopup->EnableMenuItem(ID_POPUP_FLOATING, MF_BYCOMMAND|MF_DISABLED);
  306. pPopup->EnableMenuItem(ID_POPUP_DOCKABLE, MF_BYCOMMAND|MF_DISABLED);
  307. }
  308. else if (pPopupPane->GetOptions() & xtpPaneNoDockable)
  309. {
  310. pPopup->CheckMenuItem(ID_POPUP_FLOATING, MF_BYCOMMAND|MF_CHECKED);
  311. }
  312. else
  313. {
  314. pPopup->CheckMenuItem(ID_POPUP_DOCKABLE, MF_BYCOMMAND|MF_CHECKED);
  315. }
  316. TPMPARAMS tpm;
  317. tpm.cbSize = sizeof(TPMPARAMS);
  318. tpm.rcExclude = lprcExclude ? *lprcExclude : CRect(0, 0, 0, 0);
  319. int nCommand = GetCommandBars()->TrackPopupMenuEx(pPopup, TPM_RIGHTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD, pt.x, pt.y, NULL, &tpm);
  320. switch (nCommand)
  321. {
  322. case ID_POPUP_HIDE:
  323. pPopupPane->Close();
  324. break;
  325. case ID_POPUP_AUTOHIDE:
  326. m_paneManager.ToggleAutoHide(pPopupPane);
  327. break;
  328. case ID_POPUP_DOCKABLE:
  329. if (pPopupPane->GetOptions() & xtpPaneNoDockable)
  330. {
  331. pPopupPane->SetOptions(pPopupPane->GetOptions() & ~xtpPaneNoDockable);
  332. }
  333. break;
  334. case ID_POPUP_FLOATING:
  335. if ((pPopupPane->GetOptions() & xtpPaneNoDockable) == 0)
  336. {
  337. if (!pPopupPane->IsFloating())
  338. m_paneManager.ToggleDocking(pPopupPane);
  339. pPopupPane->SetOptions(pPopupPane->GetOptions() | xtpPaneNoDockable);
  340. }
  341. break;
  342. }
  343. }
  344. LRESULT CMainFrame::OnDockingPaneNotify(WPARAM wParam, LPARAM lParam)
  345. {
  346. if (wParam == XTP_DPN_SHOWWINDOW)
  347. {
  348. CXTPDockingPane* pPane = (CXTPDockingPane*)lParam;
  349. if (!pPane->IsValid())
  350. {
  351. switch (pPane->GetID())
  352. {
  353. case ID_VIEW_TOOLBOX:
  354. pPane->Attach(CreateToolBox());
  355. break;
  356. case ID_VIEW_CLASSVIEW:
  357. if (!m_wndClassView.GetSafeHwnd())
  358. {
  359. m_wndClassView.Create(_T("STATIC"), NULL, WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, CXTPEmptyRect(), this, 0);
  360. }
  361. pPane->Attach(&m_wndClassView);
  362. break;
  363. case ID_VIEW_RESOURCEVIEW:
  364. if (!m_wndResourceView.GetSafeHwnd())
  365. {
  366. m_wndResourceView.Create(_T("STATIC"), NULL, WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, CXTPEmptyRect(), this, 0);
  367. }
  368. pPane->Attach(&m_wndResourceView);
  369. break;
  370. case ID_VIEW_SOLUTIONEXPLORER:
  371. if (!m_wndSolutionExplorer.GetSafeHwnd())
  372. {
  373. m_wndSolutionExplorer.Create(_T("STATIC"), NULL, WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, CXTPEmptyRect(), this, 0);
  374. }
  375. pPane->Attach(&m_wndSolutionExplorer);
  376. break;
  377. case ID_VIEW_PROPERTIESWINDOW:
  378. if (!m_wndProperties.GetSafeHwnd())
  379. {
  380. m_wndProperties.Create(_T("STATIC"), NULL, WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, CXTPEmptyRect(), this, 0);
  381. }
  382. pPane->Attach(&m_wndProperties);
  383. break;
  384. case ID_WINDOWS_OUTPUT:
  385. if (!m_wndOutput.GetSafeHwnd())
  386. {
  387. m_wndOutput.Create(WS_HSCROLL|ES_AUTOHSCROLL|ES_MULTILINE|WS_VISIBLE, CXTPEmptyRect(), this, 0);
  388. }
  389. pPane->Attach(&m_wndOutput);
  390. break;
  391. case ID_HELP_DYNAMICHELP:
  392. {
  393. // attach the dynamic help view to the pane.
  394. CWnd* pView = pPane->AttachView(this, RUNTIME_CLASS(CDynamicHelpView));
  395. pView;
  396. break;
  397. }
  398. }
  399. }
  400. return 1;
  401. }
  402. if (wParam == XTP_DPN_CONTEXTMENU)
  403. {
  404. XTP_DOCKINGPANE_CLICK* pClick = (XTP_DOCKINGPANE_CLICK*)lParam;
  405. CXTPDockingPane* pPopupPane = pClick->pPane;
  406. if (!pPopupPane) 
  407. return FALSE;
  408. ShowDockingPanePopupMenu(pPopupPane, pClick->pt, pClick->rcExclude);
  409. return TRUE;
  410. }
  411. return 0;
  412. }
  413. void CMainFrame::OnShowView(UINT nID)
  414. {
  415. m_paneManager.ShowPane(nID);
  416. }
  417. void CMainFrame::OnEmptyCommandRange(UINT)
  418. {
  419. }
  420. void CMainFrame::OnWindowAutohideall()
  421. {
  422. CXTPDockingPaneInfoList& lstPanes = m_paneManager.GetPaneList();
  423. POSITION pos = lstPanes.GetHeadPosition();
  424. while (pos)
  425. {
  426. CXTPDockingPane* pPane = lstPanes.GetNext(pos);
  427. if (!pPane->IsClosed() && !pPane->IsHidden())
  428. m_paneManager.HidePane(pPane);
  429. }
  430. }
  431. void CMainFrame::OnWindowMore()
  432. {
  433. CXTWindowList dlg(this);
  434. dlg.DoModal();
  435. }
  436. int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)
  437. {
  438. if (lpCreateControl->bToolBar)
  439. {
  440. CXTPToolBar* pToolBar = DYNAMIC_DOWNCAST(CXTPToolBar, lpCreateControl->pCommandBar);
  441. if (!pToolBar)
  442. return FALSE;
  443. if (lpCreateControl->nID == ID_VIEW_CLASSVIEW && pToolBar->GetBarID() == IDR_MAINFRAME)
  444. {
  445. lpCreateControl->controlType = xtpControlSplitButtonPopup;
  446. return TRUE;
  447. }
  448. if (lpCreateControl->nID == ID_VIEW_FULLSCREEN)
  449. {
  450. lpCreateControl->buttonStyle = xtpButtonIconAndCaption;
  451. return TRUE;
  452. }
  453. if (lpCreateControl->nID == ID_THEME_SKINFRAMEWORK)
  454. {
  455. lpCreateControl->controlType = xtpControlPopup;
  456. return TRUE;
  457. }
  458. if (lpCreateControl->nID == ID_FILE_NEW_PROJECT && pToolBar->GetBarID() == IDR_MAINFRAME)
  459. {
  460. lpCreateControl->controlType = xtpControlSplitButtonPopup;
  461. return TRUE;
  462. }
  463. if (lpCreateControl->nID == ID_PROJECT_ADDNEWITEM && pToolBar->GetBarID() == IDR_MAINFRAME)
  464. {
  465. lpCreateControl->controlType = xtpControlSplitButtonPopup;
  466. return TRUE;
  467. }
  468. if (lpCreateControl->nID == ID_EDIT_FIND_EX && pToolBar->GetBarID() == IDR_MAINFRAME)
  469. {
  470. CXTPControlComboBox* pComboFind = (CXTPControlComboBox*)CXTPControlComboBox::CreateObject();
  471. pComboFind->SetDropDownListStyle();
  472. pComboFind->AddString(_T("Line1"));
  473. pComboFind->AddString(_T("Line2"));
  474. pComboFind->AddString(_T("Line3"));
  475. pComboFind->SetWidth(180);
  476. pComboFind->SetCaption(_T("Find"));
  477. pComboFind->SetStyle(xtpComboLabel);
  478. lpCreateControl->pControl = pComboFind;
  479. return TRUE;
  480. }
  481. if (lpCreateControl->nID == ID_EDIT_STATE && pToolBar->GetBarID() == IDR_MAINFRAME)
  482. {
  483. CXTPControlComboBox* pComboState = (CXTPControlComboBox*)CXTPControlComboBox::CreateObject();
  484. pComboState->AddString(_T("Debug"));
  485. pComboState->AddString(_T("Release"));
  486. pComboState->AddString(_T("Configuration Manager"));
  487. pComboState->SetDropDownWidth(150);
  488. lpCreateControl->pControl = pComboState;
  489. return TRUE;
  490. }
  491. if (lpCreateControl->nID == ID_EDIT_PLATFORM && pToolBar->GetBarID() == IDR_MAINFRAME)
  492. {
  493. CXTPControlComboBox* pComboState = (CXTPControlComboBox*)CXTPControlComboBox::CreateObject();
  494. pComboState->AddString(_T("Win32"));
  495. pComboState->AddString(_T("Configuration Manager"));
  496. pComboState->SetDropDownWidth(150);
  497. lpCreateControl->pControl = pComboState;
  498. return TRUE;
  499. }
  500. if (lpCreateControl->nID == ID_GOTO_URL && pToolBar->GetBarID() == IDR_TOOLBAR_WEB)
  501. {
  502. CXTPControlComboBox* pComboUrl = (CXTPControlComboBox*)CXTPControlComboBox::CreateObject();
  503. pComboUrl->AddString(_T("http://www.codejock.com"));
  504. pComboUrl->AddString(_T("ms-help://MS.VSCC/vsccCommon/html/vsccCommon_Start_Page.htm"));
  505. pComboUrl->SetWidth(200);
  506. pComboUrl->SetDropDownWidth(300);
  507. pComboUrl->SetDropDownListStyle();
  508. pComboUrl->SetFlags(xtpFlagManualUpdate);
  509. pComboUrl->SetEditText(_T("http://www.codejock.com"));
  510. pComboUrl->EnableShellAutoComplete();
  511. lpCreateControl->pControl = pComboUrl;
  512. return TRUE;
  513. }
  514. }
  515. return FALSE;
  516. }
  517. void CMainFrame::OnCustomize()
  518. {
  519. CXTPCustomizeSheet cs(GetCommandBars());
  520. CXTPCustomizeKeyboardPage pageKeyboard(&cs);
  521. cs.AddPage(&pageKeyboard);
  522. pageKeyboard.AddCategories(IDR_MAINFRAME, TRUE);
  523. CXTPCustomizeOptionsPage pageOptions(&cs);
  524. cs.AddPage(&pageOptions);
  525. CXTPCustomizeCommandsPage* pCommands = cs.GetCommandsPage();
  526. pCommands->AddCategories(IDR_MAINFRAME, TRUE);
  527. pCommands->InsertAllCommandsCategory();
  528. pCommands->InsertBuiltInMenus(IDR_MAINFRAME);
  529. pCommands->InsertNewMenuCategory();
  530. cs.DoModal();
  531. }
  532. void CMainFrame::OnEditState(NMHDR* pNMHDR, LRESULT* pResult)
  533. {
  534. NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)pNMHDR;
  535. CXTPControlComboBox* pControl = (CXTPControlComboBox*)tagNMCONTROL->pControl;
  536. if (pControl->GetType() == xtpControlComboBox)
  537. {
  538. int nState = pControl->GetCurSel();
  539. if (nState != 2)
  540. {
  541. m_nState = nState;
  542. }
  543. else
  544. {
  545. MessageBox(_T("Configuration Manager"));
  546. pControl->SetCurSel(m_nState);
  547. }
  548. *pResult = TRUE; // Handled
  549. }
  550. }
  551. void CMainFrame::OnUpdateEditState(CCmdUI* pCmdUI)
  552. {
  553. CXTPCommandBar* pToolBar = (CXTPToolBar*)pCmdUI->m_pOther;
  554. if (pToolBar && !XTPMouseManager()->IsTrackedLock())
  555. {
  556. CXTPControlComboBox* pStateCombo = (CXTPControlComboBox*)pToolBar->GetControls()->GetAt(pCmdUI->m_nIndex);
  557. if (pStateCombo->GetType() == xtpControlComboBox)
  558. {
  559. pStateCombo->SetCurSel(m_nState);
  560. }
  561. }
  562. pCmdUI->Enable(TRUE);
  563. }
  564. void CMainFrame::OnEditPlatform(NMHDR* pNMHDR, LRESULT* pResult)
  565. {
  566. NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)pNMHDR;
  567. CXTPControlComboBox* pControl = (CXTPControlComboBox*)tagNMCONTROL->pControl;
  568. if (pControl->GetType() == xtpControlComboBox)
  569. {
  570. int nState = pControl->GetCurSel();
  571. if (nState != 1)
  572. {
  573. m_nPlatform = nState;
  574. }
  575. else
  576. {
  577. MessageBox(_T("Configuration Manager"));
  578. pControl->SetCurSel(m_nPlatform);
  579. }
  580. *pResult = TRUE; // Handled
  581. }
  582. }
  583. void CMainFrame::OnUpdateEditPlatform(CCmdUI* pCmdUI)
  584. {
  585. CXTPCommandBar* pToolBar = (CXTPToolBar*)pCmdUI->m_pOther;
  586. if (pToolBar && !XTPMouseManager()->IsTrackedLock())
  587. {
  588. CXTPControlComboBox* pStateCombo = (CXTPControlComboBox*)pToolBar->GetControls()->GetAt(pCmdUI->m_nIndex);
  589. if (pStateCombo->GetType() == xtpControlComboBox)
  590. {
  591. pStateCombo->SetCurSel(m_nPlatform);
  592. }
  593. }
  594. pCmdUI->Enable(TRUE);
  595. }
  596. void CMainFrame::OnClose()
  597. {
  598. //CXTPPropExchangeIniFile px(FALSE, 0, _T("Settings"));    // To serialize to ini file
  599. CXTPPropExchangeXMLNode px(FALSE, 0, _T("Settings"));      // To serialize to XML file
  600. if (px.OnBeforeExchange()) 
  601. {
  602. CXTPPropExchangeSection pxTaskPanel(px.GetSection(_T("TaskPanel")));
  603. m_wndTaskPanel.GetGroups()->DoPropExchange(&pxTaskPanel);
  604. // Reset Full Screen Mode
  605. if (m_bFullScreen)
  606. {
  607. OnFullScreen();
  608. }
  609. CXTPPropExchangeSection pxNormalLayout(px.GetSection(_T("NormalLayout")));
  610. ExchangeLayout(&pxNormalLayout);
  611. px.PutSection(m_pFullScreenLayout);
  612. px.SaveToFile(m_strIniFileName);
  613. }
  614. CMDIFrameWnd::OnClose();
  615. }
  616. void CMainFrame::OnSetPreviewMode(BOOL bPreview, CPrintPreviewState* pState)
  617. {
  618. // Toggle CommandBars
  619. GetCommandBars()->OnSetPreviewMode(bPreview);
  620. // Toggle Tab Client
  621. m_MTIClientWnd.ShowWorkspace(!bPreview);
  622. // Toggle Docking Panes.
  623. m_paneManager.OnSetPreviewMode(bPreview);
  624. CMDIFrameWnd::OnSetPreviewMode(bPreview, pState);
  625. }
  626. void CMainFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
  627. {
  628. static HWND hFocus = 0;
  629. if (nState == WA_INACTIVE)
  630. {
  631. hFocus = m_paneManager.GetActivePane() != NULL ? ::GetFocus() : NULL;
  632. }
  633. CMDIFrameWnd::OnActivate(nState, pWndOther, bMinimized);
  634. if (nState != WA_INACTIVE && hFocus)
  635. {
  636. ::SetFocus(hFocus);
  637. hFocus = NULL;
  638. }
  639. }
  640. void CMainFrame::ExchangeLayout(CXTPPropExchange* pPX, BOOL bSerializeControls /*= TRUE*/)
  641. {
  642. XTP_COMMANDBARS_PROPEXCHANGE_PARAM param; param.bSerializeControls = bSerializeControls; 
  643. CXTPPropExchangeSection pxCommandBars(pPX->GetSection(_T("CommandBars")));
  644. GetCommandBars()->DoPropExchange(&pxCommandBars, &param);
  645. CXTPPropExchangeSection secShortcuts(pPX->GetSection(_T("Shortcuts")));
  646. GetCommandBars()->GetShortcutManager()->DoPropExchange(&secShortcuts);
  647. CXTPPropExchangeSection secOptions(pPX->GetSection(_T("Options")));
  648. GetCommandBars()->GetCommandBarsOptions()->DoPropExchange(&secOptions, TRUE);
  649. CXTPPropExchangeSection pxDockingPane(pPX->GetSection(_T("DockingPane")));
  650. m_paneManager.DoPropExchange(&pxDockingPane);
  651. }
  652. void CMainFrame::OnFullScreen()
  653. {
  654. m_bFullScreen ^= 1;
  655. CXTPPropExchangeXMLNode px(FALSE, 0, _T("Settings"));
  656. CXTPPropExchangeXMLNode* pxLayoutSave = DYNAMIC_DOWNCAST(CXTPPropExchangeXMLNode, px.GetSection(_T("FullScreenLayout")));
  657. ASSERT(pxLayoutSave);
  658. // Save current layout
  659. if (pxLayoutSave != 0)
  660. {
  661. ExchangeLayout(pxLayoutSave, FALSE);
  662. }
  663. // If Full screen layout exists
  664. if (m_pFullScreenLayout && m_pFullScreenLayout->IsSectionExists(_T("CommandBars")))
  665. {
  666. // Set it
  667. m_pFullScreenLayout->SetLoading(TRUE);
  668. ExchangeLayout(m_pFullScreenLayout, FALSE);
  669. }
  670. // Else create new fullscreen layout. Hide all toolbars and DockingPanes.
  671. else
  672. {
  673. for (int i = 0; i < GetCommandBars()->GetCount(); i++)
  674. {
  675. CXTPToolBar* pToolBar = GetCommandBars()->GetAt(i);
  676. pToolBar->SetVisible((pToolBar->GetType() == xtpBarTypeMenuBar) || (pToolBar->GetBarID() == IDR_TOOLBAR_FULLSCREEN));
  677. }
  678. m_paneManager.CloseAll();
  679. }
  680. // Save old layout
  681. if (m_pFullScreenLayout)
  682. {
  683. delete m_pFullScreenLayout;
  684. }
  685. m_pFullScreenLayout = pxLayoutSave;
  686. if (m_bFullScreen)
  687. {
  688. GetWindowRect(&m_rcMainFrame);
  689. ModifyStyle(WS_CAPTION|WS_THICKFRAME, 0);
  690. // Now resize the main window
  691. CRect rcScreen = XTPMultiMonitor()->GetScreenArea(this);
  692. int cxBorder = ::GetSystemMetrics(SM_CXBORDER);
  693. int cyBorder = ::GetSystemMetrics(SM_CYBORDER);
  694. SetWindowPos(NULL, rcScreen.left - cxBorder, rcScreen.top - cyBorder, 
  695. rcScreen.Width() + cxBorder * 2, rcScreen.Height() + cyBorder * 2, SWP_NOZORDER);
  696. m_wndStatusBar.ShowWindow(SW_HIDE);
  697. else
  698. {
  699. ModifyStyle(0, WS_CAPTION|WS_THICKFRAME);
  700. MoveWindow(&m_rcMainFrame);
  701. m_wndStatusBar.ShowWindow(SW_SHOW);
  702. }
  703. RecalcLayout(TRUE);
  704. }
  705. void CMainFrame::OnUpdateFullScreen(CCmdUI* pCmdUI)
  706. {
  707. pCmdUI->SetCheck(m_bFullScreen);
  708. }
  709. class CVisualStudio6Theme : public CXTPDefaultTheme
  710. {
  711. CSize DrawCommandBarGripper(CDC* pDC, CXTPCommandBar* pBar, BOOL bDraw)
  712. {
  713. if (pBar->IsDialogBar() || pBar->GetPosition() == xtpBarFloating)
  714. return CXTPDefaultTheme::DrawCommandBarGripper(pDC, pBar, bDraw);
  715. CRect rc;
  716. pBar->GetClientRect(&rc);
  717. if (pBar->GetPosition() == xtpBarRight || pBar->GetPosition() == xtpBarLeft)
  718. {
  719. if (pDC && bDraw)
  720. {
  721. Draw3dRect(pDC, CRect(3, 3, rc.right - 3, 6), COLOR_BTNHILIGHT, COLOR_3DSHADOW);
  722. Draw3dRect(pDC, CRect(3, 7, rc.right - 3, 10), COLOR_BTNHILIGHT, COLOR_3DSHADOW);
  723. }
  724. return CSize(0, 10);
  725. }
  726. else if (pBar->GetPosition() == xtpBarTop || pBar->GetPosition() == xtpBarBottom)
  727. {
  728. if (pDC && bDraw)
  729. {
  730. Draw3dRect(pDC, CRect(3, 3, 6, rc.bottom - 3), COLOR_BTNHILIGHT, COLOR_3DSHADOW);
  731. Draw3dRect(pDC, CRect(7, 3, 10, rc.bottom - 3), COLOR_BTNHILIGHT, COLOR_3DSHADOW);
  732. }
  733. return CSize(10, 0);
  734. }
  735. return 0;
  736. }
  737. };
  738. void CMainFrame::OnSkinFramework(UINT nID)
  739. {
  740. #ifdef _XTP_INCLUDE_SKINFRAMEWORK
  741. switch (nID)
  742. {
  743. case ID_SKINFRAMEWORK_VISTABLUE:
  744. XTPSkinManager()->LoadSkin(NULL, _T("NORMALBLUE.INI"));
  745. break;
  746. case ID_SKINFRAMEWORK_VISTABLACK:
  747. XTPSkinManager()->LoadSkin(NULL, _T("NORMALBLACK.INI"));
  748. break;
  749. default:
  750. XTPSkinManager()->LoadSkin(NULL);
  751. break;
  752. }
  753. #endif
  754. }
  755. void CMainFrame::OnTheme(UINT nID)
  756. {
  757. m_nTheme = nID;
  758. switch (nID)
  759. {
  760. case ID_THEME_VC6:
  761. XTPPaintManager()->SetCustomTheme(new CVisualStudio6Theme);
  762. m_paneManager.SetTheme(xtpPaneThemeGrippered);
  763. m_wndTaskPanel.SetTheme(xtpTaskPanelThemeToolbox);
  764. m_wndProperties.m_wndPropertyGrid.SetTheme(xtpGridThemeDefault);
  765. break;
  766. case ID_THEME_VC7:
  767. XTPPaintManager()->SetTheme(xtpThemeOfficeXP);
  768. m_paneManager.SetTheme(xtpPaneThemeOffice);
  769. m_wndTaskPanel.SetTheme(xtpTaskPanelThemeToolbox);
  770. m_wndProperties.m_wndPropertyGrid.SetTheme(xtpGridThemeOfficeXP);
  771. break;
  772. case ID_THEME_VC8:
  773. XTPPaintManager()->SetTheme(xtpThemeWhidbey);
  774. m_paneManager.SetTheme(xtpPaneThemeVisualStudio2005);
  775. m_wndTaskPanel.SetTheme(xtpTaskPanelThemeToolboxWhidbey);
  776. m_wndProperties.m_wndPropertyGrid.SetTheme(xtpGridThemeWhidbey);
  777. break;
  778. case ID_THEME_VC9:
  779. XTPPaintManager()->SetTheme(xtpThemeVisualStudio2008);
  780. m_paneManager.SetTheme(xtpPaneThemeVisualStudio2005);
  781. m_wndTaskPanel.SetTheme(xtpTaskPanelThemeToolboxWhidbey);
  782. m_wndProperties.m_wndPropertyGrid.SetTheme(xtpGridThemeWhidbey);
  783. break;
  784. }
  785. GetCommandBars()->RedrawCommandBars();
  786. }
  787. void CMainFrame::OnUpdateTheme(CCmdUI* pCmdUI)
  788. {
  789. pCmdUI->SetCheck(pCmdUI->m_nID == m_nTheme ? TRUE : FALSE);
  790. }