implement switching of file sort order
Modified: trunk/reactos/subsys/system/winefile/Sv.rc
Modified: trunk/reactos/subsys/system/winefile/cz.rc
Modified: trunk/reactos/subsys/system/winefile/de.rc
Modified: trunk/reactos/subsys/system/winefile/en.rc
Modified: trunk/reactos/subsys/system/winefile/es.rc
Modified: trunk/reactos/subsys/system/winefile/fr.rc
Modified: trunk/reactos/subsys/system/winefile/hu.rc
Modified: trunk/reactos/subsys/system/winefile/it.rc
Modified: trunk/reactos/subsys/system/winefile/nl.rc
Modified: trunk/reactos/subsys/system/winefile/pt.rc
Modified: trunk/reactos/subsys/system/winefile/resource.h
Modified: trunk/reactos/subsys/system/winefile/ru.rc
Modified: trunk/reactos/subsys/system/winefile/si.rc
Modified: trunk/reactos/subsys/system/winefile/winefile.c
Modified: trunk/reactos/subsys/system/winefile/zh.rc

Modified: trunk/reactos/subsys/system/winefile/Sv.rc
--- trunk/reactos/subsys/system/winefile/Sv.rc	2005-05-14 18:04:53 UTC (rev 15282)
+++ trunk/reactos/subsys/system/winefile/Sv.rc	2005-05-14 18:57:07 UTC (rev 15283)
@@ -93,10 +93,10 @@
 		MENUITEM "&Alla Fildetaljer" ,				ID_VIEW_ALL_ATTRIBUTES, CHECKED
 		MENUITEM "&Vissa detaljer..." ,			ID_VIEW_SELECTED_ATTRIBUTES
 		MENUITEM SEPARATOR
-        MENUITEM "&Sortera efter namn",               404
-        MENUITEM "Sortera efter t&yp",               405
-        MENUITEM "Sortera efter st&orlek",               406
-        MENUITEM "Sortera efter &datum",               407
+	MENUITEM "&Sortera efter namn", 	ID_VIEW_SORT_NAME
+	MENUITEM "Sortera efter t&yp",		ID_VIEW_SORT_TYPE
+	MENUITEM "Sortera efter st&orlek",	ID_VIEW_SORT_SIZE
+	MENUITEM "Sortera efter &datum",	ID_VIEW_SORT_DATE
         MENUITEM SEPARATOR
         MENUITEM "Sortera efter &...",                409
 	}

Modified: trunk/reactos/subsys/system/winefile/cz.rc
--- trunk/reactos/subsys/system/winefile/cz.rc	2005-05-14 18:04:53 UTC (rev 15282)
+++ trunk/reactos/subsys/system/winefile/cz.rc	2005-05-14 18:57:07 UTC (rev 15283)
@@ -92,10 +92,10 @@
 		MENUITEM "&Detaily vÜech soubor¨" ,				ID_VIEW_ALL_ATTRIBUTES, CHECKED
 		MENUITEM "?ß&steÞnÚ detaily..." ,			ID_VIEW_SELECTED_ATTRIBUTES
 		MENUITEM SEPARATOR
-		MENUITEM "&T°Ýdit podle jmÚna" ,		404
-		MENUITEM "T°Ýdit &podle typu" ,		405
-		MENUITEM "T°Ýdit podle &velikosti" , 		406
-		MENUITEM "T°Ýdit podle &data" , 		407
+		MENUITEM "&T°Ýdit podle jmÚna" ,		ID_VIEW_SORT_NAME
+		MENUITEM "T°Ýdit &podle typu" ,			ID_VIEW_SORT_TYPE
+		MENUITEM "T°Ýdit podle &velikosti" , 		ID_VIEW_SORT_SIZE
+		MENUITEM "T°Ýdit podle &data" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
 		MENUITEM "T°Ýdit podle &..." ,			409
 	}

Modified: trunk/reactos/subsys/system/winefile/de.rc
--- trunk/reactos/subsys/system/winefile/de.rc	2005-05-14 18:04:53 UTC (rev 15282)
+++ trunk/reactos/subsys/system/winefile/de.rc	2005-05-14 18:57:07 UTC (rev 15283)
@@ -91,10 +91,10 @@
 		MENUITEM "A&lle Dateiangaben" ,				ID_VIEW_ALL_ATTRIBUTES, CHECKED
 		MENUITEM "&Bestimmte Dateiangaben..." ,			ID_VIEW_SELECTED_ATTRIBUTES
 		MENUITEM SEPARATOR
