Release 970101

Wed Jan  1 15:36:17 1997  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [controls/listbox.c]
	Use FindFirstFile/FindNextFile in LISTBOX_Directory.

	* [files/dos_fs.c]
	Rewrote FindFirstFile/FindNextFile to use DOSFS_FindNext().

	* [files/file.c] [files/directory.c]
	Use Win32 kernel objects and handles for file handles.
	Unified SearchPath() and OpenFile().

	* [loader/builtin.c]
	Moved to if1632/ directory.

	* [tools/build.c] [debugger/*] [miscemu/*]
	Win16 register functions now receive the same CONTEXT * structure
	as Win32 functions.

	* [include/sigcontext.h] [miscemu/instr.c]
	Added new macros to get register values from the SIGCONTEXT
	structure (only used for instruction emulation now).

	* [scheduler/process.c] [scheduler/thread.c] (New files)
	Allocate process and thread structures.

	* [scheduler/process.c] [win32/k32obj.c]
	Added Win32 kernel objects and handles management.

	* [loader/task.c]
	Create a Win32 process and thread for every Win16 task.

	* [misc/commdlg.c] [misc/shell.c] [windows/msgbox.c]
	Built-in resources are now in Win32 format. This also avoids
	16-bit callbacks for built-in dialogs.

	* [misc/lzexpand.c]
	Differentiate between 16-bit and 32-bit file handles.

	* [miscemu/int*.c]
	Moved all int emulation to msdos/ directory.

	* [msdos/*]
	New directory msdos/ contains all MS-DOS emulation code that can
	also be used for Winelib; this should enable Winelib apps to use
	DOS3Call and related functions.

	* [rc/winerc.c]
	A few bug fixes for Win32 resource format.

	* [windows/winpos.c]
	Hack in WINPOS_ReorderOwnerPopups() to avoid X crashed (still not
	right though).

Sun Dec 29 17:47:55 1996  O. Flebbe <flebbe@science-computing.uni-tuebingen.de>

	* [loader/pe_image.c]
	Make sure BSS of a PE_Image is zero.

Sat Dec 28 22:15:34 1996 Alex Korobka <alex@trantor.pharm.sunysb.edu>

	* [windows/scroll.c]
	ScrollWindowEx() rewrite, ScrollDC() fix.

	* [windows/nonclient.c] [controls/menu.c]
	Fixed Alt-Space crashes in dialogs.

	* [windows/event.c] [windows/message.c]
	Some changes in mouse message generation.

Thu Dec 26 09:25:24 1996  Philippe De Muyter  <phdm@info.ucl.ac.be>

	* [debugger/stabs.c]
	Dummy DEBUG_ReadExecutableDbgInfo provided for !__ELF__ case.

Tue Dec 24 00:59:05 MET 1996  Martin Buck <martin-2.buck@student.uni-ulm.de>

	* [windows/event.c]
	Changed XK_Page_{Up,Down} to XK_{Prior,Next} for X11R5
	compatibility.
diff --git a/controls/listbox.c b/controls/listbox.c
index ceed8b2..70f13b3 100644
--- a/controls/listbox.c
+++ b/controls/listbox.c
@@ -8,9 +8,8 @@
 #include <string.h>
 #include <stdio.h>
 #include "windows.h"
+#include "winerror.h"
 #include "drive.h"
-#include "dos_fs.h"
-#include "msdos.h"
 #include "heap.h"
 #include "spy.h"
 #include "win.h"
@@ -478,7 +477,7 @@
             else
                 SetTextColor( hdc, GetSysColor( COLOR_WINDOWTEXT ) );
         }
-        dprintf_listbox( stddeb, "Listbox %04x: painting %d (%s) action=%02x"
+        dprintf_listbox( stddeb, "Listbox %04x: painting %d (%s) action=%02x "
                          "rect=%d,%d-%d,%d\n",
                          wnd->hwndSelf, index, item ? item->str : "", action,
                          rect->left, rect->top, rect->right, rect->bottom );
@@ -1455,55 +1454,45 @@
 LRESULT LISTBOX_Directory( WND *wnd, LB_DESCR *descr, UINT32 attrib,
                            LPCSTR filespec, BOOL32 long_names )
 {
-    char mask[13];
-    const char *ptr;
-    char *path, *p;
-    int count, skip, pos;
-    LRESULT ret;
-    DOS_DIRENT entry;
+    HANDLE32 handle;
+    LRESULT ret = LB_OKAY;
+    WIN32_FIND_DATA32A entry;
+    int pos;
 
-    /* FIXME: should use FindFirstFile/FindNextFile */
-
-    if (!filespec) return LB_ERR;
-    if (!(ptr = DOSFS_GetUnixFileName( filespec, FALSE ))) return LB_ERR;
-    path = HEAP_strdupA( SystemHeap, 0, ptr );
-    p = strrchr( path, '/' );
-    *p++ = '\0';
-    if (!(ptr = DOSFS_ToDosFCBFormat( p )))
+    if ((handle = FindFirstFile32A(filespec,&entry)) == INVALID_HANDLE_VALUE32)
     {
-        HeapFree( SystemHeap, 0, path );
-        return LB_ERR;
+        if (GetLastError() != ERROR_NO_MORE_FILES) return LB_ERR;
     }
-    strcpy( mask, ptr );
-
-    skip = 0;
-    ret = LB_OKAY;
-    attrib &= ~FA_LABEL;
-    while ((count = DOSFS_FindNext( path, mask, NULL, 0,
-                                    attrib, skip, &entry )) > 0)
+    else
     {
-        char buffer[260];
-        skip += count;
-        if (entry.attr & FA_DIRECTORY)
+        do
         {
-            if (!(attrib & DDL_DIRECTORY) || !strcmp(entry.name,".          "))
-                continue;
-            if (long_names) sprintf( buffer, "[%s]", entry.unixname );
-            else sprintf( buffer, "[%s]", DOSFS_ToDosDTAFormat( entry.name ) );
-        }
-        else  /* not a directory */
-        {
-            if ((attrib & DDL_EXCLUSIVE) &&
-                ((attrib & (FA_RDONLY|FA_HIDDEN|FA_SYSTEM|FA_ARCHIVE)) !=
-                 (entry.attr & (FA_RDONLY|FA_HIDDEN|FA_SYSTEM|FA_ARCHIVE))))
-                continue;
-            if (long_names) strcpy( buffer, entry.unixname );
-            else strcpy( buffer, DOSFS_ToDosDTAFormat( entry.name ) );
-        }
-        if (!long_names) AnsiLower( buffer );
-        pos = LISTBOX_FindFileStrPos( wnd, descr, buffer );
-        if ((ret = LISTBOX_InsertString( wnd, descr, pos, buffer )) < 0)
-            break;
+            char buffer[270];
+            if (entry.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+            {
+                if (!(attrib & DDL_DIRECTORY) ||
+                    !strcmp( entry.cAlternateFileName, "." )) continue;
+                if (long_names) sprintf( buffer, "[%s]", entry.cFileName );
+                else sprintf( buffer, "[%s]", entry.cAlternateFileName );
+            }
+            else  /* not a directory */
+            {
+#define ATTRIBS (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | \
+                 FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE)
+
+                if ((attrib & DDL_EXCLUSIVE) &&
+                    ((attrib & ATTRIBS) != (entry.dwFileAttributes & ATTRIBS)))
+                    continue;
+#undef ATTRIBS
+                if (long_names) strcpy( buffer, entry.cFileName );
+                else strcpy( buffer, entry.cAlternateFileName );
+            }
+            if (!long_names) AnsiLower( buffer );
+            pos = LISTBOX_FindFileStrPos( wnd, descr, buffer );
+            if ((ret = LISTBOX_InsertString( wnd, descr, pos, buffer )) < 0)
+                break;
+        } while (FindNextFile32A( handle, &entry ));
+        FindClose32( handle );
     }
 
     if ((ret == LB_OKAY) && (attrib & DDL_DRIVES))
@@ -1517,8 +1506,6 @@
                 break;
         }
     }
-
-    HeapFree( SystemHeap, 0, path );
     return ret;
 }
 
@@ -1744,6 +1731,7 @@
         break;
     case LB_TIMER_DOWN:
         index = descr->top_item + LISTBOX_GetCurrentPageSize( wnd, descr );
+        if (index == descr->focus_item) index++;
         if (index >= descr->nb_items) index = descr->nb_items - 1;
         break;
     case LB_TIMER_RIGHT: