Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Jia Hong Li
|
Mar 5, 2007 - 11:18 AM
|
I create some CTreeCtrl in CExtPageNavigatorWnd object, and all CTreeCtrl seem to be not scrollable. How could I do ?
|
|
Technical Support
|
Mar 6, 2007 - 9:39 AM
|
That line looks strange. Why do you create a new tree (m_TreeCtrl_AllFolder ) as a child of another tree (m_wndPNAllFolders )? m_TreeCtrl_AllFolder.Create(WS_VISIBLE|WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT,
recta, &m_wndPNAllFolders, IDC_TREEDIR);
|
|
Jia Hong Li
|
Mar 6, 2007 - 10:37 PM
|
Sorry, I lose a line in my post code:
///////////////////////////// MainFrm.h ////////////////////////////////// ... CDirTreeCtrl m_TreeCtrl_AllFolder; ...
CDirTreeCtrl look like : http://picasaweb.google.com.tw/ooy.yoo/Others/photo#5039047524469930946 CDirTreeCtrl inheri from CTreeCtrl class
My unscrollable problem seem to have no concern with CDirTreeCtrl, but to m_wndResizableBarTree(CExtControlBar class) which I use for replacing the m_wndSplitter(CExtSplitterWnd class)
|
|
Jia Hong Li
|
Mar 6, 2007 - 10:48 PM
|
PS:
Original Structure in PageNavigator: CPNSplitterWnd --[contain]--> CExtPageNavigatorWnd --[constain]--> CTreeCtrl My Structure: CExtControlBar --[contain]--> CExtPageNavigatorWnd --[constain]--> CTreeCtrl --[contain]--> CDirTreeCtrl
The different (may cause of my unscrollable problem) is I use CExtControlBar instead of CPNSplitterWnd
|
|
Technical Support
|
Mar 7, 2007 - 6:08 AM
|
Your Structure should look like CExtControlBar -- [contain] --> CExtPageNavigatorWnd --[contain]--> CDirTreeCtrl So the CDirTreeCtrl control should be created as a child of the CExtPageNavigatorWnd , not CTreeCtrl . You can send the CDirTreeCtrl class to us so we can help you insert it into the page navigator.
|
|
Jia Hong Li
|
Mar 7, 2007 - 8:41 PM
|
Ok, I fix that problem now, thanks.
But the other problem: However I change the theme from UI Theme Switcher Toolbar, the Scrollbar look always is default gray
How could I change the theme of Scrollbar ??
|
|
Suhai Gyorgy
|
Mar 8, 2007 - 2:20 AM
|
The scrollbars you see are the scrollbars of the CDirTreeCtrl class, which I think is derived from CTreeCtrl, a pure MFC class, that’s why those scrollbars are not themed, because they have nothing to do with ProfUIS. But you can override CWnd::GetScrollBarCtrl method and have ProfUIS scrollbars created, thus they will be themed properly. Here’s how I think it should look like: class CDirTreeCtrl : public CTreeCtrl
{
...
protected:
CExtScrollBar m_wndScrollBarH, m_wndScrollBarV;
public:
virtual CScrollBar * GetScrollBarCtrl( int nBar ) const
{
ASSERT_VALID( this );
if( m_hWnd == NULL || (! ::IsWindow(m_hWnd) ) )
return NULL;
ASSERT( nBar == SB_HORZ || nBar == SB_VERT );
if( nBar == SB_HORZ )
{
if( m_wndScrollBarH.GetSafeHwnd() != NULL )
return ( const_cast < CExtScrollBar * > ( &m_wndScrollBarH ) );
} // if( nBar == SB_HORZ )
else
{
if( m_wndScrollBarV.GetSafeHwnd() != NULL )
return ( const_cast < CExtScrollBar * > ( &m_wndScrollBarV ) );
} // else from if( nBar == SB_HORZ )
return NULL;
}
virtual LRESULT WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
{
LRESULT lResult = CTreeCtrl::WindowProc( message, wParam, lParam );
if ( message == WM_CREATE )
{
m_wndScrollBarH.m_eSO = CExtScrollBar::__ESO_BOTTOM;
m_wndScrollBarV.m_eSO = CExtScrollBar::__ESO_RIGHT;
if( ! m_wndScrollBarV.Create(
WS_CHILD|WS_VISIBLE|SBS_VERT|SBS_RIGHTALIGN,
CRect(0,0,0,0),
this,
1
)
)
{
ASSERT( FALSE );
break;
}
if( ! m_wndScrollBarH.Create(
WS_CHILD|WS_VISIBLE|SBS_HORZ|SBS_BOTTOMALIGN,
CRect(0,0,0,0),
this,
2
)
)
{
ASSERT( FALSE );
break;
}
m_wndScrollBarH.SyncReservedSpace( &m_wndScrollBarV );
m_wndScrollBarV.SyncReservedSpace( &m_wndScrollBarH );
//OnSwRecalcLayout( true ); // I’m not sure what to call instead of this and whether it’s needed at all.
}
return lResult;
}
...
};
Or if you already have a CDirTreeCtrl::OnCreate method implemented, the code snippet from WindowProc should be placed there.
|
|
Jia Hong Li
|
Mar 8, 2007 - 8:36 PM
|
Everything work find except "OnSwRecalcLayout(true)" How could I make sure how to use something like "OnSwRecalcLayout(true)"
|
|
Technical Support
|
Mar 9, 2007 - 10:36 AM
|
You can learn more about this if you look at this sample.
|
|
Jia Hong Li
|
Mar 5, 2007 - 7:51 PM
|
In other words, I need the TreeCtrl in the PageNavigator sample (allfolder, favorite, shortcut) to be scrollable
|
|
Jia Hong Li
|
Mar 6, 2007 - 2:04 AM
|
Now my app structure:
CExtControlBar --[contain]--> CExtPageNavigatorWnd --[constain]--> CTreeCtrl --[contain]--> CDirTreeCtrl
The Folder browsing in the CDirTreeCtrl won’t be scrollable
Code:
///////////////////////////// MainFrm.h ////////////////////////////////// ... CExtControlBar m_wndResizableBarTree; CExtPageNavigatorWnd m_wndPageNavigator; CTreeCtrl m_wndPNShortcuts; CTreeCtrl m_wndPNAllFolders; CTreeCtrl m_wndPNFavoriteFolders; ...
///////////////////////////// MainFrm.cpp ////////////////////////////////// ... _splash.SetStatusText(_T("Creating TreeBar ...")); m_wndResizableBarTree.SetInitDesiredSizeVertical( CSize( 200, 400 ) ); m_wndResizableBarTree.SetInitDesiredSizeHorizontal( CSize( 400, 200 ) ); if( !m_wndResizableBarTree.Create( _T("Folder Bar"), // _T("Optional control bar caption"), this, ID_VIEW_RESIZABLEBAR_TREE ) ) { TRACE0("Failed to create m_wndResizableBarTree\n"); return -1; // fail to create } m_wndPageNavigator.Create( &m_wndResizableBarTree, CRect(0, 0, 0, 0), m_wndResizableBarTree.GetDlgCtrlID() );
CExtPageNavigatorWnd::PAGE_ITEM_INFO * pPII = m_wndPageNavigator.ItemInsert( -1, _T("Folder List"), (HICON)::LoadImage( ::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_FOLDER_LIST), IMAGE_ICON, 24, 24, 0 ), (HICON)::LoadImage( ::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_FOLDER_LIST_SMALL), IMAGE_ICON, 16, 16, 0 ) );
m_wndPNAllFolders.Create( WS_CHILD|WS_VISIBLE|TVS_HASBUTTONS|TVS_LINESATROOT, CRect(0,0,0,0), &m_wndPageNavigator, UINT( IDC_STATIC ) );
HTREEITEM hItem = NULL; HTREEITEM hItemRoot = NULL;
m_wndPNAllFolders.Expand( hItem, TVE_EXPAND ); m_wndPNAllFolders.Expand( hItemRoot, TVE_EXPAND );
//get drawing area size CRect recta; GetClientRect(recta);
//Create TreeCtrl m_TreeCtrl_AllFolder.Create(WS_VISIBLE|WS_CHILD|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT, recta, &m_wndPNAllFolders, IDC_TREEDIR); m_TreeCtrl_AllFolder.iTreePath=CSIDL_DESKTOP ; m_TreeCtrl_AllFolder.Initialize();
pPII->PaneInsert( m_wndPNAllFolders.GetSafeHwnd(), -1, _T(""), 50, true ); ...
How could I do ?
|
|