Subject: Patch to fix bug#8181: 23.2; Dired on Windows 7
From: Ben Key <[email-masked]>
To: [email-masked], Juanma Barranquero <[email-masked]>
Date: Sun, 6 Mar 2011 22:15:51 -0600
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello,

The attached patch fixes bug #8181: 23.2; Dired on Windows 7.  The patch is
for the Emacs trunk.  I can provide a patch for the Emacs 23 branch if it is
decided that this bug is important enough to go into Emacs 23.

This patch has been tested on Windows 7 32-bit, Windows 7 64-bit, and
Windows XP 32-bit.

This patch fixes three problems.

   1. The code that was attempting to set the text of the file name text
   field when processing the CDN_INITDONE WM_NOTIFY message does not work.
   This is because the code that processes the lpstrFile member of the
   OPENFILENAME structure to set the initial value of the window is called
   after the CDN_INITDONE WM_NOTIFY message is processed.  The correct way
   to set the text of the file name text field to "Current Directory" is to
   set the initial value of the lpstrFile member of the OPENFILENAME
   structure to "Current Directory" in the only_dir_p case if it does not
   already have another value.
   2. The attempt to find the window handle of the file name text field
   failed, at least on Windows XP and Windows 7.  By using Microsoft Spy++ I
   was able to discover the correct way to obtain this Window handle.  I
   modified the code in file_dialog_callback that initializes the edit_control
   using this information.
   3. Disabling the file name text field during dialog box initialization
   has undesirable side effects because this is the window that has focus when
   the open file dialog box is first opened by default.  The end result of
   disabling a window that would otherwise have focus is that focus lands in no
   man's land and the user is not able to navigate through the dialog box using
   the tab key.  Instead the system plays the system default error sound every
   time the tab key was pressed.  Now that the window is actually being
   disabled as a result of change 2, it is necessary to take steps to prevent
   this from happening.  My solution was to set focus to the list box
if the file
   name text field is disabled during dialog box initialization.  This part
   could use a little more work.

If it matters, I have already signed the appropriate copyright assignment
papers for Emacs.