* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef _MSC_VER
-#include "stdafx.h"
-#else
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-#endif
#include "main.h"
#include "about.h"
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef _MSC_VER
-#include "stdafx.h"
-#else
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-#endif
#include <windowsx.h>
#include <ctype.h>
////////////////////////////////////////////////////////////////////////////////
// Local module support methods
//
-
+/*
static BOOL pane_command(Pane* pane, UINT cmd)
{
switch(cmd) {
}
return TRUE;
}
-
+ */
static void draw_splitbar(HWND hWnd, int x)
{
RECT rt;
RECT rt = {0, 0, cx, cy};
cx = pChildWnd->nSplitPos + SPLIT_WIDTH/2;
- DeferWindowPos(hdwp, pChildWnd->left.hWnd, 0, rt.left, rt.top, pChildWnd->nSplitPos-SPLIT_WIDTH/2-rt.left, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
- DeferWindowPos(hdwp, pChildWnd->right.hWnd, 0, rt.left+cx+1, rt.top, rt.right-cx, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
+ DeferWindowPos(hdwp, pChildWnd->hTreeWnd, 0, rt.left, rt.top, pChildWnd->nSplitPos-SPLIT_WIDTH/2-rt.left, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
+ DeferWindowPos(hdwp, pChildWnd->hListWnd, 0, rt.left+cx+1, rt.top, rt.right-cx, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
EndDeferWindowPos(hdwp);
}
return TRUE;
}
+BOOL OnNotify(HWND hWnd, WPARAM wParam, LPARAM lParam)
+{
+ ChildWnd* pChildWnd = (ChildWnd*)GetWindowLong(hWnd, GWL_USERDATA);
+ {
+ if ((int)wParam == TREE_WINDOW) {
+
+ switch (((LPNMHDR)lParam)->code) {
+ case TVN_ITEMEXPANDING:
+// return !OnTreeExpanding(pChildWnd->hTreeWnd, (NMTREEVIEW*)lParam);
+ OnTreeExpanding(pChildWnd->hTreeWnd, (NMTREEVIEW*)lParam);
+ return FALSE;
+
+ case TVN_SELCHANGED:
+ {
+ Entry* entry = (Entry*)((NMTREEVIEW*)lParam)->itemNew.lParam;
+ if (entry != NULL) {
+ //RefreshList(pChildWnd->hListWnd, entry);
+ //void set_curdir(ChildWnd* child, Entry* entry)
+// set_curdir(pChildWnd, entry);
+
+// UpdateStatus(hWnd, pChildWnd->left.cur->down);
+
+ }
+ case TVN_GETDISPINFO:
+ OnGetDispInfo((NMTVDISPINFO*)lParam);
+ break;
+/*
+ HKEY hKey;
+ TCHAR keyPath[1000];
+ int keyPathLen = 0;
+ keyPath[0] = _T('\0');
+ hKey = FindRegRoot(pChildWnd->hTreeWnd, ((NMTREEVIEW*)lParam)->itemNew.hItem, keyPath, &keyPathLen, sizeof(keyPath)/sizeof(TCHAR));
+ RefreshListView(pChildWnd->hListWnd, hKey, keyPath);
+
+ keyPathLen = 0;
+ keyPath[0] = _T('\0');
+ MakeFullRegPath(pChildWnd->hTreeWnd, ((NMTREEVIEW*)lParam)->itemNew.hItem, keyPath, &keyPathLen, sizeof(keyPath)/sizeof(TCHAR));
+ SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)keyPath);
+ */
+ }
+ break;
+ default:
+ break;
+ }
+ } else
+ if ((int)wParam == LIST_WINDOW) {
+ if (!SendMessage(pChildWnd->hListWnd, WM_NOTIFY, wParam, lParam)) {
+ return FALSE;
+ }
+ }
+ }
+
+ return TRUE;
+}
+
////////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: ChildWndProc(HWND, unsigned, WORD, LONG)
// WM_DESTROY - post a quit message and return
//
//
+
LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- static int last_split;
-
ChildWnd* pChildWnd = (ChildWnd*)GetWindowLong(hWnd, GWL_USERDATA);
- ASSERT(pChildWnd);
+ ASSERT(pChildWnd || (message == WM_CREATE));
switch(message) {
case WM_CREATE:
- CreateTreeWnd(pChildWnd->hWnd, &pChildWnd->left, IDW_TREE_LEFT);
- CreateListWnd(pChildWnd->hWnd, &pChildWnd->right, IDW_TREE_RIGHT, pChildWnd->szPath);
- //create_tree_window(pChildWnd->hWnd, &pChildWnd->left, IDW_TREE_LEFT, IDW_HEADER_LEFT, pChildWnd->szPath);
- //create_list_window(pChildWnd->hWnd, &pChildWnd->right, IDW_TREE_RIGHT, IDW_HEADER_RIGHT);
- return 0;
+ pChildWnd = (ChildWnd*)((MDICREATESTRUCT*)((CREATESTRUCT*)lParam)->lpCreateParams)->lParam;
+ ASSERT(pChildWnd);
+ SetWindowLong(hWnd, GWL_USERDATA, (LONG)pChildWnd);
+
+ pChildWnd->nSplitPos = 250;
+ pChildWnd->hTreeWnd = CreateTreeView(hWnd, pChildWnd, TREE_WINDOW);
+ pChildWnd->hListWnd = CreateListView(hWnd, pChildWnd/*, pChildWnd->szPath*/, LIST_WINDOW);
+ //return -1; // terminate window creation on error
break;
case WM_PAINT:
OnPaint(hWnd, pChildWnd);
int x = LOWORD(lParam);
GetClientRect(hWnd, &rt);
if (x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) {
- last_split = pChildWnd->nSplitPos;
- draw_splitbar(hWnd, last_split);
+ pChildWnd->last_split = pChildWnd->nSplitPos;
+ draw_splitbar(hWnd, pChildWnd->last_split);
SetCapture(hWnd);
}
break;}
if (GetCapture() == hWnd) {
RECT rt;
int x = LOWORD(lParam);
- draw_splitbar(hWnd, last_split);
- last_split = -1;
+ draw_splitbar(hWnd, pChildWnd->last_split);
+ pChildWnd->last_split = -1;
GetClientRect(hWnd, &rt);
pChildWnd->nSplitPos = x;
ResizeWnd(pChildWnd, rt.right, rt.bottom);
break;
case WM_CAPTURECHANGED:
- if (GetCapture()==hWnd && last_split>=0)
- draw_splitbar(hWnd, last_split);
+ if (GetCapture()==hWnd && pChildWnd->last_split>=0)
+ draw_splitbar(hWnd, pChildWnd->last_split);
break;
case WM_KEYDOWN:
if (wParam == VK_ESCAPE)
if (GetCapture() == hWnd) {
RECT rt;
- draw_splitbar(hWnd, last_split);
+ draw_splitbar(hWnd, pChildWnd->last_split);
GetClientRect(hWnd, &rt);
ResizeWnd(pChildWnd, rt.right, rt.bottom);
- last_split = -1;
+ pChildWnd->last_split = -1;
ReleaseCapture();
SetCursor(LoadCursor(0, IDC_ARROW));
}
int x = LOWORD(lParam);
HDC hdc = GetDC(hWnd);
GetClientRect(hWnd, &rt);
- rt.left = last_split-SPLIT_WIDTH/2;
- rt.right = last_split+SPLIT_WIDTH/2+1;
+ rt.left = pChildWnd->last_split-SPLIT_WIDTH/2;
+ rt.right = pChildWnd->last_split+SPLIT_WIDTH/2+1;
InvertRect(hdc, &rt);
- last_split = x;
+ pChildWnd->last_split = x;
rt.left = x-SPLIT_WIDTH/2;
rt.right = x+SPLIT_WIDTH/2+1;
InvertRect(hdc, &rt);
case WM_SETFOCUS:
SetCurrentDirectory(pChildWnd->szPath);
- SetFocus(pChildWnd->nFocusPanel? pChildWnd->right.hWnd: pChildWnd->left.hWnd);
+ SetFocus(pChildWnd->nFocusPanel? pChildWnd->hListWnd: pChildWnd->hTreeWnd);
break;
case WM_DISPATCH_COMMAND:
if (_CmdWndProc(hWnd, message, wParam, lParam)) break;
if (1) {
- return SendMessage(pChildWnd->right.hWnd, message, wParam, lParam);
+ return SendMessage(pChildWnd->hListWnd, message, wParam, lParam);
} else {
- return SendMessage(pChildWnd->left.hWnd, message, wParam, lParam);
+ return SendMessage(pChildWnd->hTreeWnd, message, wParam, lParam);
}
break;
return DefMDIChildProc(hWnd, message, wParam, lParam);
// if (LOWORD(wParam) > ID_CMD_FIRST && LOWORD(wParam) < ID_CMD_LAST) {
-// if (!SendMessage(pChildWnd->right.hWnd, message, wParam, lParam)) {
+// if (!SendMessage(pChildWnd->hListWnd, message, wParam, lParam)) {
// return DefMDIChildProc(hWnd, message, wParam, lParam);
// }
// } else {
// }
break;
case WM_NOTIFY:
+
+ if (!OnNotify(hWnd, wParam, lParam)) {
+ return DefMDIChildProc(hWnd, message, wParam, lParam);
+ }
+/*
{
int idCtrl = (int)wParam;
//NMHDR* pnmh = (NMHDR*)lParam;
//return pane_notify(pnmh->idFrom==IDW_HEADER_LEFT? &pChildWnd->left: &pChildWnd->right, pnmh);
- if ((int)wParam == IDW_TREE_LEFT) {
+ if ((int)wParam == TREE_WINDOW) {
if ((((LPNMHDR)lParam)->code) == TVN_SELCHANGED) {
Entry* entry = (Entry*)((NMTREEVIEW*)lParam)->itemNew.lParam;
if (entry != NULL) {
- //RefreshList(pChildWnd->right.hWnd, entry);
+ //RefreshList(pChildWnd->hListWnd, entry);
//void set_curdir(ChildWnd* child, Entry* entry)
set_curdir(pChildWnd, entry);
}
}
- if (!SendMessage(pChildWnd->left.hWnd, message, wParam, lParam)) {
+ if (!SendMessage(pChildWnd->hTreeWnd, message, wParam, lParam)) {
return DefMDIChildProc(hWnd, message, wParam, lParam);
}
} else
- if ((int)wParam == IDW_TREE_RIGHT) {
- if (!SendMessage(pChildWnd->right.hWnd, message, wParam, lParam)) {
+ if ((int)wParam == LIST_WINDOW) {
+ if (!SendMessage(pChildWnd->hListWnd, message, wParam, lParam)) {
return DefMDIChildProc(hWnd, message, wParam, lParam);
}
}
}
+*/
break;
case WM_SIZE:
extern "C" {
#endif
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
LRESULT CALLBACK ChildWndProc(HWND, UINT, WPARAM, LPARAM);
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef _MSC_VER
-#include "stdafx.h"
-#else
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-#endif
#include "main.h"
#include "debug.h"
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef _MSC_VER
-#include "stdafx.h"
-#else
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-#endif
#include <shellapi.h>
//#include <winspool.h>
extern "C" {
#endif
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
#include "resource.h"
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef _MSC_VER
-#include "stdafx.h"
-#else
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-#endif
#include "main.h"
#include "settings.h"
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef _MSC_VER
-#include "stdafx.h"
-#else
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-#endif
#include <windowsx.h>
}
// insert listbox entries after index idx
-void insert_entries(Pane* pane, Entry* parent, int idx)
+void insert_entries(HWND hWnd, Entry* parent, int idx)
{
-/*
Entry* entry = parent;
if (!entry)
return;
- ShowWindow(pane->hWnd, SW_HIDE);
+ ShowWindow(hWnd, SW_HIDE);
for(; entry; entry=entry->next) {
#ifndef _LEFT_FILES
- if (pane->treePane && !(entry->data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
+ if (!(entry->data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
continue;
#endif
// don't display entries "." and ".." in the left pane
- if (pane->treePane && (entry->data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
+ if ((entry->data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
&& entry->data.cFileName[0]==_T('.'))
if (
#ifndef _NO_EXTENSIONS
continue;
if (idx != -1)
idx++;
- ListBox_InsertItemData(pane->hWnd, idx, entry);
- if (pane->treePane && entry->expanded)
- insert_entries(pane, entry->down, idx);
+ ListBox_InsertItemData(hWnd, idx, entry);
+ if (entry->expanded)
+ insert_entries(hWnd, entry->down, idx);
}
- ShowWindow(pane->hWnd, SW_SHOW);
- */
+ ShowWindow(hWnd, SW_SHOW);
}
{
TCHAR path[MAX_PATH];
/*
- int idx = ListBox_GetCurSel(child->left.hWnd);
+ int idx = ListBox_GetCurSel(child->hTreeWnd);
HCURSOR crsrOld = SetCursor(LoadCursor(0, IDC_WAIT));
// delete sub entries in left pane
for(;;) {
- LRESULT res = ListBox_GetItemData(child->left.hWnd, idx+1);
+ LRESULT res = ListBox_GetItemData(child->hTreeWnd, idx+1);
Entry* sub = (Entry*) res;
if (res==LB_ERR || !sub || sub->level<=entry->level)
break;
- ListBox_DeleteString(child->left.hWnd, idx+1);
+ ListBox_DeleteString(child->hTreeWnd, idx+1);
}
// empty right pane
- ListBox_ResetContent(child->right.hWnd);
+ ListBox_ResetContent(child->hListWnd);
*/
// release memory
free_entries(entry);
if (!(p->data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
return FALSE;
/*
- idx = ListBox_FindItemData(child->left.hWnd, 0, dir);
+ idx = ListBox_FindItemData(child->hTreeWnd, 0, dir);
*/
dir->expanded = TRUE;
// insert entries in left pane
- insert_entries(&child->left, p, idx);
+ insert_entries(child->hTreeWnd, p, idx);
/*
if (!child->header_wdths_ok) {
if (calc_widths(&child->left, FALSE)) {
if (entry->data.cFileName[0]=='.' && entry->data.cFileName[1]=='\0')
return;
#endif
-
+/*
if (entry->data.cFileName[0]=='.' && entry->data.cFileName[1]=='.' && entry->data.cFileName[2]=='\0') {
entry = child->left.cur->up;
collapse_entry(&child->left, entry);
expand_entry(child, child->left.cur);
if (!pane->treePane) focus_entry: {
- int idx = ListBox_FindItemData(child->left.hWnd, ListBox_GetCurSel(child->left.hWnd), entry);
- ListBox_SetCurSel(child->left.hWnd, idx);
+ int idx = ListBox_FindItemData(child->hTreeWnd, ListBox_GetCurSel(child->hTreeWnd), entry);
+ ListBox_SetCurSel(child->hTreeWnd, idx);
set_curdir(child, entry);
}
}
-
+ */
if (!scanned_old) {
calc_widths(pane, FALSE);
-
#ifndef _NO_EXTENSIONS
set_header(pane);
#endif
extern "C" {
#endif
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-
typedef struct _Entry {
struct _Entry* next;
typedef struct {
HWND hWnd;
-#ifndef _NO_EXTENSIONS
- HWND hwndHeader;
-#endif
#ifndef _NO_EXTENSIONS
#define COLUMNS 10
int widths[COLUMNS];
int positions[COLUMNS+1];
- BOOL treePane;
- int visible_cols;
Entry* root;
Entry* cur;
} Pane;
typedef struct {
HWND hWnd;
- Pane left;
- Pane right;
+ HWND hTreeWnd;
+ HWND hListWnd;
int nFocusPanel; // 0: left 1: right
- WINDOWPLACEMENT pos;
int nSplitPos;
- BOOL header_wdths_ok;
-
+ WINDOWPLACEMENT pos;
TCHAR szPath[MAX_PATH];
- Root root;
+// Root root;
+ Root* pRoot;
+ Pane left;
+ Pane right;
SORT_ORDER sortOrder;
+ int last_split;
+
} ChildWnd;
-void insert_entries(Pane* pane, Entry* parent, int idx);
+void insert_entries(HWND hWnd, Entry* parent, int idx);
void scan_entry(ChildWnd* child, Entry* entry);
void activate_entry(ChildWnd* child, Pane* pane);
void collapse_entry(Pane* pane, Entry* dir);
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef _MSC_VER
-#include "stdafx.h"
-#else
//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-#endif
//#include <shellapi.h>
#include <windowsx.h>
static ChildWnd* alloc_child_window(LPCTSTR path)
{
TCHAR drv[_MAX_DRIVE+1], dir[_MAX_DIR], name[_MAX_FNAME], ext[_MAX_EXT];
- ChildWnd* pChildWnd = (ChildWnd*)malloc(sizeof(ChildWnd));
- Root* root = &pChildWnd->root;
Entry* entry;
-
- memset(pChildWnd, 0, sizeof(ChildWnd));
- pChildWnd->left.treePane = TRUE;
- pChildWnd->left.visible_cols = 0;
- pChildWnd->right.treePane = FALSE;
-#ifndef _NO_EXTENSIONS
- pChildWnd->right.visible_cols = COL_SIZE|COL_DATE|COL_TIME|COL_ATTRIBUTES|COL_INDEX|COL_LINKS;
-#else
- pChildWnd->right.visible_cols = COL_SIZE|COL_DATE|COL_TIME|COL_ATTRIBUTES;
-#endif
+ Root* root;
+// ChildWnd* pChildWnd = (ChildWnd*)malloc(sizeof(ChildWnd));
+// memset(pChildWnd, 0, sizeof(ChildWnd));
+ ChildWnd* pChildWnd = (ChildWnd*)malloc(sizeof(ChildWnd)+sizeof(Root));
+ memset(pChildWnd, 0, sizeof(ChildWnd)+sizeof(Root));
+ pChildWnd->pRoot = (Root*)((BYTE*)pChildWnd + sizeof(ChildWnd));
+ pChildWnd->pRoot = (Root*)&pChildWnd[1];
+ root = pChildWnd->pRoot;
+
+// root = &pChildWnd->root;
+// pChildWnd->left.treePane = TRUE;
+// pChildWnd->left.visible_cols = 0;
+// pChildWnd->right.treePane = FALSE;
+//#ifndef _NO_EXTENSIONS
+// pChildWnd->right.visible_cols = COL_SIZE|COL_DATE|COL_TIME|COL_ATTRIBUTES|COL_INDEX|COL_LINKS;
+//#else
+// pChildWnd->right.visible_cols = COL_SIZE|COL_DATE|COL_TIME|COL_ATTRIBUTES;
+//#endif
pChildWnd->pos.length = sizeof(WINDOWPLACEMENT);
pChildWnd->pos.flags = 0;
pChildWnd->pos.showCmd = SW_SHOWNORMAL;
pChildWnd->nFocusPanel = 0;
pChildWnd->nSplitPos = 300;
pChildWnd->sortOrder = SORT_NAME;
- pChildWnd->header_wdths_ok = FALSE;
+// pChildWnd->header_wdths_ok = FALSE;
lstrcpy(pChildWnd->szPath, path);
_tsplitpath(path, drv, dir, name, ext);
#if !defined(_NO_EXTENSIONS) && defined(__linux__)
// CW_USEDEFAULT, CW_USEDEFAULT,
// CW_USEDEFAULT, CW_USEDEFAULT,
20, 20, 200, 200,
- WS_MAXIMIZE, 0
+ WS_MAXIMIZE, (LPARAM)pChildWnd
// 0/*style*/, 0/*lParam*/
};
hcbthook = SetWindowsHookEx(WH_CBT, CBTProc, 0, GetCurrentThreadId());
child_wnd = GetNextWindow(child_wnd, GW_HWNDNEXT)) {
ChildWnd* pChildWnd = (ChildWnd*) GetWindowLong(child_wnd, GWL_USERDATA);
if (pChildWnd) {
- _tsplitpath(pChildWnd->root.path, drv2, 0, 0, 0);
+ //_tsplitpath(pChildWnd->root.path, drv2, 0, 0, 0);
+ _tsplitpath(pChildWnd->pRoot->path, drv2, 0, 0, 0);
if (!lstrcmpi(drv2, drv1)) {
SendMessage(Globals.hMDIClient, WM_MDIACTIVATE, (WPARAM)child_wnd, 0);
if (IsMinimized(child_wnd))
break;
case ID_HELP_ABOUT:
#ifdef WINSHELLAPI
- ShellAbout(hWnd, szTitle, "", LoadIcon(Globals.hInstance, (LPCTSTR)IDI_WINFILE));
+ ShellAbout(hWnd, szTitle, _T(""), LoadIcon(Globals.hInstance, (LPCTSTR)IDI_WINFILE));
#else
ShowAboutBox(hWnd);
#endif
extern "C" {
#endif
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
LRESULT CALLBACK FrameWndProc(HWND, UINT, WPARAM, LPARAM);
HWND CreateChildWindow(int drv_id);
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef _MSC_VER
-#include "stdafx.h"
-#else
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-#endif
#include <windowsx.h>
#include "main.h"
case WM_KEYDOWN:
if (wParam == VK_TAB) {
//TODO: SetFocus(Globals.hDriveBar)
- SetFocus(child->nFocusPanel ? child->left.hWnd: child->right.hWnd);
+ SetFocus(child->nFocusPanel ? child->hTreeWnd: child->hListWnd);
}
break;
}
RECT rcClient; // dimensions of client area
Entry* entry = pane->root;
- pane->treePane = 0;
+// pane->treePane = 0;
GetClientRect(parent, &rcClient);
pane->hWnd = CreateWindowEx(0, WC_LISTVIEW, _T("List View"),
InsertListEntries(pane->hWnd, entry, -1);
}
}
+
+HWND CreateListView(HWND hwndParent, ChildWnd* pChildWnd, int id)
+{
+ RECT rcClient;
+ HWND hwndLV;
+
+ // Get the dimensions of the parent window's client area, and create the list view control.
+ GetClientRect(hwndParent, &rcClient);
+ hwndLV = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, _T("List View"),
+ WS_VISIBLE | WS_CHILD | LVS_REPORT,
+ 0, 0, rcClient.right, rcClient.bottom,
+ hwndParent, (HMENU)id, hInst, NULL);
+ ListView_SetExtendedListViewStyle(hwndLV, LVS_EX_FULLROWSELECT);
+
+ // Initialize the image list, and add items to the control.
+/*
+ if (!InitListViewImageLists(hwndLV) ||
+ !InitListViewItems(hwndLV, szName)) {
+ DestroyWindow(hwndLV);
+ return FALSE;
+ }
+ */
+ CreateListColumns(hwndLV);
+ g_orgListWndProc = SubclassWindow(hwndLV, ListWndProc);
+ return hwndLV;
+}
+
extern "C" {
#endif
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
void CreateListWnd(HWND parent, Pane* pane, int id, LPTSTR lpszPathName);
void RefreshList(HWND hWnd, Entry* entry);
+HWND CreateListView(HWND hwndParent, ChildWnd* pChildWnd, int id);
+
#ifdef __cplusplus
};
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef _MSC_VER
-#include "stdafx.h"
-#else
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-#endif
#include "main.h"
#include "settings.h"
extern "C" {
#endif
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
#include "resource.h"
#include "entries.h"
#define IDW_FIRST_CHILD 0xC000 //0x200
-#define IDW_TREE_LEFT 3
-#define IDW_TREE_RIGHT 6
-#define IDW_HEADER_LEFT 2
-#define IDW_HEADER_RIGHT 5
+//#define IDW_TREE_LEFT 3
+//#define IDW_TREE_RIGHT 6
+//#define IDW_HEADER_LEFT 2
+//#define IDW_HEADER_RIGHT 5
#define IDW_STATUS_WINDOW 7
+#define TREE_WINDOW 8
+#define LIST_WINDOW 9
+
////////////////////////////////////////////////////////////////////////////////
void _wsplitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHAR* ext);
void _splitpath(const CHAR* path, CHAR* drv, CHAR* dir, CHAR* name, CHAR* ext);
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef _MSC_VER
-#include "stdafx.h"
-#else
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-#endif
#include "main.h"
#include "network.h"
static void DisplayStruct(HDC hdc, LPNETRESOURCE lpnrLocal)
{
LPTSTR str = NULL;
- TRACE(_T("DisplayStruct(%p)"), lpnrLocal);
+ //TRACE(_T("DisplayStruct(%p)\n"), lpnrLocal);
switch (lpnrLocal->dwScope) {
case RESOURCE_CONNECTED: str = _T("Enumerate currently connected resources. The dwUsage member cannot be specified."); break;
case RESOURCE_REMEMBERED: str = _T("Enumerate remembered (persistent) connections. The dwUsage member cannot be specified."); break;
default: str = _T("Unknown Scope."); break;
}
- TRACE(_T(" %s\n"), str);
+ //TRACE(_T(" %s\n"), str);
switch (lpnrLocal->dwType) {
case RESOURCETYPE_ANY: str = _T("All resources."); break;
case RESOURCETYPE_PRINT: str = _T("Print resources."); break;
default: str = _T("Unknown Type."); break;
}
- TRACE(_T(" %s\n"), str);
+ //TRACE(_T(" %s\n"), str);
switch (lpnrLocal->dwDisplayType) {
case RESOURCEDISPLAYTYPE_DOMAIN: str = _T("The object should be displayed as a domain."); break;
case RESOURCEDISPLAYTYPE_GENERIC: str = _T("The method used to display the object does not matter."); break;
default: str = _T("Unknown DisplayType."); break;
}
- TRACE(_T(" %s\n"), str);
+ //TRACE(_T(" %s\n"), str);
// switch (lpnrLocal->dwUsage ) {
// case RESOURCEUSAGE_CONNECTABLE: str = _T("The resource is a connectable resource; the name pointed to by the lpRemoteName member can be passed to the WNetAddConnection function to make a network connection."); break;
// case RESOURCEUSAGE_CONTAINER: str = _T("The resource is a container resource; the name pointed to by the lpRemoteName member can be passed to the WNetOpenEnum function to enumerate the resources in the container."); break;
// default: str = _T("Unknown Usage."); break;
// }
- TRACE(_T("\tLocalName: %s\tRemoteName: %s"), lpnrLocal->lpLocalName, lpnrLocal->lpRemoteName);
- TRACE(_T("\tComment: %s\tProvider: %s\n"), lpnrLocal->lpComment, lpnrLocal->lpProvider);
+ //TRACE(_T("\tLocalName: %s\tRemoteName: %s"), lpnrLocal->lpLocalName, lpnrLocal->lpRemoteName);
+ //TRACE(_T("\tComment: %s\tProvider: %s\n"), lpnrLocal->lpComment, lpnrLocal->lpProvider);
}
////////////////////////////////////
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef _MSC_VER
-#include "stdafx.h"
-#else
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-#endif
#include <shellapi.h>
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef _MSC_VER
-#include "stdafx.h"
-#else
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-#endif
#include "main.h"
#include "settings.h"
extern "C" {
#endif
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
#include "resource.h"
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef _MSC_VER
-#include "stdafx.h"
-#else
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-#endif
#include "main.h"
#include "shell.h"
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef _MSC_VER
-#include "stdafx.h"
-#else
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-#endif
#include <windowsx.h>
#include <shellapi.h>
extern "C" {
#endif
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-
#include "entries.h"
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef _MSC_VER
-#include "stdafx.h"
-#else
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-#endif
#include "main.h"
#include <stdio.h>
#include <stdarg.h>
#define WIN32_LEAN_AND_MEAN
-#include "windows.h"
+#include <windows.h>
+#include <tchar.h>
#include "trace.h"
#ifdef _DEBUG
-#ifdef WIN32
-//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
-//#include <windows.h>
-//#include <assert.h>
-//WINBASEAPI VOID WINAPI DebugBreak(VOID);
-//WINBASEAPI VOID WINAPI OutputDebugStringA(LPCSTR lpOutputString);
-//WINBASEAPI VOID WINAPI OutputDebugStringW(LPCWSTR lpOutputString);
-//void __stdcall DebugBreak(void);
-//void __stdcall OutputDebugStringA(char* lpOutputString);
-//void __stdcall OutputDebugStringW(wchar_t* lpOutputString);
-#ifdef UNICODE
-#define OutputDebugString OutputDebugStringW
-#else
-#define OutputDebugString OutputDebugStringA
-#endif // !UNICODE
-
-#else
-#include "hardware.h"
-#endif // WIN32
-
-
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
TCHAR szBuffer[512];
va_start(args, lpszFormat);
-// nBuf = vsprintf(szBuffer, lpszFormat, args);
-// nBuf = _vsntprintf(szBuffer, _countof(szBuffer), lpszFormat, args);
-#ifdef _UNICODE
- nBuf = _vsnwprintf(szBuffer, sizeof(szBuffer), lpszFormat, args);
-#else
- nBuf = _vsnprintf(szBuffer, sizeof(szBuffer), lpszFormat, args);
-#endif
+ nBuf = _vsntprintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), lpszFormat, args);
OutputDebugString(szBuffer);
// was there an error? was the expanded string too long?
-// ASSERT(nBuf >= 0);
+ //ASSERT(nBuf >= 0);
va_end(args);
}
-void Assert(void* assert, TCHAR* file, int line, void* msg)
+void Assert(void* assert, const char* file, int line, void* msg)
{
if (msg == NULL) {
printf("ASSERT -- %s occured on line %u of file %s.\n",
}
}
-
#else
-//inline void Trace(TCHAR* lpszFormat, ...) { };
-//inline void Assert(void* assert, TCHAR* file, int line, void* msg) { };
void Trace(TCHAR* lpszFormat, ...) { };
-void Assert(void* assert, TCHAR* file, int line, void* msg) { };
+void Assert(void* assert, const char* file, int line, void* msg) { };
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+// Diagnostic Trace
//
#ifndef __TRACE_H__
#define __TRACE_H__
#ifdef _DEBUG
-//=============================================================================
-// BreakPoint() macro.
-//=============================================================================
-
#ifdef _X86_
#define BreakPoint() _asm { int 3h }
#else
#define BreakPoint() _DebugBreak()
#endif
-//=============================================================================
-// MACRO: ASSERT()
-//=============================================================================
-
#ifndef ASSERT
#define ASSERT(exp) \
{ \
- if ( !(exp) ) \
- { \
- Assert(#exp, __FILE__, __LINE__, NULL); \
+ if (!(exp)) { \
+ Assert(#exp, __FILE__, __LINE__, NULL); \
BreakPoint(); \
} \
} \
#define ASSERTMSG(exp, msg) \
{ \
- if ( !(exp) ) \
- { \
- Assert(#exp, __FILE__, __LINE__, msg); \
+ if (!(exp)) { \
+ Assert(#exp, __FILE__, __LINE__, msg); \
BreakPoint(); \
} \
}
// MACRO: TRACE()
//=============================================================================
-void Assert(void* assert, TCHAR* file, int line, void* msg);
-void Trace(TCHAR* lpszFormat, ...);
-void Trace1(int code, TCHAR* lpszFormat, ...);
-
#define TRACE Trace
-#define TRACE0 Trace
+
#else // _DEBUG
+//=============================================================================
+// Define away MACRO's ASSERT() and TRACE() in non debug builds
+//=============================================================================
+
#ifndef ASSERT
#define ASSERT(exp)
#define ASSERTMSG(exp, msg)
#endif
-//#define TRACE0 TRACE
-//#define TRACE1 TRACE
+#define TRACE 0 ? (void)0 : Trace
-void Assert(void* assert, TCHAR* file, int line, void* msg);
-void Trace(TCHAR* lpszFormat, ...);
+#endif // !_DEBUG
-#define TRACE 0 ? (void)0 : Trace
+void Assert(void* assert, const char* file, int line, void* msg);
+void Trace(TCHAR* lpszFormat, ...);
-#endif // !_DEBUG
#endif // __TRACE_H__
/////////////////////////////////////////////////////////////////////////////
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef _MSC_VER
-#include "stdafx.h"
-#else
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-#endif
#include <windowsx.h>
#include <shellapi.h>
int Image_Closed;
int Image_Root;
+static int s_init = 0;
+
#define CX_BITMAP 16
#define CY_BITMAP 16
#define NUM_BITMAPS 3
-#if 0
-/*
-// AddItemToTree - adds items to a tree view control.
-// Returns the handle to the newly added item.
-// hwndTV - handle to the tree view control.
-// lpszItem - text of the item to add.
-// nLevel - level at which to add the item.
-
-HTREEITEM AddItemToTree(HWND hwndTV, LPTSTR lpszItem, int nLevel)
-{
- TVITEM tvi;
- TVINSERTSTRUCT tvins;
- static HTREEITEM hPrev = (HTREEITEM)TVI_FIRST;
- static HTREEITEM hPrevRootItem = NULL;
- static HTREEITEM hPrevLev2Item = NULL;
- HTREEITEM hti;
-
- tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM;
- // Set the text of the item.
- tvi.pszText = lpszItem;
- tvi.cchTextMax = lstrlen(lpszItem);
- // Assume the item is not a parent item, so give it an image.
- tvi.iImage = Image_Root;
- tvi.iSelectedImage = Image_Root;
- tvi.cChildren = 1;
-
- // Save the heading level in the item's application-defined data area.
- tvi.lParam = (LPARAM)nLevel;
-
- tvins.item = tvi;
- tvins.hInsertAfter = hPrev;
-
- // Set the parent item based on the specified level.
- if (nLevel == 1)
- tvins.hParent = TVI_ROOT;
- else if (nLevel == 2)
- tvins.hParent = hPrevRootItem;
- else
- tvins.hParent = hPrevLev2Item;
-
- // Add the item to the tree view control.
- hPrev = (HTREEITEM)SendMessage(hwndTV, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT)&tvins);
-
- // Save the handle to the item.
- if (nLevel == 1)
- hPrevRootItem = hPrev;
- else if (nLevel == 2)
- hPrevLev2Item = hPrev;
-
- // The new item is a child item. Give the parent item a
- // closed folder bitmap to indicate it now has child items.
- if (nLevel > 1) {
- hti = TreeView_GetParent(hwndTV, hPrev);
- tvi.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- tvi.hItem = hti;
- tvi.iImage = Image_Closed;
- tvi.iSelectedImage = Image_Closed;
- TreeView_SetItem(hwndTV, &tvi);
- }
- return hPrev;
-}
- */
-#endif
-
+Root* FindPathRoot(HWND hwndTV, HTREEITEM hItem, LPTSTR szPath, int* pPathLen, int max)
+{
+ Root* pRoot = NULL;
+ TVITEM item;
+ item.mask = TVIF_PARAM;
+ item.hItem = TreeView_GetParent(hwndTV, hItem);
+
+ if (TreeView_GetItem(hwndTV, &item)) {
+ if (item.lParam == 0) {
+ // recurse
+ pRoot = FindPathRoot(hwndTV, item.hItem, szPath, pPathLen, max);
+ szPath[*pPathLen] = _T('\\');
+ ++(*pPathLen);
+ item.mask = TVIF_TEXT;
+ item.hItem = hItem;
+ item.pszText = &szPath[*pPathLen];
+ item.cchTextMax = max - *pPathLen;
+ if (TreeView_GetItem(hwndTV, &item)) {
+ *pPathLen += _tcslen(item.pszText);
+ }
+ } else {
+ // found root key with valid key value
+ pRoot = (Root*)item.lParam;
+ item.mask = TVIF_TEXT;
+ item.hItem = hItem;
+ item.pszText = szPath;
+ item.cchTextMax = max;
+ if (TreeView_GetItem(hwndTV, &item)) {
+ *pPathLen += _tcslen(item.pszText);
+ }
+ }
+ }
+ return pRoot;
+}
static void init_output(HWND hWnd)
{
ReleaseDC(hWnd, hdc);
}
+#if 0
HTREEITEM AddEntryToTree(HWND hwndTV, Entry* entry)
{
static HTREEITEM hPrevLev2Item = NULL;
//TRACE("AddEntryToTree(level:%u - %s)\n", entry->level, entry->data.cFileName);
-
tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM;
-/*
- // Set the text of the item.
- tvi.pszText = entry->data.cFileName;
- tvi.cchTextMax = lstrlen(entry->data.cFileName);
- // Assume the item is not a parent item, so give it an image.
- tvi.iImage = Image_Root;
- tvi.iSelectedImage = Image_Root;
- tvi.cChildren = 1;
- // Save the heading level in the item's application-defined data area.
- //tvi.lParam = (LPARAM)entry->level;
- */
tvi.pszText = LPSTR_TEXTCALLBACK;
tvi.cchTextMax = 0;
tvi.iImage = I_IMAGECALLBACK;
tvi.cChildren = I_CHILDRENCALLBACK;
// Save the entry pointer in the item's application-defined data area.
tvi.lParam = (LPARAM)entry;
-
tvins.item = tvi;
tvins.hInsertAfter = hPrev;
-
// Set the parent item based on the specified level.
if (entry->level == 0) {
tvins.hParent = TVI_ROOT;
tvins.hParent = entry->up->hTreeItem;
}
}
-
// Add the item to the tree view control.
hPrev = (HTREEITEM)SendMessage(hwndTV, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT)&tvins);
-
// Save the handle to the item.
if (entry->level == 0)
hPrevRootItem = hPrev;
else if (entry->level == 1)
hPrevLev2Item = hPrev;
-/*
- // The new item is a child item. Give the parent item a
- // closed folder bitmap to indicate it now has child items.
- if (entry->level > 1) {
- HTREEITEM hti;
- hti = TreeView_GetParent(hwndTV, hPrev);
- tvi.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- tvi.hItem = hti;
- tvi.iImage = Image_Closed;
- tvi.iSelectedImage = Image_Closed;
- TreeView_SetItem(hwndTV, &tvi);
- }
- */
hItem = hPrev;
return hItem;
}
+#else
-static BOOL InitTreeViewItems(HWND hwndTV)
+static HTREEITEM AddEntryToTree(HWND hwndTV, HTREEITEM hParent, LPTSTR label, Root* entry, DWORD dwChildren)
{
- return TRUE;
-}
-
+ HTREEITEM hItem = 0;
+ TVITEM tvi;
+ TVINSERTSTRUCT tvins;
+
+ tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM;
+ tvi.pszText = label;
+ tvi.cchTextMax = lstrlen(tvi.pszText);
+ tvi.iImage = Image_Closed;
+ tvi.iSelectedImage = Image_Open;
+ tvi.cChildren = dwChildren;
+ tvi.lParam = (LPARAM)entry;
+ tvins.item = tvi;
+ if (entry) tvins.hInsertAfter = (HTREEITEM)TVI_LAST;
+ else tvins.hInsertAfter = (HTREEITEM)TVI_SORT;
+ tvins.hParent = hParent;
+ hItem = (HTREEITEM)SendMessage(hwndTV, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT)&tvins);
+ return hItem;
+}
+
+#endif
+
// insert treectrl entries after index idx
-static void insert_tree_entries(HWND hWnd, Entry* entry, int idx)
+static void insert_tree_entries(HWND hWnd, Entry* entry/*Root* pRoot*/, int idx)
{
static HTREEITEM hItemVisible;
static int hItemVisibleIdx;
+// Entry* entry = &pRoot->entry;
- if (!entry)
- return;
-
- if (entry->hTreeItem)
- return;
-
+ if (!entry) return;
+ if (entry->hTreeItem) return;
ShowWindow(hWnd, SW_HIDE);
for(; entry; entry=entry->next) {
#ifndef _LEFT_FILES
continue;
}
}
-// if (idx != -1)
-// idx++;
-// ListBox_InsertItemData(hWnd, idx, entry);
- //TRACE("Adding item %u [level:%u] - %s\n", ++idx, entry->level, entry->data.cFileName);
-
-
if (entry->hTreeItem) continue;
-
-
- entry->hTreeItem = AddEntryToTree(hWnd, entry);
+// entry->hTreeItem = AddEntryToTree(hWnd, entry);
+
+ if (entry->up && entry->up->hTreeItem) {
+// entry->hTreeItem = AddEntryToTree(hWnd, entry->up->hTreeItem, entry->data.cFileName, entry, 0);
+ entry->hTreeItem = AddEntryToTree(hWnd, entry->up->hTreeItem, entry->data.cFileName, NULL, 1);
+ } else {
+ entry->hTreeItem = AddEntryToTree(hWnd, TVI_ROOT, entry->data.cFileName, NULL, 0);
+// AddEntryToTree(hwndTV, pnmtv->itemNew.hItem, Name, NULL, dwCount);
+ }
if (entry->expanded) {
+// insert_tree_entries(hWnd, entry->down, idx + 1);
insert_tree_entries(hWnd, entry->down, idx + 1);
TreeView_Expand(hWnd, entry->hTreeItem, TVE_EXPAND);
}
ShowWindow(hWnd, SW_SHOW);
}
+static BOOL InitTreeViewItems(HWND hwndTV, ChildWnd* pChildWnd)
+{
+ TVITEM tvi;
+ TVINSERTSTRUCT tvins;
+ HTREEITEM hRoot;
+ TCHAR buffer[MAX_PATH];
+
+ wsprintf(buffer, _T("%s - [%s]"), pChildWnd->pRoot->path, pChildWnd->pRoot->fs);
+ tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM;
+ tvi.pszText = buffer;
+ tvi.cchTextMax = lstrlen(tvi.pszText);
+ tvi.iImage = Image_Root;
+ tvi.iSelectedImage = Image_Root;
+ tvi.cChildren = 5;
+// tvi.lParam = (LPARAM)&pChildWnd->pRoot->entry;
+ tvi.lParam = (LPARAM)pChildWnd->pRoot;
+// tvi.lParam = (LPARAM)pChildWnd;
+ tvins.item = tvi;
+ tvins.hInsertAfter = (HTREEITEM)TVI_FIRST;
+ tvins.hParent = TVI_ROOT;
+ // Add the item to the tree view control.
+ hRoot = (HTREEITEM)SendMessage(hwndTV, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT)&tvins);
+ pChildWnd->pRoot->entry.hTreeItem = hRoot;
+// TreeView_Expand(hwndTV, hRoot, TVE_EXPAND);
+// insert_tree_entries(hwndTV, &pChildWnd->pRoot->entry, 0);
+ // insert entries into treectrl
+// if (pChildWnd->pRoot) {
+// insert_tree_entries(hwndTV, &pChildWnd->pRoot->entry, 0);
+// }
+// TreeView_Expand(hwndTV, pChildWnd->pRoot->entry.hTreeItem, TVE_EXPAND);
+ // calculate column widths
+ if (!s_init) {
+ s_init = 1;
+ init_output(hwndTV);
+ }
+ return TRUE;
+}
+
// InitTreeViewImageLists - creates an image list, adds three bitmaps
// to it, and associates the image list with a tree view control.
BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
{
- static int expanding;
-
- Entry* entry = (Entry*)pnmtv->itemNew.lParam;
+ Root* pRoot = NULL;
+ TCHAR szPath[1000];
+ int keyPathLen = 0;
+ static int expanding;
if (expanding) return FALSE;
+ if (pnmtv->itemNew.state & TVIS_EXPANDEDONCE ) {
+ return TRUE;
+ }
expanding = TRUE;
- if (entry) {
- insert_tree_entries(hwndTV, entry->down, 0);
-// insert_tree_entries(hwndTV, entry, 0);
+ // check if this is either the root or a subkey item...
+ if ((Root*)pnmtv->itemNew.lParam == NULL) {
+ szPath[0] = _T('\0');
+ pRoot = FindPathRoot(hwndTV, pnmtv->itemNew.hItem, szPath, &keyPathLen, sizeof(szPath)/sizeof(TCHAR));
+ } else {
+ pRoot = (Root*)pnmtv->itemNew.lParam;
+ szPath[0] = _T('\0');
+ }
+ if (pRoot != NULL) {
+// Root* pNewRoot = NULL;
+// insert_tree_entries(hwndTV, &pRoot->entry, 0);
+
+ insert_tree_entries(hwndTV, pRoot->entry.down, 0);
+
+// entry->hTreeItem = AddEntryToTree(hWnd, entry->up->hTreeItem, entry->data.cFileName, NULL, 1);
+
+/*
+ HKEY hNewKey;
+ LONG errCode = RegOpenKeyEx(hKey, szPath, 0, KEY_READ, &hNewKey);
+ if (errCode == ERROR_SUCCESS) {
+ TCHAR Name[MAX_PATH];
+ DWORD cName = MAX_PATH;
+ FILETIME LastWriteTime;
+ DWORD dwIndex = 0L;
+ //ShowWindow(hwndTV, SW_HIDE);
+ while (RegEnumKeyEx(hNewKey, dwIndex, Name, &cName, NULL, NULL, NULL, &LastWriteTime) == ERROR_SUCCESS) {
+ DWORD dwCount = 0L;
+ errCode = RegOpenKeyEx(hNewKey, Name, 0, KEY_READ, &hKey);
+ if (errCode == ERROR_SUCCESS) {
+ TCHAR SubName[MAX_PATH];
+ DWORD cSubName = MAX_PATH;
+ while (RegEnumKeyEx(hKey, dwCount, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
+ ++dwCount;
+ }
+ }
+ RegCloseKey(hKey);
+ AddEntryToTree(hwndTV, pnmtv->itemNew.hItem, Name, NULL, dwCount);
+ cName = MAX_PATH;
+ ++dwIndex;
+ }
+ //ShowWindow(hwndTV, SW_SHOWNOACTIVATE);
+ RegCloseKey(hNewKey);
+ }
+ */
+ } else {
}
expanding = FALSE;
return TRUE;
}
+/*
+static void read_directory_win(Entry* parent, LPCTSTR path)
+{
+ Entry* entry = (Entry*)malloc(sizeof(Entry));
+ int level = parent->level + 1;
+ Entry* last = 0;
+ HANDLE hFind;
+ HANDLE hFile;
+
+ TCHAR buffer[MAX_PATH], *p;
+ for(p=buffer; *path; )
+ *p++ = *path++;
+ lstrcpy(p, _T("\\*"));
+ memset(entry, 0, sizeof(Entry));
+ hFind = FindFirstFile(buffer, &entry->data);
+ if (hFind != INVALID_HANDLE_VALUE) {
+ parent->down = entry;
+ do {
+ entry->down = 0;
+ entry->up = parent;
+ entry->expanded = FALSE;
+ entry->scanned = FALSE;
+ entry->level = level;
+ entry->unix_dir = FALSE;
+ entry->bhfi_valid = FALSE;
+ lstrcpy(p+1, entry->data.cFileName);
+ hFile = CreateFile(buffer, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+ 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
+ if (hFile != INVALID_HANDLE_VALUE) {
+ if (GetFileInformationByHandle(hFile, &entry->bhfi))
+ entry->bhfi_valid = TRUE;
+
+ CloseHandle(hFile);
+ }
+ last = entry;
+ entry = (Entry*) malloc(sizeof(Entry));
+ memset(entry, 0, sizeof(Entry));
+ if (last)
+ last->next = entry;
+ } while(FindNextFile(hFind, &entry->data));
+ last->next = 0;
+ FindClose(hFind);
+ } else {
+ parent->down = 0;
+ }
+ free(entry);
+ parent->scanned = TRUE;
+}
-#ifndef _MSC_VER
-#define NMTVDISPINFO TV_DISPINFO
-#define NMTVDISPINFO TV_DISPINFO
-#endif
-static void OnGetDispInfo(NMTVDISPINFO* ptvdi)
+void read_directory(Entry* parent, LPCTSTR path, int sortOrder)
+{
+ TCHAR buffer[MAX_PATH];
+ Entry* entry;
+ LPCTSTR s;
+ PTSTR d;
+
+ read_directory_win(parent, path);
+ if (Globals.prescan_node) {
+ s = path;
+ d = buffer;
+ while(*s)
+ *d++ = *s++;
+ *d++ = _T('\\');
+ for(entry=parent->down; entry; entry=entry->next)
+ if (entry->data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ lstrcpy(d, entry->data.cFileName);
+ read_directory_win(entry, buffer);
+ SortDirectory(entry, sortOrder);
+ }
+ }
+ SortDirectory(parent, sortOrder);
+}
+
+Entry* read_tree_win(Root* root, LPCTSTR path, int sortOrder)
+{
+ TCHAR buffer[MAX_PATH];
+ Entry* entry = &root->entry;
+ LPCTSTR s = path;
+ PTSTR d = buffer;
+
+ entry->unix_dir = FALSE;
+ while(entry) {
+ while(*s && *s!=_T('\\') && *s!=_T('/'))
+ *d++ = *s++;
+ while(*s==_T('\\') || *s==_T('/'))
+ s++;
+ *d++ = _T('\\');
+ *d = _T('\0');
+ read_directory(entry, buffer, sortOrder);
+ if (entry->down)
+ entry->expanded = TRUE;
+ if (!*s)
+ break;
+ entry = find_entry_win(entry, s);
+ }
+ return entry;
+}
+
+ */
+void OnGetDispInfo(NMTVDISPINFO* ptvdi)
{
// static TCHAR buffer[200];
// LVITEM* pItem = &(ptvdi->item);
// Entry* entry = (Entry*)pItem->lParam;
- Entry* entry = (Entry*)ptvdi->item.lParam;
+ Root* entry = (Root*)ptvdi->item.lParam;
ASSERT(entry);
if (ptvdi->item.mask & TVIF_CHILDREN ) {
ptvdi->item.iSelectedImage = Image_Closed;
}
if (ptvdi->item.mask & TVIF_TEXT) {
- ptvdi->item.pszText = entry->data.cFileName;
- ptvdi->item.cchTextMax = lstrlen(entry->data.cFileName);
+// ptvdi->item.pszText = entry->data.cFileName;
+// ptvdi->item.cchTextMax = lstrlen(entry->data.cFileName);
}
}
-// OnEndLabelEdit - processes the LVN_ENDLABELEDIT notification message.
-// Returns TRUE if the label is changed, or FALSE otherwise.
-
-static BOOL OnEndLabelEdit(NMTVDISPINFO* ptvdi)
-{
-// if (ptvdi->item.iItem == -1)
-// return FALSE;
-
- // Copy the new label text to the application-defined structure.
-// lstrcpyn(rgPetInfo[ptvdi->item.iItem].szKind, ptvdi->item.pszText, 10);
-
- return TRUE;
- // To make a more robust application you should send an EM_LIMITTEXT
- // message to the edit control to prevent the user from entering too
- // many characters in the field.
-}
-
void UpdateStatus(HWND hWnd, Entry* pEntry)
{
int file_count = 0;
}
pEntry = pEntry->next;
};
-
_tcscpy(suffix, _T(" bytes"));
{
NUMBERFMT numFmt;
}
}
+// CreateTreeView - creates a tree view control.
+// Returns the handle to the new control if successful, or NULL otherwise.
+// hwndParent - handle to the control's parent window.
+
+HWND CreateTreeView(HWND hwndParent, ChildWnd* pChildWnd, int id)
+{
+ RECT rcClient;
+ HWND hwndTV;
+
+ // Get the dimensions of the parent window's client area, and create the tree view control.
+ GetClientRect(hwndParent, &rcClient);
+ hwndTV = CreateWindowEx(0, WC_TREEVIEW, _T("Tree View"),
+ WS_VISIBLE | WS_CHILD | WS_BORDER | WS_EX_CLIENTEDGE | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT,
+ 0, 0, rcClient.right, rcClient.bottom,
+ hwndParent, (HMENU)id, hInst, NULL);
+ // Initialize the image list, and add items to the control.
+ if (!InitTreeViewImageLists(hwndTV) || !InitTreeViewItems(hwndTV, pChildWnd)) {
+ DestroyWindow(hwndTV);
+ return NULL;
+ }
+ SendMessage(hwndTV, WM_SETFONT, (WPARAM)Globals.hFont, FALSE);
+ return hwndTV;
+}
+
////////////////////////////////////////////////////////////////////////////////
+
+#ifdef _SUBWND_TREEVIEW
+
static WNDPROC g_orgTreeWndProc;
+// OnEndLabelEdit - processes the LVN_ENDLABELEDIT notification message.
+// Returns TRUE if the label is changed, or FALSE otherwise.
+
+static BOOL OnEndLabelEdit(NMTVDISPINFO* ptvdi)
+{
+// if (ptvdi->item.iItem == -1)
+// return FALSE;
+
+ // Copy the new label text to the application-defined structure.
+// lstrcpyn(rgPetInfo[ptvdi->item.iItem].szKind, ptvdi->item.pszText, 10);
+
+ return TRUE;
+ // To make a more robust application you should send an EM_LIMITTEXT
+ // message to the edit control to prevent the user from entering too
+ // many characters in the field.
+}
+
static LRESULT CALLBACK TreeWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
ChildWnd* child = (ChildWnd*)GetWindowLong(GetParent(hWnd), GWL_USERDATA);
case WM_KEYDOWN:
if (wParam == VK_TAB) {
//TODO: SetFocus(Globals.hDriveBar)
- SetFocus(child->nFocusPanel ? child->left.hWnd: child->right.hWnd);
+ SetFocus(child->nFocusPanel ? child->hTreeWnd: child->hListWnd);
}
break;
}
return CallWindowProc(g_orgTreeWndProc, hWnd, message, wParam, lParam);
}
-// CreateTreeView - creates a tree view control.
-// Returns the handle to the new control if successful, or NULL otherwise.
-// hwndParent - handle to the control's parent window.
-
-static HWND CreateTreeView(HWND hwndParent, int id)
-{
- RECT rcClient;
- HWND hwndTV;
-
- // Get the dimensions of the parent window's client area, and create the tree view control.
- GetClientRect(hwndParent, &rcClient);
- hwndTV = CreateWindowEx(0, WC_TREEVIEW, _T("Tree View"),
- WS_VISIBLE | WS_CHILD | WS_BORDER | WS_EX_CLIENTEDGE | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT,
- 0, 0, rcClient.right, rcClient.bottom,
- hwndParent, (HMENU)id, hInst, NULL);
- // Initialize the image list, and add items to the control.
- if (!InitTreeViewImageLists(hwndTV) || !InitTreeViewItems(hwndTV)) {
- DestroyWindow(hwndTV);
- return NULL;
- }
- return hwndTV;
-}
-
-//void create_tree_window(HWND parent, Pane* pane, int id, int id_header, LPTSTR lpszFileName)
void CreateTreeWnd(HWND parent, Pane* pane, int id)
{
- static int s_init = 0;
Entry* entry = pane->root;
-
- pane->treePane = 1;
-
- pane->hWnd = CreateTreeView(parent, id);
+ pane->hWnd = CreateTreeView(parent, NULL, id);
SetWindowLong(pane->hWnd, GWL_USERDATA, (LPARAM)pane);
g_orgTreeWndProc = SubclassWindow(pane->hWnd, TreeWndProc);
SendMessage(pane->hWnd, WM_SETFONT, (WPARAM)Globals.hFont, FALSE);
- // insert entries into treectrl
+ // insert entries into treectrl
if (entry) {
insert_tree_entries(pane->hWnd, entry, 0);
}
s_init = 1;
init_output(pane->hWnd);
}
-// calc_widths(pane, TRUE);
-//#ifndef _NO_EXTENSIONS
-// pane->hwndHeader = create_header(parent, pane, id_header);
-//#endif
}
+
+#endif
extern "C" {
#endif
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
+//void CreateTreeWnd(HWND parent, Pane* pane, int id);
+//HTREEITEM AddItemToTree(HWND hwndTV, LPTSTR lpszItem, int nLevel);
-void CreateTreeWnd(HWND parent, Pane* pane, int id);
+HWND CreateTreeView(HWND hwndParent, ChildWnd* pChildWnd, int id);
+void UpdateStatus(HWND hWnd, Entry* pEntry);
-HTREEITEM AddItemToTree(HWND hwndTV, LPTSTR lpszItem, int nLevel);
+BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv);
+
+#ifndef _MSC_VER
+#define NMTVDISPINFO TV_DISPINFO
+#define NMTVDISPINFO TV_DISPINFO
+#endif
+
+void OnGetDispInfo(NMTVDISPINFO* ptvdi);
#ifdef __cplusplus
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef _MSC_VER
-#include "stdafx.h"
-#else
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-#endif
#include <windowsx.h>
#include <ctype.h>
#include "listview.h"
#include "utils.h"
#include "sort.h"
-#include "draw.h"
+
#define FRM_CALC_CLIENT 0xBF83
#define Frame_CalcFrameClient(hWnd, prt) ((BOOL)SNDMSG(hWnd, FRM_CALC_CLIENT, 0, (LPARAM)(PRECT)prt))
{
TCHAR path[MAX_PATH];
- child->left.cur = entry;
- child->right.root = entry;
- child->right.cur = entry;
+// child->left.cur = entry;
+// child->right.root = entry;
+// child->right.cur = entry;
if (!entry->scanned)
scan_entry(child, entry);
else {
-// ListBox_ResetContent(child->right.hWnd);
+// ListBox_ResetContent(child->hListWnd);
// insert_entries(&child->right, entry->down, -1);
-// RefreshList(child->right.hWnd, entry);
+// RefreshList(child->hListWnd, entry);
// calc_widths(&child->right, FALSE);
//#ifndef _NO_EXTENSIONS
// set_header(&child->right);
//#endif
}
- RefreshList(child->right.hWnd, entry->down);
+ RefreshList(child->hListWnd, entry->down);
get_path(entry, path);
lstrcpy(child->szPath, path);
extern "C" {
#endif
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-
void display_error(HWND hWnd, DWORD error);
void frame_get_clientspace(HWND hWnd, PRECT prect);
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef _MSC_VER
-#include "stdafx.h"
-#else
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <commctrl.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
-#endif
#include <windowsx.h>
#include <process.h>