Updated treeview and listview functionality.

svn path=/trunk/; revision=3242
This commit is contained in:
Robert Dickenson 2002-07-16 23:22:19 +00:00
parent 1ad1b97103
commit 21214f6b8c
8 changed files with 274 additions and 227 deletions

View file

@ -20,8 +20,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef __CHILD_WND_H__ #ifndef __CHILDWND_H__
#define __CHILD_WND_H__ #define __CHILDWND_H__
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -39,4 +39,4 @@ LRESULT CALLBACK ChildWndProc(HWND, UINT, WPARAM, LPARAM);
}; };
#endif #endif
#endif // __CHILD_WND_H__ #endif // __CHILDWND_H__

View file

@ -166,11 +166,9 @@ void free_entries(Entry* parent)
if (next) { if (next) {
parent->down = 0; parent->down = 0;
do { do {
entry = next; entry = next;
next = entry->next; next = entry->next;
free_entries(entry); free_entries(entry);
free(entry); free(entry);
} while(next); } while(next);
@ -180,6 +178,7 @@ void free_entries(Entry* parent)
// insert listbox entries after index idx // insert listbox entries after index idx
void insert_entries(Pane* pane, Entry* parent, int idx) void insert_entries(Pane* pane, Entry* parent, int idx)
{ {
/*
Entry* entry = parent; Entry* entry = parent;
if (!entry) if (!entry)
@ -206,12 +205,14 @@ void insert_entries(Pane* pane, Entry* parent, int idx)
insert_entries(pane, entry->down, idx); insert_entries(pane, entry->down, idx);
} }
ShowWindow(pane->hWnd, SW_SHOW); ShowWindow(pane->hWnd, SW_SHOW);
*/
} }
void scan_entry(ChildWnd* child, Entry* entry) void scan_entry(ChildWnd* child, Entry* entry)
{ {
TCHAR path[MAX_PATH]; TCHAR path[MAX_PATH];
/*
int idx = ListBox_GetCurSel(child->left.hWnd); int idx = ListBox_GetCurSel(child->left.hWnd);
HCURSOR crsrOld = SetCursor(LoadCursor(0, IDC_WAIT)); HCURSOR crsrOld = SetCursor(LoadCursor(0, IDC_WAIT));
@ -228,14 +229,14 @@ void scan_entry(ChildWnd* child, Entry* entry)
// empty right pane // empty right pane
ListBox_ResetContent(child->right.hWnd); ListBox_ResetContent(child->right.hWnd);
*/
// release memory // release memory
free_entries(entry); free_entries(entry);
// read contents from disk // read contents from disk
get_path(entry, path); get_path(entry, path);
read_directory(entry, path, child->sortOrder); read_directory(entry, path, child->sortOrder);
/*
// insert found entries in right pane // insert found entries in right pane
insert_entries(&child->right, entry->down, -1); insert_entries(&child->right, entry->down, -1);
calc_widths(&child->right, FALSE); calc_widths(&child->right, FALSE);
@ -246,6 +247,7 @@ void scan_entry(ChildWnd* child, Entry* entry)
child->header_wdths_ok = FALSE; child->header_wdths_ok = FALSE;
SetCursor(crsrOld); SetCursor(crsrOld);
*/
} }
@ -271,14 +273,14 @@ BOOL expand_entry(ChildWnd* child, Entry* dir)
// no subdirectories ? // no subdirectories ?
if (!(p->data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) if (!(p->data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
return FALSE; return FALSE;
/*
idx = ListBox_FindItemData(child->left.hWnd, 0, dir); idx = ListBox_FindItemData(child->left.hWnd, 0, dir);
*/
dir->expanded = TRUE; dir->expanded = TRUE;
// insert entries in left pane // insert entries in left pane
insert_entries(&child->left, p, idx); insert_entries(&child->left, p, idx);
/*
if (!child->header_wdths_ok) { if (!child->header_wdths_ok) {
if (calc_widths(&child->left, FALSE)) { if (calc_widths(&child->left, FALSE)) {
#ifndef _NO_EXTENSIONS #ifndef _NO_EXTENSIONS
@ -288,7 +290,7 @@ BOOL expand_entry(ChildWnd* child, Entry* dir)
child->header_wdths_ok = TRUE; child->header_wdths_ok = TRUE;
} }
} }
*/
return TRUE; return TRUE;
} }

View file

@ -36,6 +36,7 @@
//#include <shellapi.h> //#include <shellapi.h>
#include <windowsx.h> #include <windowsx.h>
#include <process.h>
#include <assert.h> #include <assert.h>
#define ASSERT assert #define ASSERT assert
@ -57,6 +58,9 @@ BOOL bInMenuLoop = FALSE; // Tells us if we are in the menu loop
int nOldWidth; // Holds the previous client area width int nOldWidth; // Holds the previous client area width
int nOldHeight; // Holds the previous client area height int nOldHeight; // Holds the previous client area height
static HANDLE hMonitorThreadEvent = NULL; // When this event becomes signaled then we run the monitor thread
void MonitorThreadProc(void *lpParameter);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Local module support methods // Local module support methods
@ -718,6 +722,7 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
} }
CheckShellAvailable(); CheckShellAvailable();
CheckNetworkAvailable(); CheckNetworkAvailable();
_beginthread(MonitorThreadProc, 0, NULL);
CreateChildWindow(-1); CreateChildWindow(-1);
break; break;
@ -751,6 +756,11 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
return DefFrameProc(hWnd, Globals.hMDIClient, message, wParam, lParam); return DefFrameProc(hWnd, Globals.hMDIClient, message, wParam, lParam);
} }
break; break;
case WM_TIMER:
SetEvent(hMonitorThreadEvent);
break;
case WM_SIZE: case WM_SIZE:
resize_frame_client(hWnd); resize_frame_client(hWnd);
break; break;
@ -765,6 +775,7 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
break; break;
case WM_DESTROY: case WM_DESTROY:
WinHelp(hWnd, _T("winfile"), HELP_QUIT, 0); WinHelp(hWnd, _T("winfile"), HELP_QUIT, 0);
CloseHandle(hMonitorThreadEvent);
PostQuitMessage(0); PostQuitMessage(0);
break; break;
case WM_QUERYENDSESSION: case WM_QUERYENDSESSION:
@ -778,3 +789,52 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
} }
return 0; return 0;
} }
void MonitorThreadProc(void *lpParameter)
{
// ULONG OldProcessorUsage = 0;
// ULONG OldProcessCount = 0;
// Create the event
hMonitorThreadEvent = CreateEvent(NULL, TRUE, TRUE, "Winfile Monitor Event");
// If we couldn't create the event then exit the thread
if (!hMonitorThreadEvent)
return;
while (1) {
DWORD dwWaitVal;
// Wait on the event
dwWaitVal = WaitForSingleObject(hMonitorThreadEvent, INFINITE);
// If the wait failed then the event object must have been
// closed and the task manager is exiting so exit this thread
if (dwWaitVal == WAIT_FAILED)
return;
if (dwWaitVal == WAIT_OBJECT_0) {
// Reset our event
ResetEvent(hMonitorThreadEvent);
#if 0
TCHAR text[260];
if ((ULONG)SendMessage(hProcessPageListCtrl, LVM_GETITEMCOUNT, 0, 0) != PerfDataGetProcessCount())
SendMessage(hProcessPageListCtrl, LVM_SETITEMCOUNT, PerfDataGetProcessCount(), /*LVSICF_NOINVALIDATEALL|*/LVSICF_NOSCROLL);
if (IsWindowVisible(hProcessPage))
InvalidateRect(hProcessPageListCtrl, NULL, FALSE);
if (OldProcessorUsage != PerfDataGetProcessorUsage()) {
OldProcessorUsage = PerfDataGetProcessorUsage();
wsprintf(text, _T("CPU Usage: %3d%%"), OldProcessorUsage);
SendMessage(hStatusWnd, SB_SETTEXT, 1, (LPARAM)text);
}
if (OldProcessCount != PerfDataGetProcessCount()) {
OldProcessCount = PerfDataGetProcessCount();
wsprintf(text, _T("Processes: %d"), OldProcessCount);
SendMessage(hStatusWnd, SB_SETTEXT, 0, (LPARAM)text);
}
#endif
}
}
}

