473,398 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Capture order of files selected in file dialog box by OS-Hook

I had exactly the same problem but I exclusively program using the WIN32 API functions and in PureBasic

I solved the problem by enabling a Hook procedure for the WIN32 OpenFile Dialog function and intercepting the CDN_SELCHANGE notifcations that are sent for every file name that is clicked, this includes contiguous or non-contiguous blocks. By sending the CDM_GETSPEC message the currently selected file as well as the group of files selected (if any) is obtained.

The problem with the group of files is that the list is dynamically re-sorted in alphabetical order as files are being selcted whilst holding down the control key but, and an important but, the first file in the list is always the present selection or to put it another way, the lastest file addd to the group.

The code to then correctly return the file names in the order in which they were selected is however non-trivial but I have been able to do it.

The easiest way to see what is going on is to simply bring up a debug window from the Hook procedure when the CDN_SELCHANGE notifcation is received and the CDM_GETSPEC message sent to retrieve the currently selected file(s).

Hope this helps for future readers that stumble upon this post.
Sep 6 '12 #1
4 1931
zmbd
5,501 Expert Mod 4TB
Gantos22

This is a very old thread to zombie; however, your solution is somewhat interesting and may have some applications.

However, you really haven't provided a lot of detail about the the method you have offered, which is quite advanced for a lot of our readers.

I would certainly be willing to move your post to its own thread where you would have the "room" to explain the method in detail, code snipit, and perhaps offer an example where this would be a useful tool.

-z
Sep 6 '12 #2
Hi zmbd I didn't think anyone would read this so quickly!

I have produced a DLL version of my code that I use in applications where it is important to know the order in which files were selected. The code is written in PureBasic format but nevertheless the WIN32 API calls are in the format of the MS SDK so can be easily reconciled.

As I mentioned, the task turned out to be non-trivial because you need to take into account files that were clicked but ended up not being selected and files that were block highlighted with the "Shift" key so there is quite a bit of code to make it work but I'm willing to provide more details as I'm sure many other people have similar needs from time to time.

In order to replicate what I have done, users will need to be familiar with calling WIN32 functions and setting up a Hook procedure that the standard MS OpenFile Dialog will call.

I have also used "Linked Lists" to store and sort the returned and selected files but alternatively static arrays could be used.

The need to know what order files were selected arose in several projects, the first for my wife's Library cataloguing business where she has a need to concatenate library MARC21 format (machine readable catalogue) files in a particular order. The program that I originally wrote to produce the MARC21 files allowed drag & drop to change the order of concatenation but it was much better that at the file selection stage the order in which they were selected was preserved.

The second application was for an RCDATA MS resource compiler that I wrote and I wanted to be able to keep ICONS, Cursors and other bitmap files in a particular order so that the generated resource file (.rc) would have say a given button UP positon bitmap and the same button DOWN position bit map following sequentially.
Sep 6 '12 #3
zmbd
5,501 Expert Mod 4TB
Absolutly cool...
Have you read Rabbit's current work with WMI?
http://bytes.com/topic/access/insigh...n-wmi-tutorial

Your work really deserves it's own thread and topic
With your kind permision, we can split your posts out into their thread as I offered earlier...

-z
Sep 6 '12 #4
Yes I'm happy for you to do that and I presume that I will receive an auto Email letting me know where you have created the new message.

I have not read Rabbits work with WMI but will do so, please be aware tough that I program using the PureBasic language and not MS Visual Studio/Visual Basic anymore so people will have to translate what I have done into the MS OOP/.net world however its the strategy that's important.

Best regards
Sep 6 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: GrantS | last post by:
I am needing to permit users to select files using the 'Open file' common dialog box. The format of the names of the files are along the names of: GB00((&X.001.jpg I am not able to show these...
3
by: B Garrett | last post by:
Hi, I have a .ASPX page using C# and I need to read in a text file from a selected path. so in need the file dialog box to allow the user to choose the path and file that they want to read in....
9
by: Amit D.Shinde | last post by:
How to enable user for selecting only folders and not the files with the Open File Dialog. i.e. I want only path of the selected folder is to be returned by Open File Dialog. i.e Open File Dialog...
3
by: den 2005 | last post by:
Hi everybody, I like to allow user to select and browse to which location to save the pdf file of a crystal report viewed on a web page, how can i do this in ASP.Net? I need to get the path...
1
by: Josha | last post by:
I am very new to vb and Access and the like, please be gentle. I am trying to use the below script in Access 2000 to open a file picker dialog then display the selected text in a text box. A...
15
by: eric dexter | last post by:
csoundgrid2.main(filename, """;<sco_header>""") isn't working like I want it to. I was trying to find out what my value for filename is but it will not print. The file I am calling...
1
by: mvlt | last post by:
I am trying to create a button and related text box that allows a user to click, open the standard Windows File Dialog Box and populate the text box with the selected file path, which will then be a...
3
by: Ecohouse | last post by:
I know how to use the File Dialog control but I'm not sure how to actually open the file that is selected. Here's my code: 'Create a FileDialog object as a File Picker dialog box. Set fd =...
2
by: kronecker | last post by:
I have a short routine that writes to a wav file. The details of the wav write file bit is not important. At present it put a file dialog up and you type in a name for the file name and you save....
7
by: xraive | last post by:
Currently I only get the file path. Is there way to retrieve the file name or do I have to just use the split function. Dim fDialog As Office.FileDialog Dim varFile As Variant ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.