Opened 12 months ago

Closed 6 months ago

Last modified 6 months ago

#15429 closed enhancement (fixed)

Cannot pick up a shortcut(*.lnk) with wxFilePicker or wxFileDialog.

Reported by: GPBeta Owned by:
Priority: low Milestone:
Component: wxMSW Version: dev-latest
Keywords: wxFilePicker wxFIleDialog simple Cc: lbacci@…
Blocked By: Blocking:
Patch: no

Description

As summary, I hope wxFilePicker and wxFileDialog would add an option to allow user to pick up a shortcut file with windows file picking dialog.
To make this possible, what we need to do is just add OFN_NODEREFERENCELINKS flag into the Flags variable of OPENFILENAME struct when we do system call GetOpenFileName(OPENFILENAME*).

Attachments (1)

mypatch.patch download (3.6 KB) - added by zeromemory 6 months ago.

Download all attachments as: .zip

Change History (7)

comment:1 follow-up: Changed 12 months ago by vadz

  • Keywords simple added
  • Priority changed from normal to low
  • Status changed from new to confirmed

I guess we could add wxFD_NO_FOLLOW (not NODEREFERENCE for consistency with the existing wxFILE_EXISTS_NO_FOLLOW) flag and patches adding it would be welcome. In the meanwhile, MSDN seems to suggest that using the filter string of "All Files\0*.*\0\0" should have the same effect (but I didn't test it).

comment:2 in reply to: ↑ 1 Changed 12 months ago by GPBeta

Replying to vadz:

I guess we could add wxFD_NO_FOLLOW (not NODEREFERENCE for consistency with the existing wxFILE_EXISTS_NO_FOLLOW) flag and patches adding it would be welcome. In the meanwhile, MSDN seems to suggest that using the filter string of "All Files\0*.*\0\0" should have the same effect (but I didn't test it).

Because I can't use the double null end string "All Files\0*.*\0\0" as lpstrFilter, I use "All Files (*.*)|*.*" wildcard in the wxFileDialog, but it didn't work on my win8. Is there a difference with them?

Changed 6 months ago by zeromemory

comment:3 Changed 6 months ago by zeromemory

  • Cc lbacci@… added
  • Patch set
  • Version changed from 2.9.4 to dev-latest

this patch adds wxFD_NO_FOLLOW flag (I've given it the value 0x008, this bit wasn't already used) and the MSW implementation of wxFileDialog (src/msw/filedlg.cpp) takes it into account, mapping wxFD_NO_FOLLOW to OFN_NODEREFERENCELINKS when calling OpenFileName. Both GTK+ and the generic implementation, I think, do not follow links, so there's no point in modifying their implementation. This is just a first attempt to make a patch, let me know of any problem! Anyway, it's been tested and works.

Luca Bacci

comment:4 Changed 6 months ago by vadz

Very nice, thanks!

I'm applying this with some minor changes. The important one is a more detailed documentation but I also simplified the demonstration code in the sample because while it was a very good idea to add it there for testing, being asked about it every time is confusing (for the first time users) and annoying (for the people who use it often). This also incidentally took care of another problem, with some of the lines being too long as we try to keep them under 80 column limit.

But all in all an excellent first contribution, thank you!

comment:5 Changed 6 months ago by VZ

  • Resolution set to fixed
  • Status changed from confirmed to closed

(In [76085]) Add wxFD_NO_FOLLOW style for wxFileDialog.

This style tells the dialog to return the paths of the link being selected
without dereferencing it.

Currently only implemented under wxMSW as the links are not dereferenced by
default in wxGTK anyhow. But we may want to change this and implement it there
too for consistency in the future.

Closes #15429.

comment:6 Changed 6 months ago by zeromemory

  • Patch unset

Thanks, vadz! Yeah, it surely needed some restyling, I wrote everything on the fly just to get things done. Wow, it got merged in the development trunk!! Thank you all

Note: See TracTickets for help on using tickets.