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

对话框与窗口

开发平台:

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_Explorer.h"
  22. #include "MainFrm.h"
  23. #include "GUI_ExplorerTree.h"
  24. #include "GUI_ExplorerView.h"
  25. #include "HistoryView.h"
  26. #include "SearchView.h"
  27. #include "InternetView.h"
  28. #include "Filefilter.h"
  29. #ifdef _DEBUG
  30. #define new DEBUG_NEW
  31. #undef THIS_FILE
  32. static char THIS_FILE[] = __FILE__;
  33. #endif
  34. #ifndef AFX_ID_VIEW_MINIMUM
  35. #define AFX_ID_VIEW_MINIMUM              ID_VIEW_SMALLICON
  36. #endif
  37. #ifndef AFX_ID_VIEW_MAXIMUM
  38. #define AFX_ID_VIEW_MAXIMUM              ID_VIEW_BYNAME
  39. #endif
  40. LPCTSTR lpszProfileName = _T("CommandBars (v4.0)");
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CMainFrame
  43. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  44. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  45. //{{AFX_MSG_MAP(CMainFrame)
  46. ON_WM_CREATE()
  47. ON_COMMAND(ID_BACK, OnBack)
  48. ON_COMMAND(ID_FORWARD, OnForward)
  49. ON_COMMAND(ID_UP, OnUp)
  50. ON_COMMAND(ID_VIEW_SEARCH, OnSearch)
  51. ON_COMMAND(ID_VIEW_FOLDERS, OnFolders)
  52. ON_COMMAND(ID_VIEW_HISTORY, OnHistory)
  53. ON_COMMAND(ID_MOVETO, OnMoveto)
  54. ON_COMMAND(ID_COPYTO, OnCopyto)
  55. ON_COMMAND(ID_DELETE, OnDelete)
  56. ON_COMMAND(ID_UNDO, OnUndo)
  57. ON_COMMAND(ID_VIEWS, OnViews)
  58. ON_UPDATE_COMMAND_UI(ID_VIEW_FOLDERS, OnUpdateFolders)
  59. ON_UPDATE_COMMAND_UI(ID_VIEW_SEARCH, OnUpdateSearch)
  60. ON_UPDATE_COMMAND_UI(ID_VIEW_HISTORY, OnUpdateHistory)
  61. ON_COMMAND(ID_VIEW_XPMODE, OnViewXpmode)
  62. ON_UPDATE_COMMAND_UI(ID_VIEW_XPMODE, OnUpdateViewXpmode)
  63. ON_WM_CLOSE()
  64. ON_UPDATE_COMMAND_UI(ID_BACK, OnUpdateBack)
  65. ON_UPDATE_COMMAND_UI(ID_FORWARD, OnUpdateForward)
  66. ON_UPDATE_COMMAND_UI(ID_UP, OnUpdateUp)
  67. ON_UPDATE_COMMAND_UI(ID_MOVETO, OnUpdateMoveto)
  68. ON_UPDATE_COMMAND_UI(ID_COPYTO, OnUpdateCopyto)
  69. ON_UPDATE_COMMAND_UI(ID_DELETE, OnUpdateDelete)
  70. ON_UPDATE_COMMAND_UI(ID_UNDO, OnUpdateUndo)
  71. ON_COMMAND(ID_GO, OnGo)
  72. ON_COMMAND(ID_VIEW_SETFILTER, OnViewSetfilter)
  73. //}}AFX_MSG_MAP
  74. ON_UPDATE_COMMAND_UI_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, OnUpdateViewStyles)
  75. ON_COMMAND_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, OnViewStyle)
  76. ON_MESSAGE(XTWM_SHELL_NOTIFY, OnUpdateShell)
  77. ON_COMMAND(IDOK, OnAddressBarEnter)
  78. ON_CBN_SELENDOK(IDC_ADDRESSBAR, OnSelEndOkAddressBar)
  79. ON_COMMAND(XTP_ID_CUSTOMIZE, OnCustomize)
  80. ON_XTP_CREATECONTROL()
  81. END_MESSAGE_MAP()
  82. static UINT indicators[] =
  83. {
  84. ID_SEPARATOR,           // status line indicator
  85. ID_INDICATOR_CAPS,
  86. ID_INDICATOR_NUM,
  87. ID_INDICATOR_SCRL,
  88. };
  89. /////////////////////////////////////////////////////////////////////////////
  90. // CMainFrame construction/destruction
  91. CMainFrame::CMainFrame()
  92. {
  93. // TODO: add member initialization code here
  94. m_pSearchView  = NULL;
  95. m_pHistoryView = NULL;
  96. m_pTreeView    = NULL;
  97. m_pFolderView  = NULL;
  98. m_pINetView    = NULL;
  99. m_pListCtrl    = NULL;
  100. m_pTreeCtrl    = NULL;
  101. // Enable/Disable XP GUI Mode
  102. CXTRegistryManager regMgr;
  103. XTAuxData().bXPMode = regMgr.GetProfileInt(_T("Settings"), _T("bXPMode"), FALSE);
  104. }
  105. CMainFrame::~CMainFrame()
  106. {
  107. CXTRegistryManager regMgr;
  108. regMgr.WriteProfileInt(_T("Settings"), _T("bXPMode"), XTAuxData().bXPMode);
  109. }
  110. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  111. {
  112. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  113. return -1;
  114. if (!m_wndStatusBar.Create(this) ||
  115. !m_wndStatusBar.SetIndicators(indicators,
  116.   sizeof(indicators)/sizeof(UINT)))
  117. {
  118. TRACE0("Failed to create status barn");
  119. return -1;      // fail to create
  120. }
  121. if (!InitCommandBars())
  122. return -1;
  123. CXTPCommandBars* pCommandBars = GetCommandBars();
  124. CXTPMenuBar* pMenuBar = pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAINFRAME);
  125. CXTPToolBar* pStandardBar = (CXTPToolBar*)pCommandBars->Add(_T("Standard"), xtpBarTop);
  126. if (!pStandardBar ||
  127. !pStandardBar->LoadToolBar(IDR_EXPLORER_BAR))
  128. {
  129. TRACE0("Failed to create toolbarn");
  130. return -1;
  131. }
  132. CXTPToolBar* pGoBar = (CXTPToolBar*)pCommandBars->Add(_T("Go"), xtpBarTop);
  133. if (!pGoBar ||
  134. !pGoBar->LoadToolBar(IDR_GO_BAR))
  135. {
  136. TRACE0("Failed to create toolbarn");
  137. return -1;
  138. }
  139. pGoBar->SetButtonSize(CSize(25, 25));
  140. InitializeAddressBar();
  141. m_wndLogo.Create(NULL, WS_CHILD|WS_VISIBLE|SS_BITMAP|SS_CENTERIMAGE, CRect(0, 0, 100, 23), this);
  142. m_wndLogo.SetURL(_T("http://www.codejock.com"));
  143. VERIFY(m_bmpLogo.LoadBitmap(IDB_LOGO));
  144. m_wndLogo.SetBitmap(m_bmpLogo);
  145. if (!m_wndReBar.Create(this) ||
  146. !m_wndReBar.AddToolBar(pMenuBar) ||
  147. !m_wndReBar.AddBar(&m_wndLogo, 0, 0, RBBS_NOGRIPPER | RBBS_FIXEDBMP | RBBS_FIXEDSIZE) ||
  148. !m_wndReBar.AddToolBar(pStandardBar, RBBS_GRIPPERALWAYS | RBBS_BREAK) ||
  149. !m_wndReBar.AddBar(&m_wndAddressBar, _T("Address"), NULL, RBBS_GRIPPERALWAYS | RBBS_BREAK) ||
  150. !m_wndReBar.AddToolBar(pGoBar) )
  151. {
  152. TRACE0("Failed to create rebarn");
  153. return -1;      // fail to create
  154. }
  155. // Set sizes for logo band.
  156. REBARBANDINFO rbbi;
  157. rbbi.cbSize     = sizeof(rbbi);
  158. rbbi.fMask      = RBBIM_CHILDSIZE|RBBIM_IDEALSIZE|RBBIM_SIZE|RBBIM_ID;
  159. rbbi.cx         =
  160. rbbi.cxIdeal    =
  161. rbbi.cxMinChild = 100;
  162. rbbi.cyMinChild = 23;
  163. rbbi.wID = IDB_LOGO;
  164. m_wndReBar.SetBandInfo(1, &rbbi);
  165. CXTPImageManager* pImageManager = pCommandBars->GetImageManager();
  166. pImageManager->SetIcons(IDR_GO_BAR, IDB_GO_BAR_HOT, xtpImageHot);
  167. XTAuxData().bXPMode = !XTAuxData().bXPMode;
  168. OnViewXpmode();
  169. if (pImageManager->IsAlphaIconsSupported())
  170. {
  171. pImageManager->SetIcons(IDR_EXPLORER_BAR, IDR_TOOLBAR_SMALL_NORMAL);
  172. pImageManager->SetIcons(IDR_EXPLORER_BAR, IDR_TOOLBAR_SMALL_HOT, xtpImageHot);
  173. pImageManager->SetIcons(IDR_EXPLORER_BAR, IDR_TOOLBAR_LARGE_NORMAL);
  174. pImageManager->SetIcons(IDR_EXPLORER_BAR, IDR_TOOLBAR_LARGE_HOT, xtpImageHot);
  175. pCommandBars->GetCommandBarsOptions()->szLargeIcons = CSize(24, 24);
  176. pCommandBars->GetCommandBarsOptions()->bLargeIcons = TRUE;
  177. }
  178. pCommandBars->GetCommandBarsOptions()->ShowKeyboardCues(xtpKeyboardCuesShowWindowsDefault);
  179. LoadCommandBars(lpszProfileName);
  180. m_wndReBar.LoadState(lpszProfileName);
  181. return 0;
  182. }
  183. BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
  184. CCreateContext* pContext)
  185. {
  186. // create splitter window
  187. if (!m_wndSplitter.CreateStatic(this, 1, 2))
  188. return FALSE;
  189. if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CGUI_ExplorerTree),
  190. CSize(300, 100), pContext))
  191. {
  192. m_wndSplitter.DestroyWindow();
  193. return FALSE;
  194. }
  195. if (!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CGUI_ExplorerView),
  196. CSize(100, 100), pContext))
  197. {
  198. m_wndSplitter.DestroyWindow();
  199. return FALSE;
  200. }
  201. m_wndSplitter.ShowTopBorder(false, 3);
  202. m_wndSplitter.SetSplitterStyle (XT_SPLIT_DOTTRACKER);
  203. return TRUE;
  204. }
  205. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  206. {
  207. if( !CFrameWnd::PreCreateWindow(cs) )
  208. return FALSE;
  209. cs.lpszClass = _T("XTPMainFrame");
  210. CXTPDrawHelpers::RegisterWndClass(AfxGetInstanceHandle(), cs.lpszClass, 
  211. CS_DBLCLKS, AfxGetApp()->LoadIcon(IDR_MAINFRAME));
  212. cs.style &= ~FWS_ADDTOTITLE;
  213. return TRUE;
  214. }
  215. /////////////////////////////////////////////////////////////////////////////
  216. // CMainFrame diagnostics
  217. #ifdef _DEBUG
  218. void CMainFrame::AssertValid() const
  219. {
  220. CFrameWnd::AssertValid();
  221. }
  222. void CMainFrame::Dump(CDumpContext& dc) const
  223. {
  224. CFrameWnd::Dump(dc);
  225. }
  226. #endif //_DEBUG
  227. /////////////////////////////////////////////////////////////////////////////
  228. // CMainFrame message handlers
  229. void CMainFrame::OnUpdateViewStyles(CCmdUI* pCmdUI)
  230. {
  231. // TODO: customize or extend this code to handle choices on the
  232. // View menu.
  233. // if the right-hand pane hasn't been created or isn't a view,
  234. // disable commands in our range
  235. if (m_pListCtrl == NULL)
  236. pCmdUI->Enable(FALSE);
  237. else
  238. {
  239. DWORD dwStyle = m_pListCtrl->GetStyle() & LVS_TYPEMASK;
  240. // if the command is ID_VIEW_LINEUP, only enable command
  241. // when we're in LVS_ICON or LVS_SMALLICON mode
  242. if (pCmdUI->m_nID == ID_VIEW_LINEUP)
  243. {
  244. if (dwStyle == LVS_ICON || dwStyle == LVS_SMALLICON)
  245. pCmdUI->Enable();
  246. else
  247. pCmdUI->Enable(FALSE);
  248. }
  249. else
  250. {
  251. // otherwise, use dots to reflect the style of the view
  252. pCmdUI->Enable();
  253. BOOL bChecked = FALSE;
  254. switch (pCmdUI->m_nID)
  255. {
  256. case ID_VIEW_DETAILS:
  257. bChecked = (dwStyle == LVS_REPORT);
  258. break;
  259. case ID_VIEW_SMALLICON:
  260. bChecked = (dwStyle == LVS_SMALLICON);
  261. break;
  262. case ID_VIEW_LARGEICON:
  263. bChecked = (dwStyle == LVS_ICON);
  264. break;
  265. case ID_VIEW_LIST:
  266. bChecked = (dwStyle == LVS_LIST);
  267. break;
  268. default:
  269. bChecked = FALSE;
  270. break;
  271. }
  272. pCmdUI->SetRadio(bChecked ? 1 : 0);
  273. }
  274. }
  275. }
  276. void CMainFrame::OnViewStyle(UINT nCommandID)
  277. {
  278. // TODO: customize or extend this code to handle choices on the
  279. // View menu.
  280. // if the right-hand pane has been created and is a CGUI_ExplorerView,
  281. // process the menu commands...
  282. if (m_pListCtrl != NULL)
  283. {
  284. DWORD dwStyle = (DWORD)-1;
  285. switch (nCommandID)
  286. {
  287. case ID_VIEW_LINEUP:
  288. {
  289. // ask the list control to snap to grid
  290. m_pListCtrl->Arrange(LVA_SNAPTOGRID);
  291. }
  292. break;
  293. // other commands change the style on the list control
  294. case ID_VIEW_DETAILS:
  295. dwStyle = LVS_REPORT;
  296. break;
  297. case ID_VIEW_SMALLICON:
  298. dwStyle = LVS_SMALLICON;
  299. break;
  300. case ID_VIEW_LARGEICON:
  301. dwStyle = LVS_ICON;
  302. break;
  303. case ID_VIEW_LIST:
  304. dwStyle = LVS_LIST;
  305. break;
  306. }
  307. // change the style; window will repaint automatically
  308. if (dwStyle != -1)
  309. m_pListCtrl->ModifyStyle(LVS_TYPEMASK, dwStyle);
  310. }
  311. }
  312. void CMainFrame::OnBack()
  313. {
  314. // TODO: Add your command handler code here
  315. }
  316. void CMainFrame::OnUpdateBack(CCmdUI* pCmdUI)
  317. {
  318. // display disabled image list.
  319. pCmdUI->Enable(FALSE);
  320. }
  321. void CMainFrame::OnForward()
  322. {
  323. // TODO: Add your command handler code here
  324. }
  325. void CMainFrame::OnUpdateForward(CCmdUI* pCmdUI)
  326. {
  327. // display disabled image list.
  328. pCmdUI->Enable(FALSE);
  329. }
  330. void CMainFrame::OnUp()
  331. {
  332. // TODO: Add your command handler code here
  333. if ( m_pTreeView )
  334. {
  335. m_pTreeView->SelectParentItem();
  336. }
  337. }
  338. void CMainFrame::OnUpdateUp(CCmdUI* /*pCmdUI*/)
  339. {
  340. }
  341. void CMainFrame::OnSearch()
  342. {
  343. if (m_wndSplitter.GetColumnCount() == 1)
  344. {
  345. m_wndSplitter.ShowColumn();
  346. if (m_wndSplitter.GetPane(0,0)->IsKindOf(RUNTIME_CLASS(CSearchView)))
  347. {
  348. return;
  349. }
  350. }
  351. if (!m_wndSplitter.GetPane(0,0)->IsKindOf(RUNTIME_CLASS(CSearchView)))
  352. {
  353. if (m_pSearchView == NULL)
  354. {
  355. if (m_wndSplitter.GetPane(0,0)->IsKindOf(
  356. RUNTIME_CLASS(CHistoryView)))
  357. {
  358. m_pHistoryView = (CHistoryView*)m_wndSplitter.ReplaceView(
  359. 0,0,RUNTIME_CLASS(CSearchView));
  360. }
  361. else
  362. {
  363. m_pTreeView  = (CGUI_ExplorerTree*)m_wndSplitter.ReplaceView(
  364. 0,0,RUNTIME_CLASS(CSearchView));
  365. }
  366. }
  367. else
  368. {
  369. if (m_wndSplitter.GetPane(0,0)->IsKindOf(
  370. RUNTIME_CLASS(CHistoryView)))
  371. {
  372. m_pHistoryView = (CHistoryView*)m_wndSplitter.ReplaceView(
  373. 0, 0, (CView*)m_pSearchView);
  374. }
  375. else
  376. {
  377. m_pTreeView = (CGUI_ExplorerTree*)m_wndSplitter.ReplaceView(
  378. 0, 0, (CView*)m_pSearchView);
  379. }
  380. }
  381. }
  382. else
  383. {
  384. m_wndSplitter.HideColumn(0);
  385. }
  386. }
  387. void CMainFrame::OnFolders()
  388. {
  389. if (m_wndSplitter.GetColumnCount() == 1)
  390. {
  391. m_wndSplitter.ShowColumn();
  392. if (m_wndSplitter.GetPane(0,0)->IsKindOf(RUNTIME_CLASS(CGUI_ExplorerTree)))
  393. {
  394. return;
  395. }
  396. }
  397. if (!m_wndSplitter.GetPane(0,0)->IsKindOf(RUNTIME_CLASS(CGUI_ExplorerTree)))
  398. {
  399. if (m_pTreeView == NULL)
  400. {
  401. if (m_wndSplitter.GetPane(0,0)->IsKindOf(
  402. RUNTIME_CLASS(CHistoryView)))
  403. {
  404. m_pHistoryView = (CHistoryView*)m_wndSplitter.ReplaceView(
  405. 0,0,RUNTIME_CLASS(CGUI_ExplorerTree));
  406. }
  407. else
  408. {
  409. m_pSearchView  = (CSearchView*)m_wndSplitter.ReplaceView(
  410. 0,0,RUNTIME_CLASS(CGUI_ExplorerTree));
  411. }
  412. }
  413. else
  414. {
  415. if (m_wndSplitter.GetPane(0,0)->IsKindOf(
  416. RUNTIME_CLASS(CHistoryView)))
  417. {
  418. m_pHistoryView = (CHistoryView*)m_wndSplitter.ReplaceView(
  419. 0, 0, (CView*)m_pTreeView);
  420. }
  421. else
  422. {
  423. m_pSearchView = (CSearchView*)m_wndSplitter.ReplaceView(
  424. 0, 0, (CView*)m_pTreeView);
  425. }
  426. }
  427. }
  428. else
  429. {
  430. m_wndSplitter.HideColumn(0);
  431. }
  432. }
  433. void CMainFrame::OnHistory()
  434. {
  435. if (m_wndSplitter.GetColumnCount() == 1)
  436. {
  437. m_wndSplitter.ShowColumn();
  438. if (m_wndSplitter.GetPane(0,0)->IsKindOf(RUNTIME_CLASS(CHistoryView)))
  439. {
  440. return;
  441. }
  442. }
  443. if (!m_wndSplitter.GetPane(0,0)->IsKindOf(RUNTIME_CLASS(CHistoryView)))
  444. {
  445. if (m_pHistoryView == NULL)
  446. {
  447. if (m_wndSplitter.GetPane(0,0)->IsKindOf(
  448. RUNTIME_CLASS(CGUI_ExplorerTree)))
  449. {
  450. m_pTreeView = (CGUI_ExplorerTree*)m_wndSplitter.ReplaceView(
  451. 0,0,RUNTIME_CLASS(CHistoryView));
  452. }
  453. else
  454. {
  455. m_pSearchView  = (CSearchView*)m_wndSplitter.ReplaceView(
  456. 0,0,RUNTIME_CLASS(CHistoryView));
  457. }
  458. }
  459. else
  460. {
  461. if (m_wndSplitter.GetPane(0,0)->IsKindOf(
  462. RUNTIME_CLASS(CGUI_ExplorerTree)))
  463. {
  464. m_pTreeView = (CGUI_ExplorerTree*)m_wndSplitter.ReplaceView(
  465. 0, 0, (CView*)m_pHistoryView);
  466. }
  467. else
  468. {
  469. m_pSearchView = (CSearchView*)m_wndSplitter.ReplaceView(
  470. 0, 0, (CView*)m_pHistoryView);
  471. }
  472. }
  473. }
  474. else
  475. {
  476. m_wndSplitter.HideColumn(0);
  477. }
  478. }
  479. void CMainFrame::OnMoveto()
  480. {
  481. // TODO: Add your command handler code here
  482. }
  483. void CMainFrame::OnUpdateMoveto(CCmdUI* pCmdUI)
  484. {
  485. // display disabled image list.
  486. pCmdUI->Enable(FALSE);
  487. }
  488. void CMainFrame::OnCopyto()
  489. {
  490. // TODO: Add your command handler code here
  491. }
  492. void CMainFrame::OnUpdateCopyto(CCmdUI* pCmdUI)
  493. {
  494. // display disabled image list.
  495. pCmdUI->Enable(FALSE);
  496. }
  497. void CMainFrame::OnDelete()
  498. {
  499. // TODO: Add your command handler code here
  500. }
  501. void CMainFrame::OnUpdateDelete(CCmdUI* pCmdUI)
  502. {
  503. // display disabled image list.
  504. pCmdUI->Enable(FALSE);
  505. }
  506. void CMainFrame::OnUndo()
  507. {
  508. // TODO: Add your command handler code here
  509. }
  510. void CMainFrame::OnUpdateUndo(CCmdUI* pCmdUI)
  511. {
  512. // display disabled image list.
  513. pCmdUI->Enable(FALSE);
  514. }
  515. void CMainFrame::OnViews()
  516. {
  517. DWORD dwStyle = m_pListCtrl->GetStyle();
  518. switch (dwStyle & (LVS_REPORT | LVS_SMALLICON | LVS_ICON | LVS_LIST))
  519. {
  520. case LVS_ICON:      OnViewStyle( ID_VIEW_SMALLICON ); break;
  521. case LVS_SMALLICON: OnViewStyle( ID_VIEW_LIST );      break;
  522. case LVS_LIST:      OnViewStyle( ID_VIEW_DETAILS );   break;
  523. case LVS_REPORT:    OnViewStyle( ID_VIEW_LARGEICON ); break;
  524. }
  525. }
  526. void CMainFrame::OnUpdateFolders(CCmdUI* pCmdUI)
  527. {
  528. pCmdUI->SetCheck(m_wndSplitter.GetPane(0,0)->IsKindOf(
  529. RUNTIME_CLASS(CGUI_ExplorerTree)));
  530. }
  531. void CMainFrame::OnUpdateSearch(CCmdUI* pCmdUI)
  532. {
  533. pCmdUI->SetCheck(m_wndSplitter.GetPane(0,0)->IsKindOf(
  534. RUNTIME_CLASS(CSearchView)));
  535. }
  536. void CMainFrame::OnUpdateHistory(CCmdUI* pCmdUI)
  537. {
  538. pCmdUI->SetCheck(m_wndSplitter.GetPane(0,0)->IsKindOf(
  539. RUNTIME_CLASS(CHistoryView)));
  540. }
  541. void CMainFrame::InitializeAddressBar()
  542. {
  543. // create a combo box for the address bar
  544. if (!m_wndAddressBar.Create(CBS_DROPDOWN | WS_CHILD,
  545. CRect(0,0,200,400), this, IDC_ADDRESSBAR))
  546. {
  547. TRACE0("Failed to create comboboxn");
  548. return;      // fail to create
  549. }
  550. // set the font for the combo and initialize the toolbar.
  551. m_wndAddressBar.SetFont(&XTAuxData().font);
  552. m_pTreeView   = (CGUI_ExplorerTree*)m_wndSplitter.GetPane(0,0);
  553. m_pFolderView = (CGUI_ExplorerView*)m_wndSplitter.GetPane(0,1);
  554. m_pTreeCtrl = &m_pTreeView->GetTreeCtrl();
  555. m_pListCtrl = &m_pFolderView->GetListCtrl();
  556. m_pListCtrl->AssociateTree (m_pTreeCtrl);
  557. m_pTreeCtrl->AssociateList (m_pListCtrl);
  558. m_pTreeCtrl->AssociateCombo(&m_wndAddressBar);
  559. }
  560. LRESULT CMainFrame::OnUpdateShell(WPARAM wParam, LPARAM /*lParam*/)
  561. {
  562. switch (wParam)
  563. {
  564. case SHN_XT_INETFOLDER:
  565. {
  566. int iCount = m_wndSplitter.GetColumnCount( );
  567. CWnd* pWnd = m_wndSplitter.GetPane( 0,iCount-1 );
  568. if ( pWnd && pWnd->IsKindOf( RUNTIME_CLASS( CInternetView ) ) )
  569. break;
  570. if ( m_pINetView == NULL )
  571. {
  572. m_pFolderView = ( CGUI_ExplorerView* )m_wndSplitter.ReplaceView(
  573. 0,iCount-1, RUNTIME_CLASS( CInternetView ) );
  574. }
  575. else
  576. {
  577. m_pFolderView = ( CGUI_ExplorerView* )m_wndSplitter.ReplaceView(
  578. 0,iCount-1, ( CView* )m_pINetView );
  579. }
  580. }
  581. break;
  582. default:
  583. {
  584. int iCount = m_wndSplitter.GetColumnCount( );
  585. CWnd* pWnd = m_wndSplitter.GetPane( 0,iCount-1 );
  586. if ( pWnd && pWnd->IsKindOf( RUNTIME_CLASS( CGUI_ExplorerView ) ) )
  587. break;
  588. m_pINetView = ( CInternetView* )m_wndSplitter.ReplaceView(
  589. 0,1, ( CView* )m_pFolderView );
  590. }
  591. break;
  592. }
  593. return 0;
  594. }
  595. void CMainFrame::OnViewXpmode()
  596. {
  597. XTAuxData().bXPMode = !XTAuxData().bXPMode;
  598. CXTCaptionButton& captBtn = m_pTreeView->m_wndCaption.GetCaptionButton();
  599. if (XTAuxData().bXPMode)
  600. {
  601. captBtn.SetXButtonStyle(
  602. (captBtn.GetXButtonStyle() | BS_XT_XPFLAT) & ~BS_XT_FLAT);
  603. }
  604. else
  605. {
  606. captBtn.SetXButtonStyle(
  607. (captBtn.GetXButtonStyle() | BS_XT_FLAT) & ~BS_XT_XPFLAT);
  608. }
  609. if (XTAuxData().bXPMode)
  610. CXTPPaintManager::SetCustomTheme(new CXTPReBarPaintManager<CXTPWhidbeyTheme>);
  611. else
  612. CXTPPaintManager::SetCustomTheme(new CXTPReBarPaintManager<CXTPNativeXPTheme>);
  613. XTPPaintManager()->GetIconsInfo()->bUseDisabledIcons = TRUE;
  614. XTPPaintManager()->GetIconsInfo()->bUseFadedIcons = FALSE;
  615. XTPPaintManager()->GetIconsInfo()->bIconsWithShadow = FALSE;
  616. RedrawWindow(NULL, NULL,
  617. RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_ALLCHILDREN);
  618. GetCommandBars()->RedrawCommandBars();
  619. }
  620. void CMainFrame::OnUpdateViewXpmode(CCmdUI* pCmdUI)
  621. {
  622. pCmdUI->SetCheck(XTAuxData().bXPMode);
  623. }
  624. void CMainFrame::OnClose()
  625. {
  626. SaveCommandBars(lpszProfileName);
  627. m_wndReBar.SaveState(lpszProfileName);
  628. // save frame window size and position.
  629. m_wndPosition.SaveWindowPos(this);
  630. CFrameWnd::OnClose();
  631. }
  632. BOOL CMainFrame::ShowWindowEx(int nCmdShow)
  633. {
  634. ASSERT_VALID(this);
  635. // restore saved rebar state.
  636. //m_wndReBar.LoadState(_T("Rebar State"));
  637. // restore frame window size and position.
  638. m_wndPosition.LoadWindowPos(this);
  639. nCmdShow = m_wndPosition.showCmd;
  640. return ShowWindow(SW_SHOW);
  641. }
  642. void CMainFrame::OnAddressBarEnter()
  643. {
  644. CString strNewPath;
  645. m_wndAddressBar.GetWindowText(strNewPath);
  646. if (strNewPath.GetLength())
  647. {
  648. m_pTreeCtrl->TunnelTree(strNewPath);
  649. }
  650. }
  651. void CMainFrame::OnSelEndOkAddressBar()
  652. {
  653. if (m_pTreeCtrl != NULL)
  654. {
  655. HTREEITEM hItem = (HTREEITEM)m_wndAddressBar.GetItemData(
  656. m_wndAddressBar.GetCurSel());
  657. if (hItem != NULL) {
  658. m_pTreeCtrl->SelectItem(hItem);
  659. }
  660. }
  661. }
  662. void CMainFrame::OnGo()
  663. {
  664. // TODO: Add your command handler code here
  665. OnAddressBarEnter();
  666. }
  667. int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)
  668. {
  669. if (lpCreateControl->nID == ID_VIEWS)
  670. {
  671. lpCreateControl->controlType = xtpControlSplitButtonPopup;
  672. return TRUE;
  673. }
  674. if (lpCreateControl->nID == ID_VIEWS)
  675. {
  676. lpCreateControl->controlType = xtpControlSplitButtonPopup;
  677. return TRUE;
  678. }
  679. switch (lpCreateControl->nID)
  680. {
  681. case ID_BACK:
  682. case ID_VIEW_SEARCH:
  683. case ID_VIEW_FOLDERS:
  684. case ID_VIEW_HISTORY:
  685. case ID_GO:
  686. lpCreateControl->buttonStyle = xtpButtonIconAndCaption;
  687. return TRUE;
  688. }
  689. return FALSE;
  690. }
  691. void CMainFrame::OnCustomize()
  692. {
  693. CXTPCustomizeSheet cs(GetCommandBars());
  694. CXTPCustomizeOptionsPage pageOptions(&cs);
  695. cs.AddPage(&pageOptions);
  696. CXTPCustomizeCommandsPage* pCommands = cs.GetCommandsPage();
  697. pCommands->AddCategories(IDR_MAINFRAME);
  698. pCommands->InsertAllCommandsCategory();
  699. pCommands->InsertBuiltInMenus(IDR_MAINFRAME);
  700. pCommands->InsertNewMenuCategory();
  701. cs.DoModal();
  702. }
  703. void CMainFrame::SetFilter()
  704. {
  705. CFileFilter dlg;
  706. dlg.m_csFilter = m_csFilter; // In case one was set previously
  707. if(dlg.DoModal() == IDOK) 
  708. {
  709. m_csFilter = dlg.m_csFilter;
  710. m_pFolderView->GetListCtrl().SetIncludeExtensions(m_csFilter);
  711. m_pFolderView->GetListCtrl().RefreshList();
  712. }
  713. }
  714. void CMainFrame::OnViewSetfilter()
  715. {
  716. SetFilter();
  717. }