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

界面编程

开发平台:

Visual C++

  1. // PageShellBrowser.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "profuis_controls.h"
  5. #include "PageShellBrowser.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 ) && ( ! defined __EXT_MFC_NO_SHELL_TREE_VIEW_CTRL )&& ( ! defined __EXT_MFC_NO_SHELL_COMBO_BOX )
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CPageShellBrowser dialog
  14. CPageShellBrowser::CPageShellBrowser(CWnd* pParent /*=NULL*/)
  15. : CPageBase(CPageShellBrowser::IDD, pParent)
  16. , m_bInitComplete( false )
  17. , m_bHaldingSelectionInTree( false )
  18. , m_bHaldingSelectionInList( false )
  19. , m_bHaldingSelectionInCombo( false )
  20. {
  21. //{{AFX_DATA_INIT(CPageShellBrowser)
  22. //}}AFX_DATA_INIT
  23. SetAutoSubclassChildControls();
  24. }
  25. void CPageShellBrowser::DoDataExchange(CDataExchange* pDX)
  26. {
  27. CPageBase::DoDataExchange(pDX);
  28. //{{AFX_DATA_MAP(CPageShellBrowser)
  29. //}}AFX_DATA_MAP
  30. DDX_Control( pDX, IDC_COMBO1, m_wndCombo );
  31. DDX_Control( pDX, IDC_SHELL_LIST_CTRL, m_wndList );
  32. DDX_Control( pDX, IDC_TREE1, m_wndTree );
  33. }
  34. BEGIN_MESSAGE_MAP(CPageShellBrowser, CPageBase)
  35. //{{AFX_MSG_MAP(CPageShellBrowser)
  36. ON_REGISTERED_MESSAGE( CExtShellListCtrl::g_nMsgShellLocationChanged, OnShellListLocationChanged )
  37. ON_REGISTERED_MESSAGE( CExtShellComboBox::g_nMsgShellLocationChanged, OnShellComboLocationChanged )
  38. ON_REGISTERED_MESSAGE( CExtTreeCtrl::g_nMsgTreeItemDelayedFocus, OnShellTreeDelayedItemFocus )
  39. //}}AFX_MSG_MAP
  40. END_MESSAGE_MAP()
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CPageShellBrowser message handlers
  43. BOOL CPageShellBrowser::OnInitDialog() 
  44. {
  45. CPageBase::OnInitDialog();
  46. // VERIFY( m_wndList.BrowseToFolder( _T("C:\") ) );
  47. // VERIFY( m_wndList.BrowseToFolder() );
  48. //m_wndTree.OutlineStyleSet(CExtTreeCtrl::outline_style_solid);
  49. //m_wndTree.ModifyStyle( 0, TVS_HASBUTTONS|TVS_LINESATROOT );
  50. m_wndTree.RefreshShellRoot();
  51. m_wndTree.FocusItem( m_wndTree.GetChildItem( TVI_ROOT ), true, false, true );
  52. m_wndTree.ModifyStyle( 0, /*TVS_SINGLEEXPAND|*/ TVS_TRACKSELECT|TVS_EDITLABELS );
  53. m_wndList.SetExtendedStyle( LVS_EX_UNDERLINEHOT|LVS_EX_UNDERLINECOLD );
  54. m_wndList.ModifyStyle( 0, LVS_EDITLABELS );
  55. INT nAnchorPercentForTree = 25;
  56. AddAnchor( IDC_TREE1, __RDA_LT, CSize(nAnchorPercentForTree,100) );
  57. AddAnchor( IDC_SHELL_LIST_CTRL, CSize(nAnchorPercentForTree,0), __RDA_RB );
  58. AddAnchor( IDC_COMBO1, __RDA_LT, __RDA_RT );
  59. m_bInitComplete = true;
  60. return TRUE;
  61. }
  62. LRESULT CPageShellBrowser::OnShellTreeDelayedItemFocus( WPARAM wParam, LPARAM lParam )
  63. {
  64. ASSERT_VALID( this );
  65. CExtShellTreeCtrl * pST = (CExtShellTreeCtrl*)wParam;
  66. ASSERT( pST != NULL );
  67. if( pST->m_hWnd != m_wndTree.m_hWnd )
  68. return 0L;
  69. if( ( lParam & CExtTreeCtrl::__PARM_DELAYED_FOCUS_BEGIN_WAITING ) != 0 )
  70. {
  71. if( ( lParam & CExtTreeCtrl::__PARM_DELAYED_FOCUS_MOUSE_CLICK ) == 0 )
  72. return 0L;
  73. }
  74. if( m_bHaldingSelectionInList || m_bHaldingSelectionInCombo )
  75. return 0L;
  76. m_bHaldingSelectionInTree = true;
  77. HTREEITEM htiSelect = m_wndTree.GetFocusedItem();
  78. ASSERT( htiSelect != NULL );
  79. CExtTreeCtrl::TREEITEMINFO_t & _TII = m_wndTree.TreeItemInfoGet( htiSelect );
  80. CExtShellItemData * pData = (CExtShellItemData*)_TII.m_lParam; //new CExtShellItemData;
  81. ASSERT( pData != NULL );
  82. LPITEMIDLIST pidlSelect = (LPITEMIDLIST)pData->m_pidlAbsolute.GetPtr();
  83. ASSERT( pidlSelect != NULL );
  84. m_wndList.DelayFocusPIDL( pidlSelect );
  85. m_wndCombo.DelayFocusPIDL( pidlSelect );
  86. m_bHaldingSelectionInTree = false;
  87. return 0L;
  88. }
  89. LRESULT CPageShellBrowser::OnShellListLocationChanged( WPARAM wParam, LPARAM lParam )
  90. {
  91. ASSERT_VALID( this );
  92. lParam;
  93. CExtShellListCtrl * pSL = (CExtShellListCtrl*)wParam;
  94. ASSERT( pSL != NULL );
  95. if( pSL->m_hWnd != m_wndList.m_hWnd )
  96. return 0L;
  97. if( m_bHaldingSelectionInTree || m_bHaldingSelectionInCombo )
  98. return 0L;
  99. m_bHaldingSelectionInList = true;
  100. //m_wndTree.FocusPath( m_wndList.GetCurrentFolderPath() );
  101. m_wndTree.DelayFocusPIDL( m_wndList.GetCurrentFolderPIDL() );
  102. m_wndCombo.DelayFocusPIDL( m_wndList.GetCurrentFolderPIDL() );
  103. m_bHaldingSelectionInList = false;
  104. return 0L;
  105. }
  106. LRESULT CPageShellBrowser::OnShellComboLocationChanged( WPARAM wParam, LPARAM lParam )
  107. {
  108. ASSERT_VALID( this );
  109. lParam;
  110. CExtShellComboBox * pSL = (CExtShellComboBox*)wParam;
  111. ASSERT( pSL != NULL );
  112. if( pSL->m_hWnd != m_wndCombo.m_hWnd )
  113. return 0L;
  114. if( m_bHaldingSelectionInTree || m_bHaldingSelectionInList )
  115. return 0L;
  116. m_bHaldingSelectionInCombo = true;
  117. //m_wndTree.FocusPath( m_wndList.GetCurrentFolderPath() );
  118. m_wndTree.DelayFocusPIDL( m_wndCombo.GetCurrentFolderPIDL() );
  119. m_wndList.DelayFocusPIDL( m_wndCombo.GetCurrentFolderPIDL() );
  120. m_bHaldingSelectionInCombo = false;
  121. return 0L;
  122. }
  123. #endif // ( ! defined __EXT_MFC_NO_SHELL_TREE_VIEW_CTRL ) && ( ! defined __EXT_MFC_NO_SHELL_TREE_VIEW_CTRL )&& ( ! defined __EXT_MFC_NO_SHELL_COMBO_BOX )