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, 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, OnUpdateViewStyles)
  52. ON_COMMAND_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, 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 DOCKING_TOOLBAR]
  214. [!if INTELLIGENT_MENUS]
  215. // Hide array of commands
  216. pCommandBars->HideCommands(uHideCmds, _countof(uHideCmds));
  217. // Set "Always Show Full Menus" option to the FALSE
  218. pCommandBars->GetCommandBarsOptions()->bAlwaysShowFullMenus = FALSE;
  219. [!endif]
  220. [!if CUSTOMIZE]
  221. pCommandBars->GetShortcutManager()->SetAccelerators(IDR_MAINFRAME);
  222. [!endif]
  223. // Load the previous state for toolbars and menus.
  224. LoadCommandBars(_T("CommandBars"));
  225. [!if !CUSTOMIZE]
  226. pCommandBars->GetCommandBarsOptions()->bShowExpandButtonAlways = FALSE;
  227. [!endif]
  228. [!endif]
  229. [!if MDITABS]
  230. VERIFY(m_MTIClientWnd.Attach(this));
  231. [!endif]
  232. [!if DOCK_PANE]
  233. // Initialize the docking pane manager and set the
  234. // initial them for the docking panes.  Do this only after all
  235. // control bars objects have been created and docked.
  236. m_paneManager.InstallDockingPanes(this);
  237. [!if THEME_OFFICEXP]
  238. // Set Visual Studio .NET / Office XP Theme
  239. m_paneManager.SetTheme(xtpPaneThemeOffice);
  240. [!endif]
  241. [!if THEME_OFFICE2000]
  242. // Set Office 2000 Theme
  243. m_paneManager.SetTheme(xtpPaneThemeDefault);
  244. [!endif]
  245. [!if THEME_OFFICE2003]
  246. // Set Office 2003 Theme
  247. m_paneManager.SetTheme(xtpPaneThemeOffice2003);
  248. [!endif]
  249. [!if THEME_NATIVEWINXP]
  250. // Set Windows XP Theme
  251. m_paneManager.SetTheme(xtpPaneThemeNativeWinXP);
  252. [!endif]
  253. // Create docking panes.
  254. CXTPDockingPane* pwndPane1 = m_paneManager.CreatePane(
  255. IDR_PANE_OPTIONS, CRect(0, 0,200, 120), xtpPaneDockLeft);
  256. CXTPDockingPane* pwndPane2 = m_paneManager.CreatePane(
  257. IDR_PANE_PROPERTIES, CRect(0, 0,200, 120), xtpPaneDockBottom, pwndPane1);
  258. // Set the icons for the docking pane tabs.
  259. int nIDIcons[] = {IDR_PANE_OPTIONS, IDR_PANE_PROPERTIES};
  260. m_paneManager.SetIcons(IDB_BITMAP_ICONS, nIDIcons,
  261. _countof(nIDIcons), RGB(0, 255, 0));
  262. // Load the previous state for docking panes.
  263. CXTPDockingPaneLayout layoutNormal(&m_paneManager);
  264. if (layoutNormal.Load(_T("NormalLayout")))
  265. {
  266. m_paneManager.SetLayout(&layoutNormal);
  267. }
  268. [!endif]
  269. return 0;
  270. }
  271. [!else]
  272. [!if APP_TYPE_SDI && !DOCVIEW]
  273. int [!output MAIN_FRAME_CLASS]::OnCreate(LPCREATESTRUCT lpCreateStruct)
  274. {
  275. if ([!output MAIN_FRAME_BASE_CLASS]::OnCreate(lpCreateStruct) == -1)
  276. return -1;
  277. // create a view to occupy the client area of the frame
  278. if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
  279. CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
  280. {
  281. TRACE0("Failed to create view windown");
  282. return -1;
  283. }
  284. return 0;
  285. }
  286. [!endif]
  287. [!endif]
  288. [!if SPLITTER || PROJECT_STYLE_EXPLORER]
  289. [!if APP_TYPE_SDI || APP_TYPE_MTLD]
  290. BOOL [!output MAIN_FRAME_CLASS]::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
  291. CCreateContext* pContext)
  292. {
  293. [!if PROJECT_STYLE_EXPLORER]
  294. // create splitter window
  295. if (!m_wndSplitter.CreateStatic(this, 1, 2))
  296. return FALSE;
  297. if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS([!output TREE_VIEW_CLASS]), CSize(100, 100), pContext) ||
  298. !m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS([!output VIEW_CLASS]), CSize(100, 100), pContext))
  299. {
  300. m_wndSplitter.DestroyWindow();
  301. return FALSE;
  302. }
  303. return TRUE;
  304. [!else]
  305. [!if HTML_VIEW || HTML_EDITVIEW]
  306. return m_wndSplitter.Create(this,
  307. 2, 2,               // TODO: adjust the number of rows, columns
  308. CSize(10, 10),      // TODO: adjust the minimum pane size
  309. pContext, WS_CHILD | WS_VISIBLE | SPLS_DYNAMIC_SPLIT);
  310. [!else]
  311. return m_wndSplitter.Create(this,
  312. 2, 2,               // TODO: adjust the number of rows, columns
  313. CSize(10, 10),      // TODO: adjust the minimum pane size
  314. pContext);
  315. [!endif]
  316. [!endif]
  317. }
  318. [!endif]
  319. [!endif]
  320. BOOL [!output MAIN_FRAME_CLASS]::PreCreateWindow(CREATESTRUCT& cs)
  321. {
  322. if( ![!output MAIN_FRAME_BASE_CLASS]::PreCreateWindow(cs) )
  323. return FALSE;
  324. // TODO: Modify the Window class or styles here by modifying
  325. //  the CREATESTRUCT cs
  326. [!if !MAIN_FRAME_DEFAULT_STYLES]
  327. cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE
  328. [!output MAIN_FRAME_STYLE_FLAGS];
  329. [!endif]
  330. [!if APP_TYPE_SDI]
  331. [!if !DOCVIEW]
  332. cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
  333. cs.lpszClass = AfxRegisterWndClass(0);
  334. [!endif]
  335. [!if DOCK_PANE]
  336. cs.style |= WS_CLIPCHILDREN|WS_CLIPSIBLINGS;
  337. [!endif]
  338. [!endif]
  339. return TRUE;
  340. }
  341. // [!output MAIN_FRAME_CLASS] diagnostics
  342. #ifdef _DEBUG
  343. void [!output MAIN_FRAME_CLASS]::AssertValid() const
  344. {
  345. [!output MAIN_FRAME_BASE_CLASS]::AssertValid();
  346. }
  347. void [!output MAIN_FRAME_CLASS]::Dump(CDumpContext& dc) const
  348. {
  349. [!output MAIN_FRAME_BASE_CLASS]::Dump(dc);
  350. }
  351. #endif //_DEBUG
  352. // [!output MAIN_FRAME_CLASS] message handlers
  353. [!if APP_TYPE_SDI]
  354. [!if !DOCVIEW]
  355. void [!output MAIN_FRAME_CLASS]::OnSetFocus(CWnd* /*pOldWnd*/)
  356. {
  357. // forward focus to the view window
  358. m_wndView.SetFocus();
  359. }
  360. BOOL [!output MAIN_FRAME_CLASS]::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
  361. {
  362. // let the view have first crack at the command
  363. if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
  364. return TRUE;
  365. // otherwise, do default handling
  366. return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  367. }
  368. [!endif]
  369. [!endif]
  370. [!if APP_TYPE_SDI || APP_TYPE_MTLD]
  371. [!if PROJECT_STYLE_EXPLORER]
  372. [!if LIST_VIEW]
  373. [!output VIEW_CLASS]* [!output MAIN_FRAME_CLASS]::GetRightPane()
  374. {
  375. CWnd* pWnd = m_wndSplitter.GetPane(0, 1);
  376. [!output VIEW_CLASS]* pView = DYNAMIC_DOWNCAST([!output VIEW_CLASS], pWnd);
  377. return pView;
  378. }
  379. void [!output MAIN_FRAME_CLASS]::OnUpdateViewStyles(CCmdUI* pCmdUI)
  380. {
  381. // TODO: customize or extend this code to handle choices on the View menu
  382. [!output VIEW_CLASS]* pView = GetRightPane();
  383. // if the right-hand pane hasn't been created or isn't a view,
  384. // disable commands in our range
  385. if (pView == NULL)
  386. pCmdUI->Enable(FALSE);
  387. else
  388. {
  389. DWORD dwStyle = pView->GetStyle() & LVS_TYPEMASK;
  390. // if the command is ID_VIEW_LINEUP, only enable command
  391. // when we're in LVS_ICON or LVS_SMALLICON mode
  392. if (pCmdUI->m_nID == ID_VIEW_LINEUP)
  393. {
  394. if (dwStyle == LVS_ICON || dwStyle == LVS_SMALLICON)
  395. pCmdUI->Enable();
  396. else
  397. pCmdUI->Enable(FALSE);
  398. }
  399. else
  400. {
  401. // otherwise, use dots to reflect the style of the view
  402. pCmdUI->Enable();
  403. BOOL bChecked = FALSE;
  404. switch (pCmdUI->m_nID)
  405. {
  406. case ID_VIEW_DETAILS:
  407. bChecked = (dwStyle == LVS_REPORT);
  408. break;
  409. case ID_VIEW_SMALLICON:
  410. bChecked = (dwStyle == LVS_SMALLICON);
  411. break;
  412. case ID_VIEW_LARGEICON:
  413. bChecked = (dwStyle == LVS_ICON);
  414. break;
  415. case ID_VIEW_LIST:
  416. bChecked = (dwStyle == LVS_LIST);
  417. break;
  418. default:
  419. bChecked = FALSE;
  420. break;
  421. }
  422. pCmdUI->SetRadio(bChecked ? 1 : 0);
  423. }
  424. }
  425. }
  426. void [!output MAIN_FRAME_CLASS]::OnViewStyle(UINT nCommandID)
  427. {
  428. // TODO: customize or extend this code to handle choices on the View menu
  429. [!output VIEW_CLASS]* pView = GetRightPane();
  430. // if the right-hand pane has been created and is a [!output VIEW_CLASS],
  431. // process the menu commands...
  432. if (pView != NULL)
  433. {
  434. DWORD dwStyle = -1;
  435. switch (nCommandID)
  436. {
  437. case ID_VIEW_LINEUP:
  438. {
  439. // ask the list control to snap to grid
  440. CListCtrl& refListCtrl = pView->GetListCtrl();
  441. refListCtrl.Arrange(LVA_SNAPTOGRID);
  442. }
  443. break;
  444. // other commands change the style on the list control
  445. case ID_VIEW_DETAILS:
  446. dwStyle = LVS_REPORT;
  447. break;
  448. case ID_VIEW_SMALLICON:
  449. dwStyle = LVS_SMALLICON;
  450. break;
  451. case ID_VIEW_LARGEICON:
  452. dwStyle = LVS_ICON;
  453. break;
  454. case ID_VIEW_LIST:
  455. dwStyle = LVS_LIST;
  456. break;
  457. }
  458. // change the style; window will repaint automatically
  459. if (dwStyle != -1)
  460. pView->ModifyStyle(LVS_TYPEMASK, dwStyle);
  461. }
  462. }
  463. [!endif]
  464. [!endif]
  465. [!endif]
  466. [!if APP_TYPE_MTLD]
  467. BOOL [!output MAIN_FRAME_CLASS]::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext)
  468. {
  469. // base class does the real work
  470. if (!CFrameWnd::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext))
  471. {
  472. return FALSE;
  473. }
  474. CWinApp* pApp = AfxGetApp();
  475. if (pApp->m_pMainWnd == NULL)
  476. pApp->m_pMainWnd = this;
  477. // replace Exit option on File menu with Close for secondary windows
  478. if (AfxGetApp()->m_pMainWnd != this)
  479. {
  480. // Find the File/Exit control nested deep in the command bar hierarchy
  481. CXTPControl *pAppExitControl = GetCommandBars()->FindControl(xtpControlButton, ID_APP_EXIT, TRUE, TRUE);
  482. // If File/Exit was found, change its name/behavior to File/Close
  483. if (pAppExitControl)  
  484. {
  485. // Change its ID and caption to that of File/Close
  486. pAppExitControl->SetID(ID_FILE_CLOSE);
  487. pAppExitControl->SetCaption(_T("&Close"));
  488. }
  489. }
  490. return TRUE;
  491. }
  492. void [!output MAIN_FRAME_CLASS]::OnFileClose()
  493. {
  494.    DestroyWindow();
  495. }
  496. [!endif]
  497. void [!output MAIN_FRAME_CLASS]::OnClose()
  498. {
  499. [!if !DOCVIEW && APP_TYPE_MTLD]
  500. [!output APP_CLASS] *pApp = reinterpret_cast<[!output APP_CLASS]*>(AfxGetApp());
  501. // main window is being closed so cleanup
  502. if (pApp->m_pMainWnd == this)
  503. {
  504. for (int iCntr=0; iCntr < pApp->m_aryFrames.GetSize(); iCntr++)
  505. {
  506. HWND hFrame = pApp->m_aryFrames.GetAt(iCntr);
  507. if (::IsWindow(hFrame))
  508. ::SendMessage(hFrame, WM_CLOSE, 0, 0);
  509. }
  510. }
  511. [!endif]
  512. // Save the current state for toolbars and menus.
  513. SaveCommandBars(_T("CommandBars"));
  514. [!if DOCK_PANE]
  515. // Save the current state for docking panes.
  516. CXTPDockingPaneLayout layoutNormal(&m_paneManager);
  517. m_paneManager.GetLayout(&layoutNormal);
  518. layoutNormal.Save(_T("NormalLayout"));
  519. [!endif]
  520. [!output MAIN_FRAME_BASE_CLASS]::OnClose();
  521. }
  522. [!if CUSTOMIZE]
  523. void [!output MAIN_FRAME_CLASS]::OnCustomize()
  524. {
  525. // Get a pointer to the command bars object.
  526. CXTPCommandBars* pCommandBars = GetCommandBars();
  527. if(pCommandBars != NULL)
  528. {
  529. // Instanciate the customize dialog object.
  530. CXTPCustomizeSheet dlg(pCommandBars);
  531. // Add the keyboard page to the customize dialog.
  532. CXTPCustomizeKeyboardPage pageKeyboard(&dlg);
  533. dlg.AddPage(&pageKeyboard);
  534. [!if !APP_TYPE_MDI || CUSTOMIZE_CUSTOM]
  535. pageKeyboard.AddCategories(IDR_MAINFRAME);
  536. [!else]
  537. pageKeyboard.AddCategories(IDR_[!output SAFE_DOC_TYPE_NAME]TYPE);
  538. [!endif]
  539. // Add the options page to the customize dialog.
  540. CXTPCustomizeOptionsPage pageOptions(&dlg);
  541. dlg.AddPage(&pageOptions);
  542. // Add the commands page to the customize dialog.
  543. CXTPCustomizeCommandsPage* pCommands = dlg.GetCommandsPage();
  544. [!if !APP_TYPE_MDI || CUSTOMIZE_CUSTOM]
  545. pCommands->AddCategories(IDR_MAINFRAME);
  546. [!else]
  547. pCommands->AddCategories(IDR_[!output SAFE_DOC_TYPE_NAME]TYPE);
  548. [!endif]
  549. // Use the command bar manager to initialize the
  550. // customize dialog.
  551. pCommands->InsertAllCommandsCategory();
  552. [!if !APP_TYPE_MDI || CUSTOMIZE_CUSTOM]
  553. pCommands->InsertBuiltInMenus(IDR_MAINFRAME);
  554. [!else]
  555. pCommands->InsertBuiltInMenus(IDR_[!output SAFE_DOC_TYPE_NAME]TYPE);
  556. [!endif]
  557. pCommands->InsertNewMenuCategory();
  558. // Dispaly the dialog.
  559. dlg.DoModal();
  560. }
  561. }
  562. [!if CUSTOMIZE_CUSTOM]
  563. int [!output MAIN_FRAME_CLASS]::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)
  564. {
  565. CXTPMenuBar* pMenuBar = DYNAMIC_DOWNCAST(CXTPMenuBar, lpCreateControl->pCommandBar);
  566. if (pMenuBar)
  567. {
  568. ASSERT(lpCreateControl->pMenu);
  569. CMenu* pPopupMenu = lpCreateControl->pMenu->GetSubMenu(lpCreateControl->nIndex);
  570. if (lpCreateControl->strCaption == _T("&Window"))
  571. {
  572. CXTPControlPopup* pControlPopup = CXTPControlPopup::CreateControlPopup(xtpControlPopup);
  573. // Exclude only IDR_MAINFRAME template
  574. pControlPopup->ExcludeDocTemplate(IDR_MAINFRAME);
  575. pControlPopup->SetCommandBar(pPopupMenu);
  576. lpCreateControl->pControl = pControlPopup;
  577. return TRUE;
  578. }
  579. if (lpCreateControl->strCaption == _T("&Edit"))
  580. {
  581. CXTPControlPopup* pControlPopup = CXTPControlPopup::CreateControlPopup(xtpControlPopup);
  582. // Present only in IDR_RRRTYPE template
  583. pControlPopup->AssignDocTemplate(IDR_[!output SAFE_DOC_TYPE_NAME]TYPE);
  584. pControlPopup->SetCommandBar(pPopupMenu);
  585. lpCreateControl->pControl = pControlPopup;
  586. return TRUE;
  587. }
  588. }
  589. return FALSE;
  590. }
  591. [!endif]
  592. [!endif]
  593. [!if DOCK_PANE]
  594. LRESULT [!output MAIN_FRAME_CLASS]::OnDockingPaneNotify(WPARAM wParam, LPARAM lParam)
  595. {
  596. if (wParam == XTP_DPN_SHOWWINDOW)
  597. {
  598. CXTPDockingPane* pPane = (CXTPDockingPane*)lParam;
  599. if (!pPane->IsValid())
  600. {
  601. switch (pPane->GetID())
  602. {
  603. case IDR_PANE_PROPERTIES:
  604. {
  605. if (m_wndProperties.GetSafeHwnd() == 0)
  606. {
  607. m_wndProperties.Create(WS_CHILD|
  608. ES_AUTOVSCROLL|ES_MULTILINE,
  609. CRect(0, 0, 0, 0), this, 0);
  610. }
  611. pPane->Attach(&m_wndProperties);
  612. break;
  613. }
  614. case IDR_PANE_OPTIONS:
  615. {
  616. if (m_wndOptions.GetSafeHwnd() == 0)
  617. {
  618. m_wndOptions.Create(_T("nnOptions"),
  619. WS_CHILD|WS_CLIPCHILDREN|
  620. WS_CLIPSIBLINGS|SS_CENTER,
  621. CRect(0, 0, 0, 0), this, 0);
  622. }
  623. pPane->Attach(&m_wndOptions);
  624. break;
  625. }
  626. }
  627. }
  628. return TRUE;
  629. }
  630. return FALSE;
  631. }
  632. [!endif]
  633. [!if MDITABS]
  634. void [!output MAIN_FRAME_CLASS]::OnDestroy()
  635. {
  636. [!output MAIN_FRAME_BASE_CLASS]::OnDestroy();
  637. m_MTIClientWnd.Detach();
  638. }
  639. [!endif]