PageShellTreeCtrl.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:5k
源码类别:

界面编程

开发平台:

Visual C++

  1. // PageShellTreeCtrl.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "profuis_controls.h"
  5. #include "PageShellTreeCtrl.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. #if ( ! defined __EXT_MFC_NO_SHELL_TREE_VIEW_CTRL )
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CPageShellTreeCtrl dialog
  14. CPageShellTreeCtrl::CPageShellTreeCtrl(CWnd* pParent /*=NULL*/)
  15. : CPageBase(CPageShellTreeCtrl::IDD, pParent)
  16. , m_bInitComplete( false )
  17. {
  18. //{{AFX_DATA_INIT(CPageShellTreeCtrl)
  19. //}}AFX_DATA_INIT
  20. SetAutoSubclassChildControls();
  21. }
  22. void CPageShellTreeCtrl::DoDataExchange(CDataExchange* pDX)
  23. {
  24. CPageBase::DoDataExchange(pDX);
  25. //{{AFX_DATA_MAP(CPageShellTreeCtrl)
  26. DDX_Control( pDX, IDC_BUTTON_GO, m_buttonGo );
  27. DDX_Control( pDX, IDC_MAKE_NEW_FOLDER_BUTTON, m_buttonMakeNewFolder );
  28. DDX_Control( pDX, IDC_EDIT_PATH, m_editPath );
  29. DDX_Control( pDX, IDC_INCLUDE_FILE_CHECK, m_checkIncludeFiles );
  30. DDX_Control( pDX, IDC_EDITING_LABELS_CHECK, m_checkEditLabels );
  31. DDX_Control( pDX, IDC_SHOW_HIDDEN_FILES_CHECK, m_checkShowHiddenItems );
  32. DDX_Control( pDX, IDC_WATCH_FILE_SYSTEM_CHECK, m_checkWatchFileSystem );
  33. //}}AFX_DATA_MAP
  34. DDX_Control( pDX, IDC_TREE1, m_wndTree );
  35. }
  36. BEGIN_MESSAGE_MAP(CPageShellTreeCtrl, CPageBase)
  37. //{{AFX_MSG_MAP(CPageShellTreeCtrl)
  38. ON_BN_CLICKED( IDC_BUTTON_GO, OnBnClickedButtonGo )
  39. ON_BN_CLICKED( IDC_MAKE_NEW_FOLDER_BUTTON, OnBnClickedMakeNewFolderButton )
  40. ON_BN_CLICKED( IDC_INCLUDE_FILE_CHECK, OnBnClickedShowFilesCheck )
  41. ON_BN_CLICKED( IDC_SHOW_HIDDEN_FILES_CHECK, OnBnClickedShowHiddenFilesCheck )
  42. ON_BN_CLICKED( IDC_EDITING_LABELS_CHECK, OnBnClickedEditingLabelsCheck )
  43. ON_BN_CLICKED( IDC_WATCH_FILE_SYSTEM_CHECK, OnBnClickedWatchFileSystemCheck )
  44. ON_NOTIFY( NM_RCLICK, IDC_TREE1, OnNMRclickTree1 )
  45. //}}AFX_MSG_MAP
  46. END_MESSAGE_MAP()
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CPageShellTreeCtrl message handlers
  49. BOOL CPageShellTreeCtrl::OnInitDialog() 
  50. {
  51. CPageBase::OnInitDialog();
  52. m_wndTree.LineStyleSet(CExtTreeCtrl::line_style_solid);
  53. m_wndTree.ModifyStyle( 0, /*TVS_FULLROWSELECT|*/ TVS_HASBUTTONS|TVS_LINESATROOT );
  54. m_wndTree.ModifyStyle( 0, TVS_HASBUTTONS|TVS_LINESATROOT );
  55. m_wndTree.TreeModifyStyle( __EXT_TREE_MULTIPLE_SELECTION );
  56. m_wndTree.RefreshShellRoot();
  57. m_checkEditLabels.SetCheck(1);
  58. m_checkWatchFileSystem.SetCheck(1);
  59. OnBnClickedEditingLabelsCheck();
  60. AddAnchor( IDC_TREE1, __RDA_LT, __RDA_RB );
  61. AddAnchor( IDC_EDIT_PATH, __RDA_LT, __RDA_RT );
  62. AddAnchor( IDC_BUTTON_GO, __RDA_RT );
  63. AddAnchor( IDC_MAKE_NEW_FOLDER_BUTTON, __RDA_RT );
  64. AddAnchor( IDC_INCLUDE_FILE_CHECK, __RDA_RT );
  65. AddAnchor( IDC_SHOW_HIDDEN_FILES_CHECK, __RDA_RT );
  66. AddAnchor( IDC_EDITING_LABELS_CHECK, __RDA_RT );
  67. AddAnchor( IDC_WATCH_FILE_SYSTEM_CHECK, __RDA_RT );
  68. m_bInitComplete = true;
  69. return TRUE;
  70. }
  71. void CPageShellTreeCtrl::OnBnClickedButtonGo()
  72. {
  73. CString strPath;
  74. m_editPath.GetWindowText( strPath );
  75. m_wndTree.FocusPath( LPCTSTR(strPath) );
  76. m_wndTree.SetFocus();
  77. }
  78. void CPageShellTreeCtrl::OnBnClickedMakeNewFolderButton()
  79. {
  80. CString strNewFolderName;
  81. m_editPath.GetWindowText( strNewFolderName );
  82. m_wndTree._CreateFolder( LPCTSTR(strNewFolderName) );
  83. }
  84. void CPageShellTreeCtrl::OnBnClickedShowFilesCheck()
  85. {
  86. if( m_checkIncludeFiles.GetCheck() == BST_CHECKED )
  87. m_wndTree.IncludeFilesSet( true );
  88. if( m_checkIncludeFiles.GetCheck() == BST_UNCHECKED )
  89. m_wndTree.IncludeFilesSet( false );
  90. }
  91. void CPageShellTreeCtrl::OnBnClickedShowHiddenFilesCheck()
  92. {
  93. if( m_checkShowHiddenItems.GetCheck() != 0 )
  94. m_wndTree.m_dwAttributeFilterAny |= SFGAO_HIDDEN;
  95. else
  96. m_wndTree.m_dwAttributeFilterAny &= ~(SFGAO_HIDDEN);
  97. m_wndTree.RescanContent();
  98. }
  99. void CPageShellTreeCtrl::OnBnClickedEditingLabelsCheck()
  100. {
  101. if( m_checkEditLabels.GetCheck() == BST_CHECKED )
  102. if( ( m_wndTree.GetStyle() & TVS_EDITLABELS ) == 0 )
  103. m_wndTree.ModifyStyle( NULL, TVS_EDITLABELS );
  104. if( m_checkEditLabels.GetCheck() == BST_UNCHECKED )
  105. if( ( m_wndTree.GetStyle() & TVS_EDITLABELS ) != 0 )
  106. m_wndTree.ModifyStyle( TVS_EDITLABELS, NULL );
  107. m_wndTree.Invalidate();
  108. }
  109. void CPageShellTreeCtrl::OnNMRclickTree1(NMHDR *pNMHDR, LRESULT *pResult)
  110. {
  111. pNMHDR;
  112. (*pResult) = 0;
  113. }
  114. void CPageShellTreeCtrl::OnBnClickedWatchFileSystemCheck()
  115. {
  116. if( m_checkWatchFileSystem.GetCheck() == BST_CHECKED )
  117. m_wndTree.WatchFileSystemSet( true );
  118. if( m_checkWatchFileSystem.GetCheck() == BST_UNCHECKED )
  119. m_wndTree.WatchFileSystemSet( false );
  120. }
  121. #endif // ( ! defined __EXT_MFC_NO_SHELL_TREE_VIEW_CTRL )