9d0e714f900ab89c0bc546899802d99c48d5505d
6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
44 ////////////////////////////////////////////////////////////////////////////////
48 static WNDPROC g_orgListWndProc
;
51 ////////////////////////////////////////////////////////////////////////////////
52 // Local module support methods
57 #define MAX_LIST_COLUMNS (IDS_LIST_COLUMN_LAST - IDS_LIST_COLUMN_FIRST + 1)
58 static int default_column_widths
[MAX_LIST_COLUMNS
] = { 200, 175, 400 };
59 static int column_alignment
[MAX_LIST_COLUMNS
] = { LVCFMT_LEFT
, LVCFMT_LEFT
, LVCFMT_LEFT
};
61 static void CreateListColumns(HWND hWndListView
)
68 lvC
.mask
= LVCF_FMT
| LVCF_WIDTH
| LVCF_TEXT
| LVCF_SUBITEM
;
71 // Load the column labels from the resource file.
72 for (index
= 0; index
< MAX_LIST_COLUMNS
; index
++) {
74 lvC
.cx
= default_column_widths
[index
];
75 lvC
.fmt
= column_alignment
[index
];
76 LoadString(hInst
, IDS_LIST_COLUMN_FIRST
+ index
, szText
, sizeof(szText
));
77 if (ListView_InsertColumn(hWndListView
, index
, &lvC
) == -1) {
78 // TODO: handle failure condition...
85 // OnGetDispInfo - processes the LVN_GETDISPINFO
86 // notification message.
88 static void OnGetDispInfo(NMLVDISPINFO
* plvdi
)
90 static TCHAR buffer
[200];
91 // Entry* entry = (Entry*)plvdi->item.lParam;
93 plvdi
->item
.pszText
= NULL
;
95 switch (plvdi
->item
.iSubItem
) {
97 // plvdi->item.pszText = entry->data.cFileName;
108 _tcscpy(buffer
, _T(" "));
109 plvdi
->item
.pszText
= buffer
;
113 static BOOL
_CmdWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
115 switch (LOWORD(wParam
)) {
116 // case ID_FILE_OPEN:
123 ////////////////////////////////////////////////////////////////////////////////
125 static LRESULT CALLBACK
ListWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
127 // ChildWnd* child = (ChildWnd*)GetWindowLong(GetParent(hWnd), GWL_USERDATA);
128 // Pane* pane = (Pane*)GetWindowLong(hWnd, GWL_USERDATA);
134 //CreateListView(hWnd);
138 if (!_CmdWndProc(hWnd
, message
, wParam
, lParam
)) {
139 return CallWindowProc(g_orgListWndProc
, hWnd
, message
, wParam
, lParam
);
143 switch (((LPNMHDR
)lParam
)->code
) {
144 case LVN_GETDISPINFO
:
145 OnGetDispInfo((NMLVDISPINFO
*)lParam
);
149 NMITEMACTIVATE
* nmitem
= (LPNMITEMACTIVATE
)lParam
;
152 if (nmitem
->hdr
.hwndFrom
!= hWnd
) break;
153 // if (nmitem->hdr.idFrom != IDW_LISTVIEW) break;
154 // if (nmitem->hdr.code != ???) break;
156 switch (nmitem
->uKeyFlags
) {
157 case LVKF_ALT
: // The ALT key is pressed.
158 // properties dialog box ?
160 case LVKF_CONTROL
: // The CTRL key is pressed.
161 // run dialog box for providing parameters...
163 case LVKF_SHIFT
: // The SHIFT key is pressed.
167 info
.pt
.x
= nmitem
->ptAction
.x
;
168 info
.pt
.y
= nmitem
->ptAction
.y
;
169 if (ListView_HitTest(hWnd
, &info
) != -1) {
171 item
.mask
= LVIF_PARAM
;
172 item
.iItem
= info
.iItem
;
173 if (ListView_GetItem(hWnd
, &item
)) {
174 // Entry* entry = (Entry*)item.lParam;
175 // OpenTarget(hWnd, entry->data.cFileName);
182 return CallWindowProc(g_orgListWndProc
, hWnd
, message
, wParam
, lParam
);
186 if (wParam
== VK_TAB
) {
187 //TODO: SetFocus(Globals.hDriveBar)
188 //SetFocus(child->nFocusPanel? child->left.hWnd: child->right.hWnd);
192 return CallWindowProc(g_orgListWndProc
, hWnd
, message
, wParam
, lParam
);
199 HWND
CreateListView(HWND hwndParent
/*, Pane* pane*/, int id
, Root
* pRoot
/*Entry* pEntry*/)
201 RECT rcClient
; // dimensions of client area
202 HWND hwndLV
; // handle to list view control
203 // Entry* entry = pane->root;
204 // pane->treePane = 0;
206 // Get the dimensions of the parent window's client area, and create the list view control.
207 GetClientRect(hwndParent
, &rcClient
);
208 hwndLV
= CreateWindowEx(0, WC_LISTVIEW
, _T("List View"),
209 WS_VISIBLE
| WS_CHILD
| WS_BORDER
| LVS_REPORT
,
210 0, 0, rcClient
.right
, rcClient
.bottom
,
211 hwndParent
, (HMENU
)id
, hInst
, NULL
);
213 // Initialize the image list, and add items to the control.
215 if (!InitListViewImageLists(hwndLV) ||
216 !InitListViewItems(hwndLV, lpszPathName)) {
217 DestroyWindow(hwndLV);
221 ListView_SetExtendedListViewStyle(hwndLV
, LVS_EX_FULLROWSELECT
);
222 CreateListColumns(hwndLV
);
224 SetWindowLong(hwndLV
, GWL_USERDATA
, (LPARAM
)pRoot
);
225 g_orgListWndProc
= SubclassWindow(hwndLV
, ListWndProc
);
226 //SendMessage(hwndLV, WM_SETFONT, (WPARAM)Globals.hFont, FALSE);
228 // insert entries into listbox
230 // InsertListEntries(hwndLV, entry, -1);
236 void RefreshList(HWND hWnd
, Entry
* entry
)
239 ListView_DeleteAllItems(hWnd
);
242 TRACE("RefreshList(...) entry name: %s\n", entry->data.cFileName);
243 InsertListEntries(hWnd, entry, -1);