-		MENUITEM "Nach N&ame" ,		404
-		MENUITEM "Nach T&yp" ,		405
-		MENUITEM "Nach &Gr÷?e" , 		406
-		MENUITEM "Nach &Datum" , 		407
+		MENUITEM "Nach N&ame" ,		ID_VIEW_SORT_NAME
+		MENUITEM "Nach T&yp" ,		ID_VIEW_SORT_TYPE
+		MENUITEM "Nach &Gr÷?e" , 	ID_VIEW_SORT_SIZE
+		MENUITEM "Nach &Datum" , 	ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
 		MENUITEM "Angaben ausw&õhlen..." ,			409
 	}

Modified: trunk/reactos/subsys/system/winefile/en.rc
--- trunk/reactos/subsys/system/winefile/en.rc	2005-05-14 18:04:53 UTC (rev 15282)
+++ trunk/reactos/subsys/system/winefile/en.rc	2005-05-14 18:57:07 UTC (rev 15283)
@@ -94,12 +94,12 @@
 		MENUITEM "&All File Details" ,				ID_VIEW_ALL_ATTRIBUTES, CHECKED
 		MENUITEM "&Partial Details..." ,			ID_VIEW_SELECTED_ATTRIBUTES
 		MENUITEM SEPARATOR
-		MENUITEM "&Sort by Name" ,		404
-		MENUITEM "Sort &by Type" ,		405
-		MENUITEM "Sort by Si&ze" , 		406
-		MENUITEM "Sort by &Date" , 		407
+		MENUITEM "&Sort by Name" ,		ID_VIEW_SORT_NAME
+		MENUITEM "Sort &by Type" ,		ID_VIEW_SORT_TYPE
+		MENUITEM "Sort by Si&ze" , 		ID_VIEW_SORT_SIZE
+		MENUITEM "Sort by &Date" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
-		MENUITEM "Sort by &..." ,			409
+		MENUITEM "Filter by &..." ,			409
 	}
 
 	POPUP "&Options"  {

Modified: trunk/reactos/subsys/system/winefile/es.rc
--- trunk/reactos/subsys/system/winefile/es.rc	2005-05-14 18:04:53 UTC (rev 15282)
+++ trunk/reactos/subsys/system/winefile/es.rc	2005-05-14 18:57:07 UTC (rev 15283)
@@ -90,10 +90,10 @@
 		MENUITEM "T&odos los detalles" ,	ID_VIEW_ALL_ATTRIBUTES, CHECKED
 		MENUITEM "Detalles &parciales..." ,	ID_VIEW_SELECTED_ATTRIBUTES
 		MENUITEM SEPARATOR
-		MENUITEM "Ordenar por &nombre" ,		404
-		MENUITEM "Ordenar por &tipo" ,			405
-		MENUITEM "Ordenar por t&ama±o" , 		406
-		MENUITEM "Ordenar por &fecha" , 		407
+		MENUITEM "Ordenar por &nombre" ,		ID_VIEW_SORT_NAME
+		MENUITEM "Ordenar por &tipo" ,			ID_VIEW_SORT_TYPE
+		MENUITEM "Ordenar por t&ama±o" , 		ID_VIEW_SORT_SIZE
+		MENUITEM "Ordenar por &fecha" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
 		MENUITEM "Ordenar por &..." ,			409
 	}

Modified: trunk/reactos/subsys/system/winefile/fr.rc
--- trunk/reactos/subsys/system/winefile/fr.rc	2005-05-14 18:04:53 UTC (rev 15282)
+++ trunk/reactos/subsys/system/winefile/fr.rc	2005-05-14 18:57:07 UTC (rev 15283)
@@ -93,10 +93,10 @@
 		MENUITEM "Tous &les DÚtails" ,				ID_VIEW_ALL_ATTRIBUTES, CHECKED
 		MENUITEM "&DÚtails..." ,			ID_VIEW_SELECTED_ATTRIBUTES
 		MENUITEM SEPARATOR