View file

@ -34,28 +34,20 @@
#include <stdio.h> #include <stdio.h>
#endif #endif
#include <shellapi.h>
//#include <winspool.h>
#include <windowsx.h> #include <windowsx.h>
#include <shellapi.h> //#include <assert.h>
#include <ctype.h> //#define ASSERT assert
#include <assert.h>
#define ASSERT assert
#include "main.h" #include "main.h"
#include "listview.h" #include "listview.h"
#include "dialogs.h"
#include "utils.h"
#include "run.h" #include "run.h"
#include "trace.h" #include "trace.h"
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Global Variables: // Global and Local Variables:
// //
extern HINSTANCE hInst;
static WNDPROC g_orgListWndProc; static WNDPROC g_orgListWndProc;
@ -63,23 +55,6 @@ static WNDPROC g_orgListWndProc;
// Local module support methods // Local module support methods
// //
static void init_output(HWND hWnd)
{
TCHAR b[16];
HFONT old_font;
HDC hdc = GetDC(hWnd);
if (GetNumberFormat(LOCALE_USER_DEFAULT, 0, _T("1000"), 0, b, 16) > 4)
Globals.num_sep = b[1];
else
Globals.num_sep = _T('.');
old_font = SelectFont(hdc, Globals.hFont);
GetTextExtentPoint32(hdc, _T(" "), 1, &Globals.spaceSize);
SelectFont(hdc, old_font);
ReleaseDC(hWnd, hdc);
}
static void AddEntryToList(HWND hwndLV, int idx, Entry* entry) static void AddEntryToList(HWND hwndLV, int idx, Entry* entry)
{ {
LVITEM item; LVITEM item;
@ -116,7 +91,6 @@ static void InsertListEntries(HWND hWnd, Entry* entry, int idx)
if (entry->data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) if (entry->data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
continue; continue;
#endif #endif
//ListBox_InsertItemData(hWnd, idx, entry);
AddEntryToList(hWnd, idx, entry); AddEntryToList(hWnd, idx, entry);
++idx; ++idx;
} }
@ -150,99 +124,16 @@ static void CreateListColumns(HWND hWndListView)
} }
} }
static HWND CreateListView(HWND hwndParent, int id) // OnGetDispInfo - processes the LVN_GETDISPINFO notification message.
{
RECT rcClient; // dimensions of client area
HWND hwndLV; // handle to list view control
// Get the dimensions of the parent window's client area, and create the list view control.
GetClientRect(hwndParent, &rcClient);
hwndLV = CreateWindowEx(0, WC_LISTVIEW, _T("List View"),
// WS_VISIBLE | WS_CHILD | WS_BORDER | LVS_REPORT | LVS_NOCOLUMNHEADER,
WS_VISIBLE | WS_CHILD | WS_BORDER | LVS_REPORT,
0, 0, rcClient.right, rcClient.bottom,
hwndParent, (HMENU)id, hInst, NULL);
// Initialize the image list, and add items to the control.
/*
if (!InitListViewImageLists(hwndLV) ||
!InitListViewItems(hwndLV, lpszPathName)) {
DestroyWindow(hwndLV);
return FALSE;
}
*/
ListView_SetExtendedListViewStyle(hwndLV, LVS_EX_FULLROWSELECT);
CreateListColumns(hwndLV);
return hwndLV;
}
/*
int GetNumberFormat(
LCID Locale, // locale
DWORD dwFlags, // options
LPCTSTR lpValue, // input number string
CONST NUMBERFMT *lpFormat, // formatting information
LPTSTR lpNumberStr, // output buffer
int cchNumber // size of output buffer
);
*/
/*
typedef struct _numberfmt {
UINT NumDigits;
UINT LeadingZero;
UINT Grouping;
LPTSTR lpDecimalSep;
LPTSTR lpThousandSep;
UINT NegativeOrder;
} NUMBERFMT, *LPNUMBERFMT;
*/
/*
typedef struct _BY_HANDLE_FILE_INFORMATION {
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD dwVolumeSerialNumber;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
DWORD nNumberOfLinks;
DWORD nFileIndexHigh;
DWORD nFileIndexLow;
} BY_HANDLE_FILE_INFORMATION, *PBY_HANDLE_FILE_INFORMATION;
GetDriveTypeW
GetFileType
GetLocaleInfoW
GetNumberFormatW
BOOL FileTimeToLocalFileTime(
CONST FILETIME *lpFileTime, // UTC file time to convert
LPFILETIME lpLocalFileTime // converted file time
);
BOOL FileTimeToSystemTime(
CONST FILETIME *lpFileTime, // file time to convert
LPSYSTEMTIME lpSystemTime // receives system time
);
*/
// OnGetDispInfo - processes the LVN_GETDISPINFO
// notification message.
static void OnGetDispInfo(NMLVDISPINFO* plvdi) static void OnGetDispInfo(NMLVDISPINFO* plvdi)
{ {
SYSTEMTIME SystemTime; SYSTEMTIME SystemTime;
FILETIME LocalFileTime; FILETIME LocalFileTime;
static TCHAR buffer[200]; static TCHAR buffer[200];
// LVITEM* pItem = &(plvdi->item);
// Entry* entry = (Entry*)pItem->lParam;
Entry* entry = (Entry*)plvdi->item.lParam; Entry* entry = (Entry*)plvdi->item.lParam;
ASSERT(entry); ASSERT(entry);
plvdi->item.pszText = NULL; plvdi->item.pszText = NULL;
switch (plvdi->item.iSubItem) { switch (plvdi->item.iSubItem) {
case 0: case 0:
plvdi->item.pszText = entry->data.cFileName; plvdi->item.pszText = entry->data.cFileName;
@ -353,35 +244,6 @@ static BOOL OnEndLabelEdit(NMLVDISPINFO* plvdi)
// many characters in the field. // many characters in the field.
} }
/*
typedef struct _BY_HANDLE_FILE_INFORMATION {
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD dwVolumeSerialNumber;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
DWORD nNumberOfLinks;
DWORD nFileIndexHigh;
DWORD nFileIndexLow;
} BY_HANDLE_FILE_INFORMATION, *PBY_HANDLE_FILE_INFORMATION;
*/
/*
typedef struct _WIN32_FIND_DATA {
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
DWORD dwReserved0;
DWORD dwReserved1;
TCHAR cFileName[ MAX_PATH ];
TCHAR cAlternateFileName[ 14 ];
} WIN32_FIND_DATA, *PWIN32_FIND_DATA;
*/
static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{ {
Entry* pItem1 = (Entry*)lParam1; Entry* pItem1 = (Entry*)lParam1;
@ -420,6 +282,17 @@ static void CmdSortItems(HWND hWnd, UINT cmd)
CheckMenuItem(Globals.hMenuView, cmd, MF_BYCOMMAND | MF_CHECKED); CheckMenuItem(Globals.hMenuView, cmd, MF_BYCOMMAND | MF_CHECKED);
} }
void RefreshList(HWND hWnd, Entry* entry)
{
if (hWnd != NULL) {
ListView_DeleteAllItems(hWnd);
if (entry != NULL) {
//TRACE("RefreshList(...) entry name: %s\n", entry->data.cFileName);
InsertListEntries(hWnd, entry, -1);
}
}
}
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
UINT cmd = LOWORD(wParam); UINT cmd = LOWORD(wParam);
@ -432,7 +305,6 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
LVITEM item; LVITEM item;
item.mask = LVIF_PARAM; item.mask = LVIF_PARAM;
// UINT selected_count = ListView_GetSelectedCount(hWnd); // UINT selected_count = ListView_GetSelectedCount(hWnd);
item.iItem = ListView_GetNextItem(hWnd, -1, LVNI_SELECTED); item.iItem = ListView_GetNextItem(hWnd, -1, LVNI_SELECTED);
if (item.iItem != -1) { if (item.iItem != -1) {
if (ListView_GetItem(hWnd, &item)) { if (ListView_GetItem(hWnd, &item)) {
@ -466,6 +338,9 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case ID_VIEW_SORT_BY_SIZE: case ID_VIEW_SORT_BY_SIZE:
case ID_VIEW_SORT_BY_DATE: case ID_VIEW_SORT_BY_DATE:
CmdSortItems(hWnd, cmd); CmdSortItems(hWnd, cmd);
break;
case ID_WINDOW_REFRESH:
RefreshList(hWnd, NULL/*entry*/);
break; break;
default: default:
return FALSE; return FALSE;
@ -483,24 +358,18 @@ static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPAR
ASSERT(child); ASSERT(child);
switch (message) { switch (message) {
/*
case WM_CREATE:
//CreateListView(hWnd);
return 0;
*/
case WM_COMMAND: case WM_COMMAND:
if (!_CmdWndProc(hWnd, message, wParam, lParam)) { if (_CmdWndProc(hWnd, message, wParam, lParam)) {
return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam); return 0;
} }
break; break;
case WM_DISPATCH_COMMAND: case WM_DISPATCH_COMMAND:
return _CmdWndProc(hWnd, message, wParam, lParam); return _CmdWndProc(hWnd, message, wParam, lParam);
break;
case WM_NOTIFY: case WM_NOTIFY:
switch (((LPNMHDR)lParam)->code) { switch (((LPNMHDR)lParam)->code) {
case LVN_GETDISPINFO: case LVN_GETDISPINFO:
OnGetDispInfo((NMLVDISPINFO*)lParam); OnGetDispInfo((NMLVDISPINFO*)lParam);
break; return 0;
case NM_DBLCLK: case NM_DBLCLK:
{ {
NMITEMACTIVATE* nmitem = (LPNMITEMACTIVATE)lParam; NMITEMACTIVATE* nmitem = (LPNMITEMACTIVATE)lParam;
@ -531,86 +400,57 @@ static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPAR
} }
} }
} }
break; return 0;
case LVN_ENDLABELEDIT: case LVN_ENDLABELEDIT:
return OnEndLabelEdit((NMLVDISPINFO*)lParam); return OnEndLabelEdit((NMLVDISPINFO*)lParam);
break;
default:
return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam);
} }
// return 0;
break; break;
/*
case WM_SETFOCUS:
child->nFocusPanel = pane==&child->right? 1: 0;
ListBox_SetSel(hWnd, TRUE, 1);
//TODO: check menu items
break;
case WM_KEYDOWN:
if (wParam == VK_TAB) {
//TODO: SetFocus(Globals.hDriveBar)
SetFocus(child->nFocusPanel? child->left.hWnd: child->right.hWnd);
}
break;
*/
default:
return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam);
break;
}
return 0;
}
case WM_SETFOCUS:
child->nFocusPanel = pane==&child->right? 1: 0;
//ListView_SetSelectionMark(hWnd, 0);
//TODO: check menu items
break;
case WM_KEYDOWN:
if (wParam == VK_TAB) {
//TODO: SetFocus(Globals.hDriveBar)
SetFocus(child->nFocusPanel ? child->left.hWnd: child->right.hWnd);
}
break;
}
return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam);
}
void CreateListWnd(HWND parent, Pane* pane, int id, LPTSTR lpszPathName) void CreateListWnd(HWND parent, Pane* pane, int id, LPTSTR lpszPathName)
{ {
// static int s_init = 0; RECT rcClient; // dimensions of client area
Entry* entry = pane->root; Entry* entry = pane->root;
pane->treePane = 0; pane->treePane = 0;
#if 1
pane->hWnd = CreateListView(parent, id); GetClientRect(parent, &rcClient);
#else pane->hWnd = CreateWindowEx(0, WC_LISTVIEW, _T("List View"),
pane->hWnd = CreateWindow(_T("ListBox"), _T(""), WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL| WS_VISIBLE | WS_CHILD | WS_BORDER | LVS_REPORT/* | LVS_NOCOLUMNHEADER*/,
LBS_DISABLENOSCROLL|LBS_NOINTEGRALHEIGHT|LBS_OWNERDRAWFIXED|LBS_NOTIFY, 0, 0, rcClient.right, rcClient.bottom,
0, 0, 0, 0, parent, (HMENU)id, Globals.hInstance, 0); parent, (HMENU)id, hInst, NULL);
#endif // Initialize the image list, and add items to the control.
/*
if (!InitListViewImageLists(pane->hWnd) ||
!InitListViewItems(pane->hWnd, lpszPathName)) {
DestroyWindow(pane->hWnd);
return FALSE;
}
*/
ListView_SetExtendedListViewStyle(pane->hWnd, LVS_EX_FULLROWSELECT);
CreateListColumns(pane->hWnd);
SetWindowLong(pane->hWnd, GWL_USERDATA, (LPARAM)pane); SetWindowLong(pane->hWnd, GWL_USERDATA, (LPARAM)pane);
g_orgListWndProc = SubclassWindow(pane->hWnd, ListWndProc); g_orgListWndProc = SubclassWindow(pane->hWnd, ListWndProc);
SendMessage(pane->hWnd, WM_SETFONT, (WPARAM)Globals.hFont, FALSE); SendMessage(pane->hWnd, WM_SETFONT, (WPARAM)Globals.hFont, FALSE);
// insert entries into listbox // insert entries into listbox
if (entry) { if (entry) {
InsertListEntries(pane->hWnd, entry, -1); InsertListEntries(pane->hWnd, entry, -1);
} }
// calculate column widths
// if (!s_init) {
// s_init = 1;
// init_output(pane->hWnd);
// }
// calc_widths(pane, TRUE);
} }
void RefreshList(HWND hWnd, Entry* entry)
{
if (hWnd != NULL) {
ListView_DeleteAllItems(hWnd);
if (entry != NULL) {
//TRACE("RefreshList(...) entry name: %s\n", entry->data.cFileName);
InsertListEntries(hWnd, entry, -1);
}
}
}
/*
Pane* pane = (Pane*)GetWindowLong(hWnd, GWL_USERDATA);
if (pane != NULL) {
// ListBox_RemoveAll(hWnd, TRUE, 1);
ListView_DeleteAllItems(pane->hWnd);
if (entry) {
InsertListEntries(pane->hWnd, entry, -1);
}
}
*/

