all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#8191: Patch to fix bug#8181: 23.2; Dired on Windows 7
@ 2011-03-07  4:15 Ben Key
  2011-03-07  5:37 ` bug#8181: " Juanma Barranquero
  0 siblings, 1 reply; 26+ messages in thread
From: Ben Key @ 2011-03-07  4:15 UTC (permalink / raw)
  To: 8191, lekktu


[-- Attachment #1.1: Type: text/plain, Size: 2198 bytes --]

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.

[-- Attachment #1.2: Type: text/html, Size: 2487 bytes --]

[-- Attachment #2: emacs-bug-8181.patch --]
[-- Type: application/octet-stream, Size: 3091 bytes --]

=== modified file 'src/w32fns.c'
--- src/w32fns.c	2011-02-16 18:39:46 +0000
+++ src/w32fns.c	2011-03-07 03:57:46 +0000
@@ -60,6 +60,8 @@
 #include <dlgs.h>
 #include <imm.h>
 #define FILE_NAME_TEXT_FIELD edt1
+#define FILE_NAME_COMBO_BOX cmb13
+#define FILE_NAME_LIST lst1
 
 #include "font.h"
 #include "w32font.h"
@@ -5868,6 +5870,26 @@
 	{
 	  HWND dialog = GetParent (hwnd);
 	  HWND edit_control = GetDlgItem (dialog, FILE_NAME_TEXT_FIELD);
+	  HWND list = GetDlgItem(dialog, FILE_NAME_LIST);
+	  if (NULL == edit_control)
+	    {
+	      /*
+	      At least on Windows 7, the above attempt to get the
+	      window handle to the File Name Text Field fails.  The
+	      following code does the job though.  Note that this
+	      code is based on my examination of the window hiearchy
+	      using Microsoft Spy++.
+	      */
+	      HWND tmp = GetDlgItem(dialog, FILE_NAME_COMBO_BOX);
+	      if (NULL != tmp)
+	        {
+	          tmp = GetWindow(tmp, GW_CHILD);
+	          if (NULL != tmp)
+	            {
+	              edit_control = GetWindow(tmp, GW_CHILD);
+	            }
+	        }
+	    }
 
 	  /* Directories is in index 2.  */
 	  if (notify->lpOFN->nFilterIndex == 2)
@@ -5875,6 +5897,20 @@
 	      CommDlg_OpenSave_SetControlText (dialog, FILE_NAME_TEXT_FIELD,
 					       "Current Directory");
 	      EnableWindow (edit_control, FALSE);
+	      if (CDN_INITDONE == notify->hdr.code)
+	        {
+	          /*
+	          Not that at least on Windows 7, the above call to
+	          EnableWindow disables the window that would
+	          ordinarily have focus.  If we do not set focus to
+	          some other window here, focus will land in no man's
+	          land and the user will be unable to tab through the
+	          dialog box (pressing tab will only result in a
+	          beep).  Avoid that problem by setting focus to the
+	          list here.
+	          */
+	          SetFocus(list);
+	        }
 	    }
 	  else
 	    {
@@ -5946,10 +5982,32 @@
 	file_name_only++;
 
       strncpy (filename, file_name_only, MAX_PATH);
+      if (0 == filename[0] && ! NILP(only_dir_p))
+        {
+          /*
+          The code in file_dialog_callback that attempts to set the text
+          of the file name edit window when handling the CDN_INITDONE
+          WM_NOTIFY message does not work.  Setting filename to "Current
+          Directory" in the only_dir_p case here does work however.
+          */
+          strcpy(filename, "Current Directory");
+	    }
       filename[MAX_PATH] = '\0';
     }
   else
-    filename[0] = '\0';
+    {
+      filename[0] = '\0';
+      if (! NILP (only_dir_p))
+        {
+          /*
+          The code in file_dialog_callback that attempts to set the text
+          of the file name edit window when handling the CDN_INITDONE
+          WM_NOTIFY message does not work.  Setting filename to "Current
+          Directory" in the only_dir_p case here does work however.
+          */
+          strcpy(filename, "Current Directory");
+        }
+    }
 
   {
     NEWOPENFILENAME new_file_details;


^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2011-03-08  2:24 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-07  4:15 bug#8191: Patch to fix bug#8181: 23.2; Dired on Windows 7 Ben Key
2011-03-07  5:37 ` bug#8181: " Juanma Barranquero
2011-03-07 15:56   ` Ben Key
2011-03-07 18:06     ` Juanma Barranquero
2011-03-07 19:54       ` Juanma Barranquero
2011-03-07 20:16         ` Chong Yidong
2011-03-07 20:24           ` Juanma Barranquero
2011-03-07 20:59             ` Chong Yidong
2011-03-07 21:17               ` Juanma Barranquero
2011-03-05 22:55                 ` Robert I. Eachus
2011-03-06  0:08                   ` Lennart Borgman
2011-03-06  0:40                     ` Robert I. Eachus
2011-03-06  0:42                       ` Lennart Borgman
2011-03-06  3:30                       ` Juanma Barranquero
2011-03-07 14:19                         ` Jason Rumney
2011-03-06 13:14                   ` Dani Moncayo
2011-03-06 14:17                     ` Eli Zaretskii
2011-03-06 16:04                   ` Ben Key
2011-03-06 20:28                     ` Juanma Barranquero
2011-03-07 14:31                       ` Jason Rumney
2011-03-07 16:19                         ` Ben Key
2011-03-07 18:09                         ` Juanma Barranquero
2011-03-07 23:04                           ` Jason Rumney
2011-03-07 14:28                     ` Jason Rumney
     [not found]                   ` <handler.8181.D8181.129953268524792.notifdone@debbugs.gnu.org>
2011-03-08  1:58                     ` bug#8181: closed (Re: bug#8181: Patch to fix bug#8181: 23.2; Dired on Windows 7) Robert I. Eachus
2011-03-08  2:24                       ` Juanma Barranquero

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.