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

界面编程

开发平台:

Visual C++

  1. // PageShellListCtrl.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "profuis_controls.h"
  5. #include "PageShellListCtrl.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_LIST_VIEW_CTRL )
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CPageShellListCtrl dialog
  14. CPageShellListCtrl::CPageShellListCtrl(CWnd* pParent /*=NULL*/)
  15. : CPageBase(CPageShellListCtrl::IDD, pParent)
  16. , m_bInitComplete( false )
  17. {
  18. //{{AFX_DATA_INIT(CPageShellListCtrl)
  19. //}}AFX_DATA_INIT
  20. SetAutoSubclassChildControls();
  21. }
  22. void CPageShellListCtrl::DoDataExchange(CDataExchange* pDX)
  23. {
  24. CPageBase::DoDataExchange(pDX);
  25. //{{AFX_DATA_MAP(CPageShellListCtrl)
  26. DDX_Control( pDX, IDC_CHECK_ROOT_FOLDER_STATE, m_checkRootFolder );
  27. DDX_Control( pDX, IDC_CHECK_FOLDER_BEFORE_OTHER, m_checkFolderBeforeOther );
  28. DDX_Control( pDX, IDC_CHECK_EDITING, m_checkEdit );
  29. DDX_Control( pDX, IDC_CHECK_VIEW_FILES, m_checkViewFiles );
  30. DDX_Control( pDX, IDC_CHECK_UP_FOLDER_STATE, m_checkUpFolder );
  31. DDX_Control( pDX, IDC_CHECK_SHOW_HIDDEN_STATE, m_checkShowHiddenState );
  32. DDX_Control( pDX, IDC_CHECK_WATCH_FILE_SYSTEM, m_checkWatchFileSystem );
  33. DDX_Control( pDX, IDC_COMBO_LIST_SORT, m_comboListSort );
  34. DDX_Control( pDX, ID_BOTTON_GO, m_buttonGo );
  35. DDX_Control( pDX, IDC_EDIT_PATH, m_editPath );
  36. DDX_Control( pDX, IDC_COMBO_LIST_TYPE, m_comboListType );
  37. //}}AFX_DATA_MAP
  38. DDX_Control( pDX, IDC_SHELL_LIST_CTRL, m_wndList );
  39. }
  40. BEGIN_MESSAGE_MAP(CPageShellListCtrl, CPageBase)
  41. //{{AFX_MSG_MAP(CPageShellListCtrl)
  42. ON_CBN_SELENDOK( IDC_COMBO_LIST_TYPE, OnSelendokComboListType )
  43. ON_BN_CLICKED( ID_BOTTON_GO, OnBottonGo )
  44. ON_CBN_SELENDOK( IDC_COMBO_LIST_SORT, OnSelendokComboListSort )
  45. ON_BN_CLICKED( IDC_CHECK_EDITING, OnCheckEditing )
  46. ON_BN_CLICKED( IDC_CHECK_VIEW_FILES, OnCheckViewFiles )
  47. ON_BN_CLICKED( IDC_CHECK_UP_FOLDER_STATE, OnCheckUpFolder )
  48. ON_BN_CLICKED( IDC_CHECK_FOLDER_BEFORE_OTHER, OnCheckFolderBeforeOther )
  49. ON_BN_CLICKED( IDC_CHECK_ROOT_FOLDER_STATE, OnCheckRootFolder )
  50. ON_BN_CLICKED( IDC_CHECK_SHOW_HIDDEN_STATE, OnCheckShowHidden )
  51. ON_BN_CLICKED( IDC_CHECK_WATCH_FILE_SYSTEM, OnCheckWatchFileSystem )
  52. //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CPageShellListCtrl message handlers
  56. BOOL CPageShellListCtrl::OnInitDialog() 
  57. {
  58. CPageBase::OnInitDialog();
  59. AddAnchor( IDC_SHELL_LIST_CTRL, __RDA_LT, __RDA_RB );
  60. AddAnchor( IDC_COMBO_LIST_TYPE, __RDA_RT );
  61. AddAnchor( IDC_EDIT_PATH, __RDA_LT, __RDA_RT );
  62. AddAnchor( ID_BOTTON_GO, __RDA_RT );
  63. AddAnchor( IDC_COMBO_LIST_SORT, __RDA_RT );
  64. AddAnchor( IDC_CHECK_EDITING, __RDA_RT );
  65. AddAnchor( IDC_CHECK_VIEW_FILES, __RDA_RT );
  66. AddAnchor( IDC_CHECK_UP_FOLDER_STATE, __RDA_RT );
  67. AddAnchor( IDC_CHECK_FOLDER_BEFORE_OTHER, __RDA_RT );
  68. AddAnchor( IDC_CHECK_ROOT_FOLDER_STATE, __RDA_RT );
  69. AddAnchor( IDC_CHECK_SHOW_HIDDEN_STATE, __RDA_RT );
  70. AddAnchor( IDC_CHECK_WATCH_FILE_SYSTEM, __RDA_RT );
  71. m_wndList.SetExtendedStyle( m_wndList.GetExtendedStyle() | LVS_EX_HEADERDRAGDROP );
  72. // VERIFY( m_wndList.FocusPath( _T("C:\") ) );
  73. VERIFY( m_wndList.FocusPIDL() );
  74. m_checkUpFolder.SetCheck(1);
  75. m_checkViewFiles.SetCheck(1);
  76. m_checkFolderBeforeOther.SetCheck(1);
  77. m_checkRootFolder.SetCheck(1);
  78. m_checkWatchFileSystem.SetCheck(1);
  79. m_comboListType.SetCurSel( 2 );
  80. OnSelendokComboListType();
  81. m_comboListSort.SetCurSel( 0 );
  82. OnSelendokComboListSort();
  83. OnCheckUpFolder();
  84. OnCheckRootFolder();
  85. m_bInitComplete = true;
  86. return TRUE;
  87. }
  88. void CPageShellListCtrl::OnSelendokComboListType() 
  89. {
  90. int nSel = m_comboListType.GetCurSel();
  91. if( nSel < 0 )
  92. return;
  93. ASSERT( nSel < 4 );
  94. DWORD dwArrStyles[4] = { LVS_SMALLICON, LVS_ICON, LVS_LIST, LVS_REPORT };
  95. m_wndList.ModifyStyle( LVS_TYPEMASK, dwArrStyles[nSel], SWP_FRAMECHANGED );
  96. }
  97. void CPageShellListCtrl::OnBottonGo() 
  98. {
  99. CString strPath;
  100. m_editPath.GetWindowText( strPath );
  101. if( ! m_wndList.FocusPath( LPCTSTR(strPath) ) )
  102. ::Beep( 8000, 100 );
  103. }
  104. void CPageShellListCtrl::OnSelendokComboListSort() 
  105. {
  106. int nSel = m_comboListSort.GetCurSel();
  107. if( nSel < 0 )
  108. return;
  109. ASSERT( nSel < 3 );
  110. DWORD dwArrStyles[3] = { 0, LVS_SORTASCENDING, LVS_SORTDESCENDING };
  111. m_wndList.ModifyStyle( LVS_SORTASCENDING|LVS_SORTDESCENDING, dwArrStyles[nSel], SWP_FRAMECHANGED );
  112. //m_wndList.SortItems()
  113. // CExtSafeString s = m_wndList.GetCurrentFolderPath();
  114. //  m_wndList.BrowseToFolder( s );
  115. }
  116. void CPageShellListCtrl::OnCheckEditing() 
  117. {
  118. if( m_checkEdit.GetCheck() )
  119. m_wndList.ModifyStyle( NULL, LVS_EDITLABELS );
  120. else
  121. m_wndList.ModifyStyle( LVS_EDITLABELS, NULL );
  122. }
  123. void CPageShellListCtrl::OnCheckViewFiles() 
  124. {
  125. if( m_checkViewFiles.GetCheck() )
  126. m_wndList.IncludeFilesSet( true );
  127. else
  128. m_wndList.IncludeFilesSet( false );
  129. }
  130. void CPageShellListCtrl::OnCheckUpFolder() 
  131. {
  132. if( m_checkUpFolder.GetCheck() )
  133. m_wndList.ShowParentFolderItemSet( true );
  134. else
  135. m_wndList.ShowParentFolderItemSet( false );
  136. }
  137. void CPageShellListCtrl::OnCheckFolderBeforeOther() 
  138. {
  139. if( m_checkFolderBeforeOther.GetCheck() )
  140. m_wndList.FoldersBeforeOthersSet( true );
  141. else
  142. m_wndList.FoldersBeforeOthersSet( false );
  143. }
  144. void CPageShellListCtrl::OnCheckRootFolder()
  145. {
  146. if( m_checkRootFolder.GetCheck() )
  147. m_wndList.ShowRootFolderItemSet( true );
  148. else
  149. m_wndList.ShowRootFolderItemSet( false );
  150. }
  151. void CPageShellListCtrl::OnCheckShowHidden()
  152. {
  153. if( m_checkShowHiddenState.GetCheck() != 0 )
  154. m_wndList.m_dwAttributeFilterAny |= SFGAO_HIDDEN;
  155. else
  156. m_wndList.m_dwAttributeFilterAny &= ~(SFGAO_HIDDEN);
  157. m_wndList.RescanContent();
  158. //  if( m_checkShowHiddenState.GetCheck() )
  159. //  m_wndList.ShowHiddenStateSet( true );
  160. //  else
  161. //  m_wndList.ShowHiddenStateSet( false );
  162. }
  163. void CPageShellListCtrl::OnCheckWatchFileSystem()
  164. {
  165. if( m_checkWatchFileSystem.GetCheck() )
  166. m_wndList.WatchFileSystemSet( true );
  167. else
  168. m_wndList.WatchFileSystemSet( false );
  169. }
  170. #endif // ( ! defined __EXT_MFC_NO_SHELL_LIST_VIEW_CTRL )