From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.bugs Subject: bug#8181: Patch to fix bug#8181: 23.2; Dired on Windows 7 Date: Mon, 7 Mar 2011 06:37:45 +0100 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1299478030 32034 80.91.229.12 (7 Mar 2011 06:07:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 7 Mar 2011 06:07:10 +0000 (UTC) Cc: 8181@debbugs.gnu.org To: Ben Key Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Mar 07 07:07:06 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PwTaz-0002dU-Pz for geb-bug-gnu-emacs@m.gmane.org; Mon, 07 Mar 2011 07:07:06 +0100 Original-Received: from localhost ([127.0.0.1]:43298 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PwTaz-0001tn-5U for geb-bug-gnu-emacs@m.gmane.org; Mon, 07 Mar 2011 01:07:05 -0500 Original-Received: from [140.186.70.92] (port=55322 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PwTao-0001tf-DY for bug-gnu-emacs@gnu.org; Mon, 07 Mar 2011 01:06:55 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PwTam-0002cX-1i for bug-gnu-emacs@gnu.org; Mon, 07 Mar 2011 01:06:54 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:51563) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PwTal-0002cQ-Uo for bug-gnu-emacs@gnu.org; Mon, 07 Mar 2011 01:06:52 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PwT9q-0008PB-Hx; Mon, 07 Mar 2011 00:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juanma Barranquero Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 07 Mar 2011 05:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8181 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 8181-submit@debbugs.gnu.org id=B8181.129947631432276 (code B ref 8181); Mon, 07 Mar 2011 05:39:02 +0000 Original-Received: (at 8181) by debbugs.gnu.org; 7 Mar 2011 05:38:34 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PwT9N-0008OW-UK for submit@debbugs.gnu.org; Mon, 07 Mar 2011 00:38:34 -0500 Original-Received: from mail-yi0-f44.google.com ([209.85.218.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PwT9K-0008OJ-QI for 8181@debbugs.gnu.org; Mon, 07 Mar 2011 00:38:31 -0500 Original-Received: by yic13 with SMTP id 13so1709020yic.3 for <8181@debbugs.gnu.org>; Sun, 06 Mar 2011 21:38:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=+qKLEmaXYVm5uSUKwPNBylfduqYSlgFVlRRh1LbsNJo=; b=Dphx4Qs0VA4/sWE28uWj2nJherjgUDB71NKpyaNWDDVHp35xjqoX0qFgjBXGKY5nB1 QQUReVWa/G25y004txvaha+h9hv9f+7zjtUF6hjlFc0vGHlLzURGeBUVIjqFAlHSxqml 5VNEjNCn3XR9nG8b/omzhZkcRLYIBmJbmmuBI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=Fwa4/5j2pTNMAt3KptwmJlW8qbehFmNciqhZPmaDgIxtmplCxRCaJn6OjM636SODHP sErkm8A2LIofc7ks8Mjf00CAK+beoj9F4Biy5lNA6OWmplB0lrjtUN468v6+FLzek1/t ytk6tkehUWaalrOEzRBR5UaKjQPD5nbany0Ys= Original-Received: by 10.150.52.11 with SMTP id z11mr3852698ybz.350.1299476305101; Sun, 06 Mar 2011 21:38:25 -0800 (PST) Original-Received: by 10.147.113.19 with HTTP; Sun, 6 Mar 2011 21:37:45 -0800 (PST) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 07 Mar 2011 00:39:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:44731 Archived-At: On Mon, Mar 7, 2011 at 05:15, Ben Key wrote: > The attached patch fixes bug #8181: 23.2; Dired on Windows 7. Thanks. > 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.=C2=A0 T= his 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.=C2=A0 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. There's no need to duplicate the code in both branches of "if (STRINGP (default_filename))"; "Current Directory" is shorter than MAX_PATH, so there are no worries about buffer overflow. You can just add /* 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. */ if (filename[0] =3D=3D 0 && ! NILP (only_dir_p)) strcpy (filename, "Current Directory"); afterwards. > The attempt to find the window handle of the file name text field failed,= at > least on Windows XP and Windows 7.=C2=A0 By using Microsoft Spy++ I was a= ble to > discover the correct way to obtain this Window handle.=C2=A0 I modified t= he code > in file_dialog_callback that initializes the edit_control using this > information. Having to go fishing for the window handles is hackish, but not your fault, but Microsoft's. Unless someone knows of a better way, that's what we're stuck with. > My solution was to set focus to the list box if the > file name text field is disabled during dialog box initialization.=C2=A0 = This > part could use a little more work. I don't see anything wrong with this. Here's your patch, slighty reworked to be more on line with current Emacs coding conventions (the "0 =3D=3D X" and "NULL =3D=3D X" styles are n= ot frequently used) and with a proposed ChangeLog entry (feel free to rewrite it, of course). =C2=A0 =C2=A0 Juanma 2011-03-07 Ben Key * w32fns.c (FILE_NAME_COMBO_BOX, FILE_NAME_LIST): Define. (file_dialog_callback): Fix locating the window handle of the File Name text field. After disabling it, set focus on the list control. (Fx_file_dialog): If only_dir_p is non-nil, set the text of the File Name text field to "Current Directory" if it does not already have another value. (Bug#8181) =3D=3D=3D modified file 'src/w32fns.c' --- src/w32fns.c 2011-02-16 18:39:46 +0000 +++ src/w32fns.c 2011-03-07 05:01:46 +0000 @@ -60,6 +60,8 @@ #include #include #define FILE_NAME_TEXT_FIELD edt1 +#define FILE_NAME_COMBO_BOX cmb13 +#define FILE_NAME_LIST lst1 #include "font.h" #include "w32font.h" @@ -5868,13 +5870,37 @@ { HWND dialog =3D GetParent (hwnd); HWND edit_control =3D GetDlgItem (dialog, FILE_NAME_TEXT_FIELD); - - /* Directories is in index 2. */ + HWND list =3D GetDlgItem (dialog, FILE_NAME_LIST); + + /* 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 hierarchy using Microsoft Spy++. bk */ + if (edit_control =3D=3D NULL) + { + HWND tmp =3D GetDlgItem (dialog, FILE_NAME_COMBO_BOX); + if (tmp) + { + tmp =3D GetWindow (tmp, GW_CHILD); + if (tmp) + edit_control =3D GetWindow (tmp, GW_CHILD); + } + } + + /* Directories is in index 2. */ if (notify->lpOFN->nFilterIndex =3D=3D 2) { CommDlg_OpenSave_SetControlText (dialog, FILE_NAME_TEXT_FIELD, "Current Directory"); EnableWindow (edit_control, FALSE); + /* Note 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. */ + if (CDN_INITDONE =3D=3D notify->hdr.code) + SetFocus (list); } else { @@ -5951,6 +5977,13 @@ else filename[0] =3D '\0'; + /* 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. */ + if (filename[0] =3D=3D 0 && ! NILP (only_dir_p)) + strcpy (filename, "Current Directory"); + { NEWOPENFILENAME new_file_details; BOOL file_opened =3D FALSE;