-		MENUITEM "Trier par N&om" ,		404
-		MENUITEM "Trier par &Type" ,		405
-		MENUITEM "Trier par Ta&ille" , 		406
-		MENUITEM "Trier par Dat&e" , 		407
+		MENUITEM "Trier par N&om" ,		ID_VIEW_SORT_NAME
+		MENUITEM "Trier par &Type" ,		ID_VIEW_SORT_TYPE
+		MENUITEM "Trier par Ta&ille" , 		ID_VIEW_SORT_SIZE
+		MENUITEM "Trier par Dat&e" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
 		MENUITEM "Trier par &..." ,			409
 	}

Modified: trunk/reactos/subsys/system/winefile/hu.rc
--- trunk/reactos/subsys/system/winefile/hu.rc	2005-05-14 18:04:53 UTC (rev 15282)
+++ trunk/reactos/subsys/system/winefile/hu.rc	2005-05-14 18:57:07 UTC (rev 15283)
@@ -93,10 +93,10 @@
 		MENUITEM "&Minden rÚszlet" ,				ID_VIEW_ALL_ATTRIBUTES, CHECKED
 		MENUITEM "&Egyedi..." ,			ID_VIEW_SELECTED_ATTRIBUTES
 		MENUITEM SEPARATOR
-		MENUITEM "&RendezÚs nÚv szerint" ,		404
-		MENUITEM "RendezÚs k&iterjesztÚs szerint" ,		405
-		MENUITEM "RendezÚs &mÚret szerint" , 		406
-		MENUITEM "RendezÚs &dßtum szerint" , 		407
+		MENUITEM "&RendezÚs nÚv szerint" ,		ID_VIEW_SORT_NAME
+		MENUITEM "RendezÚs k&iterjesztÚs szerint" ,	ID_VIEW_SORT_TYPE
+		MENUITEM "RendezÚs &mÚret szerint" , 		ID_VIEW_SORT_SIZE
+		MENUITEM "RendezÚs &dßtum szerint" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
 		MENUITEM "Egyedi rendezÚs &..." ,			409
 	}

Modified: trunk/reactos/subsys/system/winefile/it.rc
--- trunk/reactos/subsys/system/winefile/it.rc	2005-05-14 18:04:53 UTC (rev 15282)
+++ trunk/reactos/subsys/system/winefile/it.rc	2005-05-14 18:57:07 UTC (rev 15283)
@@ -93,10 +93,10 @@
 		MENUITEM "&Mostra tutti i dettagli sui file" ,				ID_VIEW_ALL_ATTRIBUTES, CHECKED
 		MENUITEM "&Mostra dettagli parziali..." ,			ID_VIEW_SELECTED_ATTRIBUTES
 		MENUITEM SEPARATOR
-		MENUITEM "&Ordina per Nome" ,		404
-		MENUITEM "&Ordina per Tipo" ,		405
-		MENUITEM "&Ordina per Dimensione" , 		406
-		MENUITEM "&Ordina per Data" , 		407
+		MENUITEM "&Ordina per Nome" ,		ID_VIEW_SORT_NAME
+		MENUITEM "&Ordina per Tipo" ,		ID_VIEW_SORT_TYPE
+		MENUITEM "&Ordina per Dimensione" , 	ID_VIEW_SORT_SIZE
+		MENUITEM "&Ordina per Data" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
 		MENUITEM "Ordina per &..." ,			409
 	}

Modified: trunk/reactos/subsys/system/winefile/nl.rc
--- trunk/reactos/subsys/system/winefile/nl.rc	2005-05-14 18:04:53 UTC (rev 15282)
+++ trunk/reactos/subsys/system/winefile/nl.rc	2005-05-14 18:57:07 UTC (rev 15283)
@@ -89,10 +89,10 @@
 		MENUITEM "&Alle details" ,             ID_VIEW_ALL_ATTRIBUTES, CHECKED
 		MENUITEM "&Gedeeltelijke details..." , ID_VIEW_SELECTED_ATTRIBUTES
 		MENUITEM SEPARATOR