View file

@ -35,6 +35,7 @@
#endif #endif
#include "main.h" #include "main.h"
#include "settings.h"
#include "framewnd.h" #include "framewnd.h"
#include "childwnd.h" #include "childwnd.h"
@ -459,6 +460,8 @@ int APIENTRY WinMain(HINSTANCE hInstance,
// Store instance handle in our global variable // Store instance handle in our global variable
hInst = hInstance; hInst = hInstance;
LoadSettings();
// Perform application initialization: // Perform application initialization:
if (!InitInstance(hInstance, nCmdShow)) { if (!InitInstance(hInstance, nCmdShow)) {
return FALSE; return FALSE;
@ -477,6 +480,8 @@ int APIENTRY WinMain(HINSTANCE hInstance,
DispatchMessage(&msg); DispatchMessage(&msg);
} }
} }
SaveSettings();
ExitInstance(); ExitInstance();
return msg.wParam; return msg.wParam;
} }

View file

@ -44,3 +44,133 @@ TCHAR ViewTypeMaskStr[MAX_TYPE_MASK_LEN];
//LPCTSTR lpViewTypeMaskStr; //LPCTSTR lpViewTypeMaskStr;
void LoadSettings(void)
{
HKEY hKey;
char szSubKey[] = "Software\\ReactWare\\FileManager";
/*
int i;
DWORD dwSize;
// Window size & position settings
TaskManagerSettings.Maximized = FALSE;
TaskManagerSettings.Left = 0;
TaskManagerSettings.Top = 0;
TaskManagerSettings.Right = 0;
TaskManagerSettings.Bottom = 0;
// Tab settings
TaskManagerSettings.ActiveTabPage = 0;
// Options menu settings
TaskManagerSettings.AlwaysOnTop = FALSE;
TaskManagerSettings.MinimizeOnUse = TRUE;
TaskManagerSettings.HideWhenMinimized = TRUE;
TaskManagerSettings.Show16BitTasks = TRUE;
// Update speed settings
TaskManagerSettings.UpdateSpeed = 2;
// Applications page settings
TaskManagerSettings.View_LargeIcons = FALSE;
TaskManagerSettings.View_SmallIcons = FALSE;
TaskManagerSettings.View_Details = TRUE;
// Processes page settings
TaskManagerSettings.ShowProcessesFromAllUsers = FALSE; // Server-only?
TaskManagerSettings.Column_ImageName = TRUE;
TaskManagerSettings.Column_PID = TRUE;
TaskManagerSettings.Column_CPUUsage = TRUE;
TaskManagerSettings.Column_CPUTime = TRUE;
TaskManagerSettings.Column_MemoryUsage = TRUE;
TaskManagerSettings.Column_MemoryUsageDelta = FALSE;
TaskManagerSettings.Column_PeakMemoryUsage = FALSE;
TaskManagerSettings.Column_PageFaults = FALSE;
TaskManagerSettings.Column_USERObjects = FALSE;
TaskManagerSettings.Column_IOReads = FALSE;
TaskManagerSettings.Column_IOReadBytes = FALSE;
TaskManagerSettings.Column_SessionID = FALSE; // Server-only?
TaskManagerSettings.Column_UserName = FALSE; // Server-only?
TaskManagerSettings.Column_PageFaultsDelta = FALSE;
TaskManagerSettings.Column_VirtualMemorySize = FALSE;
TaskManagerSettings.Column_PagedPool = FALSE;
TaskManagerSettings.Column_NonPagedPool = FALSE;
TaskManagerSettings.Column_BasePriority = FALSE;
TaskManagerSettings.Column_HandleCount = FALSE;
TaskManagerSettings.Column_ThreadCount = FALSE;
TaskManagerSettings.Column_GDIObjects = FALSE;
TaskManagerSettings.Column_IOWrites = FALSE;
TaskManagerSettings.Column_IOWriteBytes = FALSE;
TaskManagerSettings.Column_IOOther = FALSE;
TaskManagerSettings.Column_IOOtherBytes = FALSE;
for (i = 0; i < 25; i++) {
TaskManagerSettings.ColumnOrderArray[i] = i;
}
TaskManagerSettings.ColumnSizeArray[0] = 105;
TaskManagerSettings.ColumnSizeArray[1] = 50;
TaskManagerSettings.ColumnSizeArray[2] = 107;
TaskManagerSettings.ColumnSizeArray[3] = 70;
TaskManagerSettings.ColumnSizeArray[4] = 35;
TaskManagerSettings.ColumnSizeArray[5] = 70;
TaskManagerSettings.ColumnSizeArray[6] = 70;
TaskManagerSettings.ColumnSizeArray[7] = 100;
TaskManagerSettings.ColumnSizeArray[8] = 70;
TaskManagerSettings.ColumnSizeArray[9] = 70;
TaskManagerSettings.ColumnSizeArray[10] = 70;
TaskManagerSettings.ColumnSizeArray[11] = 70;
TaskManagerSettings.ColumnSizeArray[12] = 70;
TaskManagerSettings.ColumnSizeArray[13] = 70;
TaskManagerSettings.ColumnSizeArray[14] = 60;
TaskManagerSettings.ColumnSizeArray[15] = 60;
TaskManagerSettings.ColumnSizeArray[16] = 60;
TaskManagerSettings.ColumnSizeArray[17] = 60;
TaskManagerSettings.ColumnSizeArray[18] = 60;
TaskManagerSettings.ColumnSizeArray[19] = 70;
TaskManagerSettings.ColumnSizeArray[20] = 70;
TaskManagerSettings.ColumnSizeArray[21] = 70;
TaskManagerSettings.ColumnSizeArray[22] = 70;
TaskManagerSettings.ColumnSizeArray[23] = 70;
TaskManagerSettings.ColumnSizeArray[24] = 70;
TaskManagerSettings.SortColumn = 1;
TaskManagerSettings.SortAscending = TRUE;
// Performance page settings
TaskManagerSettings.CPUHistory_OneGraphPerCPU = TRUE;
TaskManagerSettings.ShowKernelTimes = FALSE;
*/
// Open the key
if (RegOpenKeyEx(HKEY_CURRENT_USER, szSubKey, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
return;
// Read the settings
// dwSize = sizeof(TASKMANAGER_SETTINGS);
// RegQueryValueEx(hKey, "Preferences", NULL, NULL, (LPBYTE)&TaskManagerSettings, &dwSize);
// Close the key
RegCloseKey(hKey);
}
void SaveSettings(void)
{
HKEY hKey;
char szSubKey1[] = "Software";
char szSubKey2[] = "Software\\ReactWare";
char szSubKey3[] = "Software\\ReactWare\\FileManager";
// Open (or create) the key
hKey = NULL;
RegCreateKeyEx(HKEY_CURRENT_USER, szSubKey1, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL);
RegCloseKey(hKey);
hKey = NULL;
RegCreateKeyEx(HKEY_CURRENT_USER, szSubKey2, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL);
RegCloseKey(hKey);
hKey = NULL;
if (RegCreateKeyEx(HKEY_CURRENT_USER, szSubKey3, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL) != ERROR_SUCCESS)
return;
// Save the settings
// RegSetValueEx(hKey, "Preferences", 0, REG_BINARY, (LPBYTE)&TaskManagerSettings, sizeof(TASKMANAGER_SETTINGS));
// Close the key
RegCloseKey(hKey);
}

View file

@ -54,6 +54,8 @@ extern DWORD ViewType;
extern TCHAR ViewTypeMaskStr[MAX_TYPE_MASK_LEN]; extern TCHAR ViewTypeMaskStr[MAX_TYPE_MASK_LEN];
//extern LPCTSTR lpViewTypeMaskStr; //extern LPCTSTR lpViewTypeMaskStr;
void LoadSettings(void);
void SaveSettings(void);
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -472,6 +472,14 @@ static LRESULT CALLBACK TreeWndProc(HWND hWnd, UINT message, WPARAM wParam, LPAR
child->nFocusPanel = pane == &child->right? 1: 0; child->nFocusPanel = pane == &child->right? 1: 0;
//ListBox_SetSel(hWnd, TRUE, 1); //ListBox_SetSel(hWnd, TRUE, 1);
//TODO: check menu items //TODO: check menu items
if (!child->nFocusPanel) {
int file_count = 50;
int files_size = 1115467;
TCHAR suffix[10];
TCHAR Text[260];
wsprintf(Text, _T("Total %d file(s) (%d%s)"), file_count, files_size, suffix);
SendMessage(Globals.hStatusBar, SB_SETTEXT, 2, (LPARAM)Text);
}
break; break;
case WM_KEYDOWN: case WM_KEYDOWN:
if (wParam == VK_TAB) { if (wParam == VK_TAB) {