/[emacs]/emacs/src/w32fns.c
ViewVC logotype

Diff of /emacs/src/w32fns.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.249 by eliz, Sun Jun 12 10:41:05 2005 UTC revision 1.250 by jasonr, Sun Jun 12 19:22:40 2005 UTC
# Line 7759  file_dialog_callback (hwnd, msg, wParam, Line 7759  file_dialog_callback (hwnd, msg, wParam,
7759    return 0;    return 0;
7760  }  }
7761    
7762    /* Since we compile with _WIN32_WINNT set to 0x0400 (for NT4 compatibility)
7763       we end up with the old file dialogs. Define a big enough struct for the
7764       new dialog to trick GetOpenFileName into giving us the new dialogs on
7765       Windows 2000 and XP.  */
7766    typedef struct
7767    {
7768      OPENFILENAME real_details;
7769      void * pReserved;
7770      DWORD dwReserved;
7771      DWORD FlagsEx;
7772    } NEWOPENFILENAME;
7773    
7774        
7775  DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0,  DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0,
7776         doc: /* Read file name, prompting with PROMPT in directory DIR.         doc: /* Read file name, prompting with PROMPT in directory DIR.
7777  Use a file selection dialog.  Use a file selection dialog.
# Line 7807  If ONLY-DIR-P is non-nil, the user can o Line 7820  If ONLY-DIR-P is non-nil, the user can o
7820      filename[0] = '\0';      filename[0] = '\0';
7821    
7822    {    {
7823      OPENFILENAME file_details;      NEWOPENFILENAME new_file_details;
7824      BOOL file_opened = FALSE;      BOOL file_opened = FALSE;
7825        OPENFILENAME * file_details = &new_file_details.real_details;
7826      
7827      /* Prevent redisplay.  */      /* Prevent redisplay.  */
7828      specbind (Qinhibit_redisplay, Qt);      specbind (Qinhibit_redisplay, Qt);
7829      BLOCK_INPUT;      BLOCK_INPUT;
7830    
7831      bzero (&file_details, sizeof (file_details));      bzero (&new_file_details, sizeof (new_file_details));
7832      file_details.lStructSize = sizeof (file_details);      /* Apparently NT4 crashes if you give it an unexpected size.
7833      file_details.hwndOwner = FRAME_W32_WINDOW (f);         I'm not sure about Windows 9x, so play it safe.  */
7834        if (w32_major_version > 4 && w32_major_version < 95)
7835          file_details->lStructSize = sizeof (new_file_details);
7836        else
7837          file_details->lStructSize = sizeof (file_details);
7838    
7839        file_details->hwndOwner = FRAME_W32_WINDOW (f);
7840      /* Undocumented Bug in Common File Dialog:      /* Undocumented Bug in Common File Dialog:
7841         If a filter is not specified, shell links are not resolved.  */         If a filter is not specified, shell links are not resolved.  */
7842      file_details.lpstrFilter = "All Files (*.*)\0*.*\0Directories\0*|*\0\0";      file_details->lpstrFilter = "All Files (*.*)\0*.*\0Directories\0*|*\0\0";
7843      file_details.lpstrFile = filename;      file_details->lpstrFile = filename;
7844      file_details.nMaxFile = sizeof (filename);      file_details->nMaxFile = sizeof (filename);
7845      file_details.lpstrInitialDir = init_dir;      file_details->lpstrInitialDir = init_dir;
7846      file_details.lpstrTitle = SDATA (prompt);      file_details->lpstrTitle = SDATA (prompt);
7847    
7848      if (! NILP (only_dir_p))      if (! NILP (only_dir_p))
7849        default_filter_index = 2;        default_filter_index = 2;
7850    
7851      file_details.nFilterIndex = default_filter_index;      file_details->nFilterIndex = default_filter_index;
7852    
7853      file_details.Flags = (OFN_HIDEREADONLY | OFN_NOCHANGEDIR      file_details->Flags = (OFN_HIDEREADONLY | OFN_NOCHANGEDIR
7854                            | OFN_EXPLORER | OFN_ENABLEHOOK);                            | OFN_EXPLORER | OFN_ENABLEHOOK);
7855      if (!NILP (mustmatch))      if (!NILP (mustmatch))
7856        file_details.Flags |= OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;        {
7857            /* Require that the path to the parent directory exists.  */
7858            file_details->Flags |= OFN_PATHMUSTEXIST;
7859            /* If we are looking for a file, require that it exists.  */
7860            if (NILP (only_dir_p))
7861              file_details->Flags |= OFN_FILEMUSTEXIST;
7862          }
7863    
7864      file_details.lpfnHook = (LPOFNHOOKPROC) file_dialog_callback;      file_details->lpfnHook = (LPOFNHOOKPROC) file_dialog_callback;
7865    
7866      file_opened = GetOpenFileName (&file_details);      file_opened = GetOpenFileName (file_details);
7867    
7868      UNBLOCK_INPUT;      UNBLOCK_INPUT;
7869    
7870      if (file_opened)      if (file_opened)
7871        {        {
7872          dostounix_filename (filename);          dostounix_filename (filename);
7873          if (file_details.nFilterIndex == 2)  
7874            if (file_details->nFilterIndex == 2)
7875            {            {
7876              /* "Directories" selected - strip dummy file name.  */              /* "Directories" selected - strip dummy file name.  */
7877              char * last = strrchr (filename, '/');              char * last = strrchr (filename, '/');

Legend:
Removed from v.1.249  
changed lines
  Added in v.1.250

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26