-		MENUITEM "Sorteer op &naam" ,    404
-		MENUITEM "Sorteer op &type" ,    405
-		MENUITEM "Sorteer op &grootte" , 406
-		MENUITEM "Sorteer op &datum" ,   407
+		MENUITEM "Sorteer op &naam" ,    ID_VIEW_SORT_NAME
+		MENUITEM "Sorteer op &type" ,    ID_VIEW_SORT_TYPE
+		MENUITEM "Sorteer op &grootte" , ID_VIEW_SORT_SIZE
+		MENUITEM "Sorteer op &datum" ,   ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
 		MENUITEM "Sorteer op &..." ,     409
 	}

Modified: trunk/reactos/subsys/system/winefile/pt.rc
--- trunk/reactos/subsys/system/winefile/pt.rc	2005-05-14 18:04:53 UTC (rev 15282)
+++ trunk/reactos/subsys/system/winefile/pt.rc	2005-05-14 18:57:07 UTC (rev 15283)
@@ -92,10 +92,10 @@
 		MENUITEM "&Todos os delalhes" ,				ID_VIEW_ALL_ATTRIBUTES, CHECKED
 		MENUITEM "D&etalhes parciais..." ,			ID_VIEW_SELECTED_ATTRIBUTES
 		MENUITEM SEPARATOR
-		MENUITEM "&Classificar por nome" ,		404
-		MENUITEM "C&lassificar por tipo" ,		405
-		MENUITEM "Cl&assificar por tamanho" , 		406
-		MENUITEM "Cla&ssificar por &data" , 		407
+		MENUITEM "&Classificar por nome" ,		ID_VIEW_SORT_NAME
+		MENUITEM "C&lassificar por tipo" ,		ID_VIEW_SORT_TYPE
+		MENUITEM "Cl&assificar por tamanho" , 		ID_VIEW_SORT_SIZE
+		MENUITEM "Cla&ssificar por &data" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
 		MENUITEM "Classificar &por..." ,			409
 	}
@@ -220,10 +220,10 @@
 		MENUITEM "&Todos os delalhes" ,				ID_VIEW_ALL_ATTRIBUTES, CHECKED
 		MENUITEM "D&etalhes parciais..." ,			ID_VIEW_SELECTED_ATTRIBUTES
 		MENUITEM SEPARATOR
-		MENUITEM "&Classificar por nome" ,		404
-		MENUITEM "C&lassificar por tipo" ,		405
-		MENUITEM "Cl&assificar por tamanho" , 		406
-		MENUITEM "Cla&ssificar por &data" , 		407
+		MENUITEM "&Classificar por nome" ,		ID_VIEW_SORT_NAME
+		MENUITEM "C&lassificar por tipo" ,		ID_VIEW_SORT_TYPE
+		MENUITEM "Cl&assificar por tamanho" , 		ID_VIEW_SORT_SIZE
+		MENUITEM "Cla&ssificar por &data" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
 		MENUITEM "Classificar &por..." ,			409
 	}

Modified: trunk/reactos/subsys/system/winefile/resource.h
--- trunk/reactos/subsys/system/winefile/resource.h	2005-05-14 18:04:53 UTC (rev 15282)
+++ trunk/reactos/subsys/system/winefile/resource.h	2005-05-14 18:57:07 UTC (rev 15283)
@@ -49,6 +49,10 @@
 #define ID_VIEW_NAME					401
 #define ID_VIEW_ALL_ATTRIBUTES			402
 #define ID_VIEW_SELECTED_ATTRIBUTES		403
+#define	ID_VIEW_SORT_NAME				404
+#define	ID_VIEW_SORT_TYPE				405
+#define	ID_VIEW_SORT_SIZE				406
+#define	ID_VIEW_SORT_DATE				407
 #define ID_SELECT_FONT					510
 #define ID_VIEW_TOOL_BAR				508
 #define ID_VIEW_DRIVE_BAR				507

Modified: trunk/reactos/subsys/system/winefile/ru.rc
--- trunk/reactos/subsys/system/winefile/ru.rc	2005-05-14 18:04:53 UTC (rev 15282)
+++ trunk/reactos/subsys/system/winefile/ru.rc	2005-05-14 18:57:07 UTC (rev 15283)
@@ -89,10 +89,10 @@
 		MENUITEM "?&±Õ ´¯õ­¯ßݯ±?Þ ¯ ¶ÓÚÙÕ" ,				ID_VIEW_ALL_ATTRIBUTES, CHECKED
 		MENUITEM "&?¹ß¯­¯¸Ý¯ ¯ ¶ÓÚÙÕ..." ,			ID_VIEW_SELECTED_ATTRIBUTES
 		MENUITEM SEPARATOR
