00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020
00025 #pragma once
00026
00027 #include <sstream>
00028 #include <ExtDockingWindow.h>
00029
00030 class CFoldersTree :
00031 public dockwins::CTitleDockingWindowImpl< CFoldersTree,CWindow,dockwins::COutlookLikeTitleDockingWindowTraits>
00032 {
00033 typedef CFoldersTree thisClass;
00034 typedef dockwins::CTitleDockingWindowImpl< CFoldersTree,CWindow,dockwins::COutlookLikeTitleDockingWindowTraits> baseClass;
00035 protected:
00036 void FillTree(CTreeViewCtrl& tree)
00037 {
00038 for( int i =0; i < 10; i++)
00039 {
00040 std::basic_stringstream<TCHAR> text;
00041 text<<_T("item ")<<i;
00042 HTREEITEM hItem=tree.InsertItem(text.str().c_str(),0,1,TVI_ROOT,TVI_LAST);
00043 for( int j = 0; j < 5; j++)
00044 {
00045 std::basic_stringstream<TCHAR> text;
00046 text<<_T("sub item ")<<j;
00047 tree.InsertItem(text.str().c_str(),0,1,hItem,TVI_LAST);
00048 }
00049 }
00050
00051 }
00052 public:
00053 void OnDocked(HDOCKBAR hBar,bool bHorizontal)
00054 {
00055 DWORD dwStyle = GetWindowLong(GWL_STYLE)&(~WS_SIZEBOX);
00056 SetWindowLong( GWL_STYLE, dwStyle);
00057
00058 baseClass::OnDocked(hBar,bHorizontal);
00059 }
00060 void OnUndocked(HDOCKBAR hBar)
00061 {
00062 DWORD dwStyle = GetWindowLong(GWL_STYLE) | WS_SIZEBOX;
00063 SetWindowLong( GWL_STYLE , dwStyle);
00064
00065 baseClass::OnUndocked(hBar);
00066 }
00067
00068 DECLARE_WND_CLASS(_T("CFoldersTree"))
00069 BEGIN_MSG_MAP(thisClass)
00070 MESSAGE_HANDLER(WM_CREATE, OnCreate)
00071 MESSAGE_HANDLER(WM_SIZE, OnSize)
00072 CHAIN_MSG_MAP(baseClass)
00073 END_MSG_MAP()
00074
00075 LRESULT OnCreate(UINT , WPARAM , LPARAM , BOOL& )
00076 {
00077 m_images.Create(16, 16, TRUE, 3, 0);
00078
00079 assert(m_images.m_hImageList);
00080 CBitmap bmp;
00081
00082 bmp.LoadBitmap(IDB_FOLDERS);
00083
00084 m_images.Add( bmp, RGB(255,255,255));
00085
00086 m_tree.Create(m_hWnd,NULL,NULL,
00087 TVS_SHOWSELALWAYS | TVS_HASBUTTONS |
00088 TVS_LINESATROOT | TVS_HASLINES |
00089 TVS_EDITLABELS|TVS_SHOWSELALWAYS|
00090 TVS_DISABLEDRAGDROP|
00091 WS_CHILD | WS_VISIBLE);
00092 m_tree.SetImageList(m_images, TVSIL_NORMAL);
00093 FillTree(m_tree);
00094 return 0;
00095 }
00096 LRESULT OnSize(UINT , WPARAM wParam, LPARAM , BOOL& bHandled)
00097 {
00098 if(wParam != SIZE_MINIMIZED )
00099 {
00100 RECT rc;
00101 GetClientRect(&rc);
00102 ::SetWindowPos(m_tree.m_hWnd, NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top ,SWP_NOZORDER | SWP_NOACTIVATE);
00103 }
00104 bHandled = FALSE;
00105 return 1;
00106 }
00107 protected:
00108 CTreeViewCtrl m_tree;
00109 CImageList m_images;
00110 };