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

对话框与窗口

开发平台:

Visual C++

  1. // [!output MAIN_FRAME_IMPL] : implementation of the [!output MAIN_FRAME_CLASS] class
  2. //
  3. #include "stdafx.h"
  4. #include "[!output APP_HEADER]"
  5. #include "[!output MAIN_FRAME_HEADER]"
  6. [!if PROJECT_STYLE_EXPLORER]
  7. [!if APP_TYPE_SDI || APP_TYPE_MTLD]
  8. #include "[!output TREE_VIEW_HEADER]"
  9. #include "[!output VIEW_HEADER]"
  10. [!endif]
  11. [!endif]
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #endif
  15. // [!output MAIN_FRAME_CLASS]
  16. [!if APP_TYPE_MDI || !DOCVIEW]
  17. IMPLEMENT_DYNAMIC([!output MAIN_FRAME_CLASS], [!output MAIN_FRAME_BASE_CLASS])
  18. [!else]
  19. IMPLEMENT_DYNCREATE([!output MAIN_FRAME_CLASS], [!output MAIN_FRAME_BASE_CLASS])
  20. [!endif]
  21. BEGIN_MESSAGE_MAP([!output MAIN_FRAME_CLASS], [!output MAIN_FRAME_BASE_CLASS])
  22. [!if DOCKING_TOOLBAR || STATUS_BAR]
  23. ON_WM_CREATE()
  24. [!else]
  25. [!if APP_TYPE_SDI && !DOCVIEW]
  26. ON_WM_CREATE()
  27. [!endif]
  28. [!endif]
  29. [!if APP_TYPE_SDI]
  30. [!if !DOCVIEW]
  31. ON_WM_SETFOCUS()
  32. [!endif]
  33. [!endif]
  34. [!if APP_TYPE_MTLD]
  35. ON_COMMAND(ID_FILE_CLOSE, &[!output MAIN_FRAME_CLASS]::OnFileClose)
  36. [!endif] 
  37. ON_WM_CLOSE()
  38. [!if MDITABS]
  39. ON_WM_DESTROY()
  40. [!endif]
  41. [!if CONTEXT_HELP]
  42. // Global help commands
  43. ON_COMMAND(ID_HELP_FINDER, &[!output MAIN_FRAME_BASE_CLASS]::OnHelpFinder)
  44. ON_COMMAND(ID_HELP, &[!output MAIN_FRAME_BASE_CLASS]::OnHelp)
  45. ON_COMMAND(ID_CONTEXT_HELP, &[!output MAIN_FRAME_BASE_CLASS]::OnContextHelp)
  46. ON_COMMAND(ID_DEFAULT_HELP, &[!output MAIN_FRAME_BASE_CLASS]::OnHelpFinder)
  47. [!endif]
  48. [!if PROJECT_STYLE_EXPLORER]
  49. [!if APP_TYPE_SDI || APP_TYPE_MTLD]
  50. [!if LIST_VIEW]
  51. ON_UPDATE_COMMAND_UI_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, &[!output MAIN_FRAME_CLASS]::OnUpdateViewStyles)
  52. ON_COMMAND_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, &[!output MAIN_FRAME_CLASS]::OnViewStyle)
  53. [!endif]
  54. [!endif]
  55. [!endif]
  56. [!if CUSTOMIZE]
  57. ON_COMMAND(XTP_ID_CUSTOMIZE, OnCustomize)
  58. [!if CUSTOMIZE_CUSTOM]
  59. ON_XTP_CREATECONTROL()
  60. [!endif]
  61. [!endif]
  62. [!if DOCK_PANE]
  63. ON_MESSAGE(XTPWM_DOCKINGPANE_NOTIFY, OnDockingPaneNotify)
  64. [!endif]
  65. END_MESSAGE_MAP()
  66. [!if STATUS_BAR]
  67. static UINT indicators[] =
  68. {
  69. ID_SEPARATOR,           // status line indicator
  70. [!if DO_KANA]
  71. ID_INDICATOR_KANA,
  72. [!endif]
  73. ID_INDICATOR_CAPS,
  74. ID_INDICATOR_NUM,
  75. ID_INDICATOR_SCRL,
  76. };
  77. [!endif]
  78. [!if INTELLIGENT_MENUS]
  79. static UINT uHideCmds[] =
  80. {
  81. [!if APP_TYPE_MDI]
  82. ID_WINDOW_CASCADE,
  83. [!endif]
  84. ID_FILE_PRINT,
  85. ID_FILE_PRINT_PREVIEW,
  86. };
  87. [!endif]
  88. // [!output MAIN_FRAME_CLASS] construction/destruction
  89. [!output MAIN_FRAME_CLASS]::[!output MAIN_FRAME_CLASS]()
  90. {
  91. [!if ACCESSIBILITY]
  92. EnableActiveAccessibility();
  93. [!endif]
  94. // TODO: add member initialization code here
  95. }
  96. [!output MAIN_FRAME_CLASS]::~[!output MAIN_FRAME_CLASS]()
  97. {
  98. }
  99. [!if DOCKING_TOOLBAR || STATUS_BAR]
  100. int [!output MAIN_FRAME_CLASS]::OnCreate(LPCREATESTRUCT lpCreateStruct)
  101. {
  102. if ([!output MAIN_FRAME_BASE_CLASS]::OnCreate(lpCreateStruct) == -1)
  103. return -1;
  104. [!if APP_TYPE_SDI]
  105. [!if !DOCVIEW]
  106. // create a view to occupy the client area of the frame
  107. if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
  108. CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
  109. {
  110. TRACE0("Failed to create view windown");
  111. return -1;
  112. }
  113. [!endif]
  114. [!endif]
  115. [!if DOCKING_TOOLBAR]
  116. [!if TOOLBAR_STYLE_REBAR]
  117. if (!m_wndDlgBar.Create(this, IDR_MAINFRAME,
  118. CBRS_ALIGN_TOP, AFX_IDW_DIALOGBAR))
  119. {
  120. TRACE0("Failed to create dialogbarn");
  121. return -1;      // fail to create
  122. }
  123. if (!m_wndReBar.Create(this) ||
  124. !m_wndReBar.AddBar(&m_wndDlgBar))
  125. {
  126. TRACE0("Failed to create rebarn");
  127. return -1;      // fail to create
  128. }
  129. [!if CONTAINER || CONTAINER_SERVER]
  130. m_wndReBar.SetBarStyle(m_wndReBar.GetBarStyle() & ~CBRS_HIDE_INPLACE);
  131. [!endif]
  132. [!endif]
  133. [!endif]
  134. [!if STATUS_BAR]
  135. if (!m_wndStatusBar.Create(this) ||
  136. !m_wndStatusBar.SetIndicators(indicators,
  137.   sizeof(indicators)/sizeof(UINT)))
  138. {
  139. TRACE0("Failed to create status barn");
  140. return -1;      // fail to create
  141. }
  142. [!endif]
  143. [!if DOCKING_TOOLBAR]
  144. [!if TOOLBAR_STYLE_REBAR]
  145. [!if MINI_SERVER || FULL_SERVER || CONTAINER_SERVER]
  146. m_wndDlgBar.SetBarStyle(m_wndDlgBar.GetBarStyle() |
  147. CBRS_TOOLTIPS | CBRS_FLYBY);
  148. [!endif]
  149. [!else]
  150. // Initialize the command bars
  151. if (!InitCommandBars())
  152. return -1;
  153. // Get a pointer to the command bars object.
  154. CXTPCommandBars* pCommandBars = GetCommandBars();
  155. if(pCommandBars == NULL)
  156. {
  157. TRACE0("Failed to create command bars object.n");
  158. return -1;      // fail to create
  159. }
  160. [!if MENUBAR]
  161. // Add the menu bar
  162. CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(
  163. [!if CUSTOMIZE_STATIC]
  164. _T("Menu Bar"), IDR_[!output SAFE_DOC_TYPE_NAME]TYPE);
  165. [!else]
  166. _T("Menu Bar"), IDR_MAINFRAME);
  167. [!endif]
  168. if(pMenuBar == NULL)
  169. {
  170. TRACE0("Failed to create menu bar.n");
  171. return -1;      // fail to create
  172. }
  173. [!if !MDITABS]
  174. [!if APP_TYPE_MDI]
  175. pMenuBar->SetFlags(xtpFlagAddMDISysPopup);
  176. [!endif]
  177. [!else]
  178. pMenuBar->SetFlags(xtpFlagHideMinimizeBox | xtpFlagHideMaximizeBox);
  179. [!endif]
  180. [!if CUSTOMIZE_STATIC]
  181. pMenuBar->SetFlags(xtpFlagIgnoreSetMenuMessage);
  182. [!endif]
  183. [!endif]
  184. // Create ToolBar
  185. CXTPToolBar* pToolBar = (CXTPToolBar*)
  186. pCommandBars->Add(_T("Standard"), xtpBarTop);
  187. if (!pToolBar || !pToolBar->LoadToolBar(IDR_MAINFRAME))
  188. {
  189. TRACE0("Failed to create toolbarn");
  190. return -1;
  191. }
  192. [!endif]
  193. [!endif]
  194. [!if THEME_OFFICEXP]
  195. // Set Office XP Theme
  196. CXTPPaintManager::SetTheme(xtpThemeOfficeXP);
  197. [!endif]
  198. [!if THEME_OFFICE2000]
  199. // Set Office 2000 Theme
  200. CXTPPaintManager::SetTheme(xtpThemeOffice2000);
  201. [!endif]
  202. [!if THEME_OFFICE2003]
  203. // Set Office 2003 Theme
  204. [!if DISABLELUNACOLORS]
  205. XTPColorManager()->DisableLunaColors(TRUE);
  206. [!endif]
  207. CXTPPaintManager::SetTheme(xtpThemeOffice2003);
  208. [!endif]
  209. [!if THEME_NATIVEWINXP]
  210. // Set Windows XP Theme
  211. CXTPPaintManager::SetTheme(xtpThemeNativeWinXP);
  212. [!endif]
  213. [!if INTELLIGENT_MENUS]
  214. // Hide array of commands
  215. pCommandBars->HideCommands(uHideCmds, _countof(uHideCmds));
  216. // Set "Always Show Full Menus" option to the FALSE
  217. pCommandBars->GetCommandBarsOptions()->bAlwaysShowFullMenus = FALSE;
  218. [!endif]
  219. [!if CUSTOMIZE]
  220. pCommandBars->GetShortcutManager()->SetAccelerators(IDR_MAINFRAME);
  221. [!endif]
  222. // Load the previous state for toolbars and menus.
  223. LoadCommandBars(_T("CommandBars"));
  224. [!if !CUSTOMIZE]
  225. pCommandBars->GetCommandBarsOptions()->bShowExpandButtonAlways = FALSE;
  226. [!endif]
  227. [!if MDITABS]
  228. VERIFY(m_MTIClientWnd.Attach(this));
  229. [!endif]
  230. [!if DOCK_PANE]
  231. // Initialize the docking pane manager and set the
  232. // initial them for the docking panes.  Do this only after all
  233. // control bars objects have been created and docked.
  234. m_paneManager.InstallDockingPanes(this);
  235. [!if THEME_OFFICEXP]
  236. // Set Visual Studio .NET / Office XP Theme
  237. m_paneManager.SetTheme(xtpPaneThemeOffice);
  238. [!endif]
  239. [!if THEME_OFFICE2000]
  240. // Set Office 2000 Theme
  241. m_paneManager.SetTheme(xtpPaneThemeDefault);
  242. [!endif]
  243. [!if THEME_OFFICE2003]
  244. // Set Office 2003 Theme
  245. m_paneManager.SetTheme(xtpPaneThemeOffice2003);
  246. [!endif]
  247. [!if THEME_NATIVEWINXP]
  248. // Set Windows XP Theme
  249. m_paneManager.SetTheme(xtpPaneThemeNativeWinXP);
  250. [!endif]
  251. // Create docking panes.
  252. CXTPDockingPane* pwndPane1 = m_paneManager.CreatePane(
  253. IDR_PANE_OPTIONS, CRect(0, 0,200, 120), xtpPaneDockLeft);
  254. CXTPDockingPane* pwndPane2 = m_paneManager.CreatePane(
  255. IDR_PANE_PROPERTIES, CRect(0, 0,200, 120), xtpPaneDockBottom, pwndPane1);
  256. // Set the icons for the docking pane tabs.
  257. int nIDIcons[] = {IDR_PANE_OPTIONS, IDR_PANE_PROPERTIES};
  258. m_paneManager.SetIcons(IDB_BITMAP_ICONS, nIDIcons,
  259. _countof(nIDIcons), RGB(0, 255, 0));
  260. // Load the previous state for docking panes.
  261. CXTPDockingPaneLayout layoutNormal(&m_paneManager);
  262. if (layoutNormal.Load(_T("NormalLayout")))
  263. {
  264. m_paneManager.SetLayout(&layoutNormal);
  265. }
  266. [!endif]
  267. return 0;
  268. }
  269. [!else]
  270. [!if APP_TYPE_SDI && !DOCVIEW]
  271. int [!output MAIN_FRAME_CLASS]::OnCreate(LPCREATESTRUCT lpCreateStruct)
  272. {
  273. if ([!output MAIN_FRAME_BASE_CLASS]::OnCreate(lpCreateStruct) == -1)
  274. return -1;
  275. // create a view to occupy the client area of the frame
  276. if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
  277. CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
  278. {
  279. TRACE0("Failed to create view windown");
  280. return -1;
  281. }
  282. return 0;
  283. }
  284. [!endif]
  285. [!endif]
  286. [!if SPLITTER || PROJECT_STYLE_EXPLORER]
  287. [!if APP_TYPE_SDI || APP_TYPE_MTLD]
  288. BOOL [!output MAIN_FRAME_CLASS]::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
  289. CCreateContext* pContext)
  290. {
  291. [!if PROJECT_STYLE_EXPLORER]
  292. // create splitter window
  293. if (!m_wndSplitter.CreateStatic(this, 1, 2))
  294. return FALSE;
  295. if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS([!output TREE_VIEW_CLASS]), CSize(100, 100), pContext) ||
  296. !m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS([!output VIEW_CLASS]), CSize(100, 100), pContext))
  297. {
  298. m_wndSplitter.DestroyWindow();
  299. return FALSE;
  300. }
  301. return TRUE;
  302. [!else]
  303. [!if HTML_VIEW || HTML_EDITVIEW]
  304. return m_wndSplitter.Create(this,
  305. 2, 2,               // TODO: adjust the number of rows, columns
  306. CSize(10, 10),      // TODO: adjust the minimum pane size
  307. pContext, WS_CHILD | WS_VISIBLE | SPLS_DYNAMIC_SPLIT);
  308. [!else]
  309. return m_wndSplitter.Create(this,
  310. 2, 2,               // TODO: adjust the number of rows, columns
  311. CSize(10, 10),      // TODO: adjust the minimum pane size
  312. pContext);
  313. [!endif]
  314. [!endif]
  315. }
  316. [!endif]
  317. [!endif]
  318. BOOL [!output MAIN_FRAME_CLASS]::PreCreateWindow(CREATESTRUCT& cs)
  319. {
  320. if( ![!output MAIN_FRAME_BASE_CLASS]::PreCreateWindow(cs) )
  321. return FALSE;
  322. // TODO: Modify the Window class or styles here by modifying
  323. //  the CREATESTRUCT cs
  324. [!if !MAIN_FRAME_DEFAULT_STYLES]
  325. cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE
  326. [!output MAIN_FRAME_STYLE_FLAGS];
  327. [!endif]
  328. [!if APP_TYPE_SDI]
  329. [!if !DOCVIEW]
  330. cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
  331. cs.lpszClass = AfxRegisterWndClass(0);
  332. [!endif]
  333. [!if DOCK_PANE]
  334. cs.style |= WS_CLIPCHILDREN|WS_CLIPSIBLINGS;
  335. [!endif]
  336. [!endif]
  337. return TRUE;
  338. }
  339. // [!output MAIN_FRAME_CLASS] diagnostics
  340. #ifdef _DEBUG
  341. void [!output MAIN_FRAME_CLASS]::AssertValid() const
  342. {
  343. [!output MAIN_FRAME_BASE_CLASS]::AssertValid();
  344. }
  345. void [!output MAIN_FRAME_CLASS]::Dump(CDumpContext& dc) const
  346. {
  347. [!output MAIN_FRAME_BASE_CLASS]::Dump(dc);
  348. }
  349. #endif //_DEBUG
  350. // [!output MAIN_FRAME_CLASS] message handlers
  351. [!if APP_TYPE_SDI]
  352. [!if !DOCVIEW]
  353. void [!output MAIN_FRAME_CLASS]::OnSetFocus(CWnd* /*pOldWnd*/)
  354. {
  355. // forward focus to the view window
  356. m_wndView.SetFocus();
  357. }
  358. BOOL [!output MAIN_FRAME_CLASS]::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
  359. {
  360. // let the view have first crack at the command
  361. if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
  362. return TRUE;
  363. // otherwise, do default handling
  364. return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  365. }
  366. [!endif]
  367. [!endif]
  368. [!if APP_TYPE_SDI || APP_TYPE_MTLD]
  369. [!if PROJECT_STYLE_EXPLORER]
  370. [!if LIST_VIEW]
  371. [!output VIEW_CLASS]* [!output MAIN_FRAME_CLASS]::GetRightPane()
  372. {
  373. CWnd* pWnd = m_wndSplitter.GetPane(0, 1);
  374. [!output VIEW_CLASS]* pView = DYNAMIC_DOWNCAST([!output VIEW_CLASS], pWnd);
  375. return pView;
  376. }
  377. void [!output MAIN_FRAME_CLASS]::OnUpdateViewStyles(CCmdUI* pCmdUI)
  378. {
  379. // TODO: customize or extend this code to handle choices on the View menu
  380. [!output VIEW_CLASS]* pView = GetRightPane();
  381. // if the right-hand pane hasn't been created or isn't a view,
  382. // disable commands in our range
  383. if (pView == NULL)
  384. pCmdUI->Enable(FALSE);
  385. else
  386. {
  387. DWORD dwStyle = pView->GetStyle() & LVS_TYPEMASK;
  388. // if the command is ID_VIEW_LINEUP, only enable command
  389. // when we're in LVS_ICON or LVS_SMALLICON mode
  390. if (pCmdUI->m_nID == ID_VIEW_LINEUP)
  391. {
  392. if (dwStyle == LVS_ICON || dwStyle == LVS_SMALLICON)
  393. pCmdUI->Enable();
  394. else
  395. pCmdUI->Enable(FALSE);
  396. }
  397. else
  398. {
  399. // otherwise, use dots to reflect the style of the view
  400. pCmdUI->Enable();
  401. BOOL bChecked = FALSE;
  402. switch (pCmdUI->m_nID)
  403. {
  404. case ID_VIEW_DETAILS:
  405. bChecked = (dwStyle == LVS_REPORT);
  406. break;
  407. case ID_VIEW_SMALLICON:
  408. bChecked = (dwStyle == LVS_SMALLICON);
  409. break;
  410. case ID_VIEW_LARGEICON:
  411. bChecked = (dwStyle == LVS_ICON);
  412. break;
  413. case ID_VIEW_LIST:
  414. bChecked = (dwStyle == LVS_LIST);
  415. break;
  416. default:
  417. bChecked = FALSE;
  418. break;
  419. }
  420. pCmdUI->SetRadio(bChecked ? 1 : 0);
  421. }
  422. }
  423. }
  424. void [!output MAIN_FRAME_CLASS]::OnViewStyle(UINT nCommandID)
  425. {
  426. // TODO: customize or extend this code to handle choices on the View menu
  427. [!output VIEW_CLASS]* pView = GetRightPane();
  428. // if the right-hand pane has been created and is a [!output VIEW_CLASS],
  429. // process the menu commands...
  430. if (pView != NULL)
  431. {
  432. DWORD dwStyle = -1;
  433. switch (nCommandID)
  434. {
  435. case ID_VIEW_LINEUP:
  436. {
  437. // ask the list control to snap to grid
  438. CListCtrl& refListCtrl = pView->GetListCtrl();
  439. refListCtrl.Arrange(LVA_SNAPTOGRID);
  440. }
  441. break;
  442. // other commands change the style on the list control
  443. case ID_VIEW_DETAILS:
  444. dwStyle = LVS_REPORT;
  445. break;
  446. case ID_VIEW_SMALLICON:
  447. dwStyle = LVS_SMALLICON;
  448. break;
  449. case ID_VIEW_LARGEICON:
  450. dwStyle = LVS_ICON;
  451. break;
  452. case ID_VIEW_LIST:
  453. dwStyle = LVS_LIST;
  454. break;
  455. }
  456. // change the style; window will repaint automatically
  457. if (dwStyle != -1)
  458. pView->ModifyStyle(LVS_TYPEMASK, dwStyle);
  459. }
  460. }
  461. [!endif]
  462. [!endif]
  463. [!endif]
  464. [!if APP_TYPE_MTLD]
  465. BOOL [!output MAIN_FRAME_CLASS]::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext)
  466. {
  467. // base class does the real work
  468. if (!CFrameWnd::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext))
  469. {
  470. return FALSE;
  471. }
  472. CWinApp* pApp = AfxGetApp();
  473. if (pApp->m_pMainWnd == NULL)
  474. pApp->m_pMainWnd = this;
  475. // replace Exit option on File menu with Close for secondary windows
  476. if (AfxGetApp()->m_pMainWnd != this)
  477. {
  478. // Find the File/Exit control nested deep in the command bar hierarchy
  479. CXTPControl *pAppExitControl = GetCommandBars()->FindControl(xtpControlButton, ID_APP_EXIT, TRUE, TRUE);
  480. // If File/Exit was found, change its name/behavior to File/Close
  481. if (pAppExitControl)  
  482. {
  483. // Change its ID and caption to that of File/Close
  484. pAppExitControl->SetID(ID_FILE_CLOSE);
  485. pAppExitControl->SetCaption(_T("&Close"));
  486. }
  487. }
  488. return TRUE;
  489. }
  490. void [!output MAIN_FRAME_CLASS]::OnFileClose()
  491. {
  492.    DestroyWindow();
  493. }
  494. [!endif]
  495. void [!output MAIN_FRAME_CLASS]::OnClose()
  496. {
  497. [!if !DOCVIEW && APP_TYPE_MTLD]
  498. [!output APP_CLASS] *pApp = reinterpret_cast<[!output APP_CLASS]*>(AfxGetApp());
  499. // main window is being closed so cleanup
  500. if (pApp->m_pMainWnd == this)
  501. {
  502. for (int iCntr=0; iCntr < pApp->m_aryFrames.GetSize(); iCntr++)
  503. {
  504. HWND hFrame = pApp->m_aryFrames.GetAt(iCntr);
  505. if (::IsWindow(hFrame))
  506. ::SendMessage(hFrame, WM_CLOSE, 0, 0);
  507. }
  508. }
  509. [!endif]
  510. // Save the current state for toolbars and menus.
  511. SaveCommandBars(_T("CommandBars"));
  512. [!if DOCK_PANE]
  513. // Save the current state for docking panes.
  514. CXTPDockingPaneLayout layoutNormal(&m_paneManager);
  515. m_paneManager.GetLayout(&layoutNormal);
  516. layoutNormal.Save(_T("NormalLayout"));
  517. [!endif]
  518. [!output MAIN_FRAME_BASE_CLASS]::OnClose();
  519. }
  520. [!if CUSTOMIZE]
  521. void [!output MAIN_FRAME_CLASS]::OnCustomize()
  522. {
  523. // Get a pointer to the command bars object.
  524. CXTPCommandBars* pCommandBars = GetCommandBars();
  525. if(pCommandBars != NULL)
  526. {
  527. // Instanciate the customize dialog object.
  528. CXTPCustomizeSheet dlg(pCommandBars);
  529. // Add the keyboard page to the customize dialog.
  530. CXTPCustomizeKeyboardPage pageKeyboard(&dlg);
  531. dlg.AddPage(&pageKeyboard);
  532. [!if !APP_TYPE_MDI || CUSTOMIZE_CUSTOM]
  533. pageKeyboard.AddCategories(IDR_MAINFRAME);
  534. [!else]
  535. pageKeyboard.AddCategories(IDR_[!output SAFE_DOC_TYPE_NAME]TYPE);
  536. [!endif]
  537. // Add the options page to the customize dialog.
  538. CXTPCustomizeOptionsPage pageOptions(&dlg);
  539. dlg.AddPage(&pageOptions);
  540. // Add the commands page to the customize dialog.
  541. CXTPCustomizeCommandsPage* pCommands = dlg.GetCommandsPage();
  542. [!if !APP_TYPE_MDI || CUSTOMIZE_CUSTOM]
  543. pCommands->AddCategories(IDR_MAINFRAME);
  544. [!else]
  545. pCommands->AddCategories(IDR_[!output SAFE_DOC_TYPE_NAME]TYPE);
  546. [!endif]
  547. // Use the command bar manager to initialize the
  548. // customize dialog.
  549. pCommands->InsertAllCommandsCategory();
  550. [!if !APP_TYPE_MDI || CUSTOMIZE_CUSTOM]
  551. pCommands->InsertBuiltInMenus(IDR_MAINFRAME);
  552. [!else]
  553. pCommands->InsertBuiltInMenus(IDR_[!output SAFE_DOC_TYPE_NAME]TYPE);
  554. [!endif]
  555. pCommands->InsertNewMenuCategory();
  556. // Dispaly the dialog.
  557. dlg.DoModal();
  558. }
  559. }
  560. [!if CUSTOMIZE_CUSTOM]
  561. int [!output MAIN_FRAME_CLASS]::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)
  562. {
  563. CXTPMenuBar* pMenuBar = DYNAMIC_DOWNCAST(CXTPMenuBar, lpCreateControl->pCommandBar);
  564. if (pMenuBar)
  565. {
  566. ASSERT(lpCreateControl->pMenu);
  567. CMenu* pPopupMenu = lpCreateControl->pMenu->GetSubMenu(lpCreateControl->nIndex);
  568. if (lpCreateControl->strCaption == _T("&Window"))
  569. {
  570. CXTPControlPopup* pControlPopup = CXTPControlPopup::CreateControlPopup(xtpControlPopup);
  571. // Exclude only IDR_MAINFRAME template
  572. pControlPopup->ExcludeDocTemplate(IDR_MAINFRAME);
  573. pControlPopup->SetCommandBar(pPopupMenu);
  574. lpCreateControl->pControl = pControlPopup;
  575. return TRUE;
  576. }
  577. if (lpCreateControl->strCaption == _T("&Edit"))
  578. {
  579. CXTPControlPopup* pControlPopup = CXTPControlPopup::CreateControlPopup(xtpControlPopup);
  580. // Present only in IDR_RRRTYPE template
  581. pControlPopup->AssignDocTemplate(IDR_[!output SAFE_DOC_TYPE_NAME]TYPE);
  582. pControlPopup->SetCommandBar(pPopupMenu);
  583. lpCreateControl->pControl = pControlPopup;
  584. return TRUE;
  585. }
  586. }
  587. return FALSE;
  588. }
  589. [!endif]
  590. [!endif]
  591. [!if DOCK_PANE]
  592. LRESULT [!output MAIN_FRAME_CLASS]::OnDockingPaneNotify(WPARAM wParam, LPARAM lParam)
  593. {
  594. if (wParam == XTP_DPN_SHOWWINDOW)
  595. {
  596. CXTPDockingPane* pPane = (CXTPDockingPane*)lParam;
  597. if (!pPane->IsValid())
  598. {
  599. switch (pPane->GetID())
  600. {
  601. case IDR_PANE_PROPERTIES:
  602. {
  603. if (m_wndProperties.GetSafeHwnd() == 0)
  604. {
  605. m_wndProperties.Create(WS_CHILD|
  606. ES_AUTOVSCROLL|ES_MULTILINE,
  607. CRect(0, 0, 0, 0), this, 0);
  608. }
  609. pPane->Attach(&m_wndProperties);
  610. break;
  611. }
  612. case IDR_PANE_OPTIONS:
  613. {
  614. if (m_wndOptions.GetSafeHwnd() == 0)
  615. {
  616. m_wndOptions.Create(_T("nnOptions"),
  617. WS_CHILD|WS_CLIPCHILDREN|
  618. WS_CLIPSIBLINGS|SS_CENTER,
  619. CRect(0, 0, 0, 0), this, 0);
  620. }
  621. pPane->Attach(&m_wndOptions);
  622. break;
  623. }
  624. }
  625. }
  626. return TRUE;
  627. }
  628. return FALSE;
  629. }
  630. [!endif]
  631. [!if MDITABS]
  632. void [!output MAIN_FRAME_CLASS]::OnDestroy()
  633. {
  634. [!output MAIN_FRAME_BASE_CLASS]::OnDestroy();
  635. m_MTIClientWnd.Detach();
  636. }
  637. [!endif]