-		MENUITEM "&Я­?Þ­¯ÔÓ?³ ´¯ ÞýÕÝÞ" ,		404
-		MENUITEM "Я­?Þ­¯ÔÓ?³ ´¯ &?Þ´¾" ,		405
-		MENUITEM "Я­?Þ­¯ÔÓ?³ ´¯ &­ÓþýÕ­¾" , 		406
-		MENUITEM "Я­?Þ­¯ÔÓ?³ ´¯ õ&Ó?Õ" , 		407
+		MENUITEM "&Я­?Þ­¯ÔÓ?³ ´¯ ÞýÕÝÞ" ,		ID_VIEW_SORT_NAME
+		MENUITEM "Я­?Þ­¯ÔÓ?³ ´¯ &?Þ´¾" ,		ID_VIEW_SORT_TYPE
+		MENUITEM "Я­?Þ­¯ÔÓ?³ ´¯ &­ÓþýÕ­¾" , 		ID_VIEW_SORT_SIZE
+		MENUITEM "Я­?Þ­¯ÔÓ?³ ´¯ õ&Ó?Õ" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
 		MENUITEM "Я­?Þ­¯ÔÓ?³ ´¯ &..." ,			409
 	}

Modified: trunk/reactos/subsys/system/winefile/si.rc
--- trunk/reactos/subsys/system/winefile/si.rc	2005-05-14 18:04:53 UTC (rev 15282)
+++ trunk/reactos/subsys/system/winefile/si.rc	2005-05-14 18:57:07 UTC (rev 15283)
@@ -90,12 +90,12 @@
 		MENUITEM "&All File Details" ,				ID_VIEW_ALL_ATTRIBUTES, CHECKED
 		MENUITEM "&Partial Details..." ,			ID_VIEW_SELECTED_ATTRIBUTES
 		MENUITEM SEPARATOR
-		MENUITEM "&Sort by Name" ,		404
-		MENUITEM "Sort &by Type" ,		405
-		MENUITEM "Sort by Si&ze" , 		406
-		MENUITEM "Sort by &Date" , 		407
+		MENUITEM "&Sort by Name" ,		ID_VIEW_SORT_NAME
+		MENUITEM "Sort &by Type" ,		ID_VIEW_SORT_TYPE
+		MENUITEM "Sort by Si&ze" , 		ID_VIEW_SORT_SIZE
+		MENUITEM "Sort by &Date" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
-		MENUITEM "Sort by &..." ,			409
+		MENUITEM "Filter by &..." ,			409
 	}
 
 	POPUP "&Options"  {

Modified: trunk/reactos/subsys/system/winefile/winefile.c
--- trunk/reactos/subsys/system/winefile/winefile.c	2005-05-14 18:04:53 UTC (rev 15282)
+++ trunk/reactos/subsys/system/winefile/winefile.c	2005-05-14 18:57:07 UTC (rev 15283)
@@ -200,7 +200,8 @@
 
 
 static void read_directory(Entry* dir, LPCTSTR path, SORT_ORDER sortOrder, HWND hwnd);
-static void set_curdir(ChildWnd* child, Entry* entry, HWND hwnd);
+static void set_curdir(ChildWnd* child, Entry* entry, int idx, HWND hwnd);
+static void refresh_child(ChildWnd* child);
 static void get_path(Entry* dir, PTSTR path);
 
 LRESULT CALLBACK FrameWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam);
@@ -1319,10 +1320,57 @@
 }
 
 
