637ea51f1562f4afe91573f893aabae1fb04688f
[reactos.git] / subsys / system / explorer / Seashell / SeaShellExt / UIListView.cpp
1 //*******************************************************************************
2 // COPYRIGHT NOTES
3 // ---------------
4 // You may use this source code, compile or redistribute it as part of your application 
5 // for free. You cannot redistribute it as a part of a software development 
6 // library without the agreement of the author. If the sources are 
7 // distributed along with the application, you should leave the original 
8 // copyright notes in the source code without any changes.
9 // This code can be used WITHOUT ANY WARRANTIES at your own risk.
10 // 
11 // For the latest updates to this code, check this site:
12 // http://www.masmex.com 
13 // after Sept 2000
14 // 
15 // Copyright(C) 2000 Philip Oldaker <email: philip@masmex.com>
16 //*******************************************************************************
17
18 // TabClientView.cpp : implementation file
19 //
20
21 #include "stdafx.h"
22 #include "UIListView.h"
23
24 #ifdef _DEBUG
25 #define new DEBUG_NEW
26 #undef THIS_FILE
27 static char THIS_FILE[] = __FILE__;
28 #endif
29
30 /////////////////////////////////////////////////////////////////////////////
31 // CUIListView
32
33 IMPLEMENT_DYNAMIC(CUIListView, CView)
34
35 CUIListView::CUIListView(UINT nID) : m_nID(nID), m_pListCtrl(NULL)
36 {
37         m_Style = WS_VISIBLE | WS_CHILD | LVS_REPORT | LVS_SHOWSELALWAYS;
38         m_bDragDrop = true;
39 }
40
41 CUIListView::~CUIListView()
42 {
43         delete m_pListCtrl;
44 }
45
46 CUIODListCtrl &CUIListView::GetListCtrl()
47 {
48         ASSERT(m_pListCtrl);
49         return *m_pListCtrl;
50 }
51
52 void CUIListView::CreateListCtrl()
53 {
54         m_pListCtrl = new CUIODListCtrl;
55         GetListCtrl().SetDragDrop(m_bDragDrop);
56 }
57
58 BEGIN_MESSAGE_MAP(CUIListView, CView)
59         //{{AFX_MSG_MAP(CUIListView)
60         ON_WM_CREATE()
61         ON_WM_SETFOCUS()
62         ON_WM_SIZE()
63         //}}AFX_MSG_MAP
64         ON_MESSAGE(WM_APP_UPDATE_ALL_VIEWS, OnAppUpdateAllViews)
65 END_MESSAGE_MAP()
66
67 /////////////////////////////////////////////////////////////////////////////
68 // CUIListView drawing
69
70 void CUIListView::OnDraw(CDC* pDC)
71 {
72         CDocument* pDoc = GetDocument();
73         // TODO: add draw code here
74 }
75
76 /////////////////////////////////////////////////////////////////////////////
77 // CUIListView diagnostics
78
79 #ifdef _DEBUG
80 void CUIListView::AssertValid() const
81 {
82         CView::AssertValid();
83 }
84
85 void CUIListView::Dump(CDumpContext& dc) const
86 {
87         CView::Dump(dc);
88 }
89 #endif //_DEBUG
90
91 /////////////////////////////////////////////////////////////////////////////
92 // CUIListView message handlers
93
94 int CUIListView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
95 {
96         if (CView::OnCreate(lpCreateStruct) == -1)
97                 return -1;
98
99         CreateListCtrl();
100
101         // TODO: Add your specialized creation code here
102 USES_CONVERSION;
103         GetListCtrl().SetSection(A2CT(GetRuntimeClass()->m_lpszClassName));
104         GetListCtrl().ChangeStyle(m_Style);
105         if (GetListCtrl().Create(m_Style,CRect(0,0,0,0),this,m_nID) == -1)
106                 return -1;
107
108         GetListCtrl().Init();
109
110         return 0;
111 }
112
113 void CUIListView::OnSetFocus(CWnd* pOldWnd) 
114 {
115         CView::OnSetFocus(pOldWnd);
116         
117         // TODO: Add your message handler code here
118         GetListCtrl().SetFocus();       
119 }
120
121 void CUIListView::OnSize(UINT nType, int cx, int cy) 
122 {
123         CView::OnSize(nType, cx, cy);
124
125         // TODO: Add your message handler code here
126         if (GetListCtrl().GetSafeHwnd())
127                 GetListCtrl().MoveWindow(0,0,cx,cy);    
128 }
129
130 LRESULT CUIListView::OnAppUpdateAllViews( WPARAM wParam, LPARAM lParam )
131 {
132         ASSERT(wParam);
133         GetDocument()->UpdateAllViews(NULL,wParam,(CObject*)lParam);
134         return 1L;
135 }
136
137 BOOL CUIListView::PreCreateWindow(CREATESTRUCT& cs) 
138 {
139         // TODO: Add your specialized code here and/or call the base class
140         cs.lpszClass = AfxRegisterWndClass(
141                                   CS_DBLCLKS,                       
142                                   NULL,                             
143                                   NULL,                             
144                                   NULL); 
145         ASSERT(cs.lpszClass);
146         
147         return CView::PreCreateWindow(cs);
148 }