-static ChildWnd* alloc_child_window(LPCTSTR path, LPITEMIDLIST pidl, HWND hwnd)
+static Entry* read_tree(Root* root, LPCTSTR path, LPITEMIDLIST pidl, LPTSTR drv, SORT_ORDER sortOrder, HWND hwnd)
 {
 	const static TCHAR sBackslash[] = {'\\', '\0'};
+
+#ifdef _SHELL_FOLDERS
+	if (pidl)
+	{
+		 /* read shell namespace tree */
+		root->drive_type = DRIVE_UNKNOWN;
+		drv[0] = '\\';
+		drv[1] = '\0';
+		load_string(root->volname, IDS_DESKTOP);
+		root->fs_flags = 0;
+		load_string(root->fs, IDS_SHELL);
+
+		return read_tree_shell(root, pidl, sortOrder, hwnd);
+	}
+	else
+#endif
 #if !defined(_NO_EXTENSIONS) && defined(__WINE__)
+	if (*path == '/')
+	{
+		 /* read unix file system tree */
+		root->drive_type = GetDriveType(path);
+
+		lstrcat(drv, sSlash);
+		load_string(root->volname, IDS_ROOT_FS);
+		root->fs_flags = 0;
+		load_string(root->fs, IDS_UNIXFS);
+
+		lstrcpy(root->path, sSlash);
+
+		return read_tree_unix(root, path, sortOrder, hwnd);
+	}
+#endif
+
+	 /* read WIN32 file system tree */
+	root->drive_type = GetDriveType(path);
+
+	lstrcat(drv, sBackslash);
+	GetVolumeInformation(drv, root->volname, _MAX_FNAME, 0, 0, &root->fs_flags, root->fs, _MAX_DIR);
+
+	lstrcpy(root->path, drv);
+
+	return read_tree_win(root, path, sortOrder, hwnd);
+}
+
+
+static ChildWnd* alloc_child_window(LPCTSTR path, LPITEMIDLIST pidl, HWND hwnd)
+{
+#if !defined(_NO_EXTENSIONS) && defined(__WINE__)
 	const static TCHAR sSlash[] = {'/', '\0'};
 #endif
 
@@ -1367,45 +1415,8 @@
 
 	root->entry.level = 0;
 
-#ifdef _SHELL_FOLDERS
-	if (pidl)
-	{
-		root->drive_type = DRIVE_UNKNOWN;
-		drv[0] = '\\';
-		drv[1] = '\0';
-		load_string(root->volname, IDS_DESKTOP);
-		root->fs_flags = 0;
-		load_string(root->fs, IDS_SHELL);
+	entry = read_tree(root, path, pidl, drv, child->sortOrder, hwnd);
 
-		entry = read_tree_shell(root, pidl, child->sortOrder, hwnd);
-	}
-	else
-#endif
-#if !defined(_NO_EXTENSIONS) && defined(__WINE__)
-	if (*path == '/')
-	{
-		root->drive_type = GetDriveType(path);
-
-		lstrcat(drv, sSlash);
-		load_string(root->volname, IDS_ROOT_FS);
-		root->fs_flags = 0;
-		load_string(root->fs, IDS_UNIXFS);
-
-		lstrcpy(root->path, sSlash);
-		entry = read_tree_unix(root, path, child->sortOrder, hwnd);
-	}
-	else
-#endif
-	{
-		root->drive_type = GetDriveType(path);
-
-		lstrcat(drv, sBackslash);
-		GetVolumeInformation(drv, root->volname, _MAX_FNAME, 0, 0, &root->fs_flags, root->fs, _MAX_DIR);
-
-		lstrcpy(root->path, drv);
-		entry = read_tree_win(root, path, child->sortOrder, hwnd);
-	}
-
 #ifdef _SHELL_FOLDERS
 	if (root->entry.etype == ET_SHELL)
 		load_string(root->entry.data.cFileName, IDS_DESKTOP);
@@ -1418,7 +1429,7 @@
 	child->left.root = &root->entry;
 	child->right.root = NULL;
 
-	set_curdir(child, entry, hwnd);
+	set_curdir(child, entry, 0, hwnd);
 
 	return child;
 }
@@ -1610,7 +1621,8 @@
 
 	ListBox_SetItemHeight(child->left.hwnd, 1, max(Globals.spaceSize.cy,IMAGE_HEIGHT+3));
 	ListBox_SetItemHeight(child->right.hwnd, 1, max(Globals.spaceSize.cy,IMAGE_HEIGHT+3));
-	idx = ListBox_FindItemData(child->left.hwnd, ListBox_GetCurSel(child->left.hwnd), child->left.cur);
+
+	idx = ListBox_FindItemData(child->left.hwnd, 0, child->left.cur);
 	ListBox_SetCurSel(child->left.hwnd, idx);
 
 	return child->hwnd;
@@ -1873,6 +1885,13 @@
 				PostQuitMessage(0);
 			break;
 
+		case WM_INITMENUPOPUP: {
+			HWND hwndClient = (HWND) SendMessage(Globals.hmdiclient, WM_MDIGETACTIVE, 0, 0);
+
+			if (!SendMessage(hwndClient, WM_INITMENUPOPUP, wparam, lparam))
+				return 0;
+			break;}
+
 		case WM_COMMAND: {
 			UINT cmd = LOWORD(wparam);
 			HWND hwndClient = (HWND) SendMessage(Globals.hmdiclient, WM_MDIGETACTIVE, 0, 0);
@@ -3188,10 +3207,9 @@
 #endif /* _NO_EXTENSIONS */
 
 
-static void scan_entry(ChildWnd* child, Entry* entry, HWND hwnd)
+static void scan_entry(ChildWnd* child, Entry* entry, int idx, HWND hwnd)
 {
 	TCHAR path[MAX_PATH];
-	int idx = ListBox_GetCurSel(child->left.hwnd);
 	HCURSOR old_cursor = SetCursor(LoadCursor(0, IDC_WAIT));
 
 	/* delete sub entries in left pane */
@@ -3305,7 +3323,7 @@
 }
 
 
-static void set_curdir(ChildWnd* child, Entry* entry, HWND hwnd)
+static void set_curdir(ChildWnd* child, Entry* entry, int idx, HWND hwnd)
 {
 	TCHAR path[MAX_PATH];
 
@@ -3316,7 +3334,7 @@
 	child->right.cur = entry;
 
 	if (!entry->scanned)
-		scan_entry(child, entry, hwnd);
+		scan_entry(child, entry, idx, hwnd);
 	else {
 		ListBox_ResetContent(child->right.hwnd);
 		insert_entries(&child->right, entry->down, -1);
@@ -3338,6 +3356,30 @@
 }
 
 
+static void refresh_child(ChildWnd* child)
+{
+	TCHAR path[MAX_PATH], drv[_MAX_DRIVE+1];
+	Entry* entry;
+	int idx;
+
+	get_path(child->left.cur, path);
+	_tsplitpath(path, drv, NULL, NULL, NULL);
+
+	child->right.root = NULL;
+
+	scan_entry(child, &child->root.entry, 0, child->hwnd);
+
+	entry = read_tree(&child->root, path, NULL, drv, child->sortOrder, child->hwnd);
+
+	insert_entries(&child->left, child->root.entry.down, 0);
+
+	set_curdir(child, entry, 0, child->hwnd);
+
+	idx = ListBox_FindItemData(child->left.hwnd, 0, child->left.cur);
+	ListBox_SetCurSel(child->left.hwnd, idx);
+}
+
+
 BOOL launch_file(HWND hwnd, LPCTSTR cmd, UINT nCmdShow)
 {
 	HINSTANCE hinst = ShellExecute(hwnd, NULL/*operation*/, cmd, NULL/*parameters*/, NULL/*dir*/, nCmdShow);
@@ -3415,7 +3457,7 @@
 		int scanned_old = entry->scanned;
 
 		if (!scanned_old)
-			scan_entry(child, entry, hwnd);
+			scan_entry(child, entry, ListBox_GetCurSel(child->left.hwnd), hwnd);
 
 #ifndef _NO_EXTENSIONS
 		if (entry->data.cFileName[0]=='.' && entry->data.cFileName[1]=='\0')
@@ -3434,7 +3476,7 @@
 			if (!pane->treePane) focus_entry: {
 				int idx = ListBox_FindItemData(child->left.hwnd, ListBox_GetCurSel(child->left.hwnd), entry);
 				ListBox_SetCurSel(child->left.hwnd, idx);
-				set_curdir(child, entry, hwnd);
+				set_curdir(child, entry, idx, hwnd);
 			}
 		}
 
@@ -3500,6 +3542,23 @@
 }
 
 
+static void set_sort_order(ChildWnd* child, SORT_ORDER sortOrder)
+{
+	if (child->sortOrder != sortOrder) {
+		child->sortOrder = sortOrder;
+		refresh_child(child);
+	}
+}
+
+static void update_view_menu(ChildWnd* child)
+{
+	CheckMenuItem(Globals.hMenuView, ID_VIEW_SORT_NAME, child->sortOrder==SORT_NAME? MF_CHECKED: MF_UNCHECKED);
+	CheckMenuItem(Globals.hMenuView, ID_VIEW_SORT_TYPE, child->sortOrder==SORT_EXT? MF_CHECKED: MF_UNCHECKED);
+	CheckMenuItem(Globals.hMenuView, ID_VIEW_SORT_SIZE, child->sortOrder==SORT_SIZE? MF_CHECKED: MF_UNCHECKED);
+	CheckMenuItem(Globals.hMenuView, ID_VIEW_SORT_DATE, child->sortOrder==SORT_DATE? MF_CHECKED: MF_UNCHECKED);
+}
+
+
 static IContextMenu2* s_pctxmenu2 = NULL;
 
 #ifndef __MINGW32__	/* IContextMenu3 missing in MinGW (as of 6.2.2005) */
@@ -3781,7 +3840,7 @@
 					break;}
 
 				case ID_REFRESH:
-					scan_entry(child, pane->cur, hwnd);
+					refresh_child(child);
 					break;
 
 				case ID_ACTIVATE:
@@ -3818,12 +3877,28 @@
 							activate_entry(child, pane, hwnd);
 						}
 						else
-							scan_entry(child, pane->root, hwnd);
+							refresh_child(child);
 					}
 					else
 						display_error(hwnd, GetLastError());
 					break;}
 
+				case ID_VIEW_SORT_NAME:
+					set_sort_order(child, SORT_NAME);
+					break;
+
+				case ID_VIEW_SORT_TYPE:
+					set_sort_order(child, SORT_EXT);
+					break;
+
+				case ID_VIEW_SORT_SIZE:
+					set_sort_order(child, SORT_SIZE);
+					break;
+
+				case ID_VIEW_SORT_DATE:
+					set_sort_order(child, SORT_DATE);
+					break;
+
 				default:
 					return pane_command(pane, LOWORD(wparam));
 			}
@@ -3839,7 +3914,7 @@
 					Entry* entry = (Entry*) ListBox_GetItemData(pane->hwnd, idx);
 
 					if (pane == &child->left)
-						set_curdir(child, entry, hwnd);
+						set_curdir(child, entry, idx, hwnd);
 					else
 						pane->cur = entry;
 					break;}
@@ -3909,6 +3984,7 @@
 			if (CtxMenu_HandleMenuMsg(nmsg, wparam, lparam))
 				return 0;
 
+			update_view_menu(child);
 			break;
 
 #ifndef __MINGW32__	/* IContextMenu3 missing in MinGW (as of 6.2.2005) */

Modified: trunk/reactos/subsys/system/winefile/zh.rc
--- trunk/reactos/subsys/system/winefile/zh.rc	2005-05-14 18:04:53 UTC (rev 15282)
+++ trunk/reactos/subsys/system/winefile/zh.rc	2005-05-14 18:57:07 UTC (rev 15283)
@@ -90,10 +90,10 @@
 		MENUITEM "????¤Û¤ñ?ð?Ýú¿&Aú®" ,				ID_VIEW_ALL_ATTRIBUTES, CHECKED
 		MENUITEM "??ÀÍ?¶ðÈú¿&Pú®..." ,			ID_VIEW_SELECTED_ATTRIBUTES
 		MENUITEM SEPARATOR
-		MENUITEM "???????¹??ð?ú¿&Sú®" ,		404
-		MENUITEM "???Óð???ð?ú¿&Bú®" ,		405
-		MENUITEM "???¾ðí??ð?ú¿&Zú®" , 		406
-		MENUITEM "???iã???ð?ú¿&Dú®" , 		407
+		MENUITEM "???????¹??ð?ú¿&Sú®" ,		ID_VIEW_SORT_NAME
+		MENUITEM "???Óð???ð?ú¿&Bú®" ,		ID_VIEW_SORT_TYPE
+		MENUITEM "???¾ðí??ð?ú¿&Zú®" , 		ID_VIEW_SORT_SIZE
+		MENUITEM "???iã???ð?ú¿&Dú®" , 		ID_VIEW_SORT_DATE
 		MENUITEM SEPARATOR
 		MENUITEM "¿Íã??ð?..." ,			409
 	}