Set default filter in SalDlgOpenFile

Version independent discussion forum
FRBhote
India
Posts: 2215
Joined: 09 Mar 2017, 05:32
Location: Hyderabad, India

Set default filter in SalDlgOpenFile

Post by FRBhote » 20 Apr 2016, 07:54

Is it possible to set the default filter in SalDlgOpenFile ?

Set strFilters[0] = 'Executable Files'
Set strFilters[1] = '*.exe'
Set strFilters[2] = 'Dynamic Link Libraries'
Set strFilters[3] = '*.dll'
Set strFilters[4] = 'Initialization Files'
Set strFilters[5] = '*.ini'

Can I set it to .dll for example?

clemdoc
Austria
Posts: 251
Joined: 08 Mar 2017, 09:51
Location: Austria

Set default filter in SalDlgOpenFile

Post by clemdoc » 20 Apr 2016, 16:19

FRBhote wrote:Is it possible to set the default filter in SalDlgOpenFile ?

Set strFilters[0] = 'Executable Files'
Set strFilters[1] = '*.exe'
Set strFilters[2] = 'Dynamic Link Libraries'
Set strFilters[3] = '*.dll'
Set strFilters[4] = 'Initialization Files'
Set strFilters[5] = '*.ini'

Can I set it to .dll for example?
Yes of course (for TD 5.2 at least, but I think it was the same in TD 1.5), that is what the "nIndex" parameter is for. Try setting that to 2.
hth, clem

FRBhote
India
Posts: 2215
Joined: 09 Mar 2017, 05:32
Location: Hyderabad, India

Set default filter in SalDlgOpenFile

Post by FRBhote » 21 Apr 2016, 06:10

That's what it should be but on TD 2.1 it doesn't do it.
Untitled.png
You do not have the required permissions to view the files attached to this post.

clemdoc
Austria
Posts: 251
Joined: 08 Mar 2017, 09:51
Location: Austria

Set default filter in SalDlgOpenFile

Post by clemdoc » 22 Apr 2016, 10:43

Hm, I'm sorry to hear that.
I've looked up SalDlgOpenFile (as in the topic name), not SalDlgSaveFile, but I would have expected that to work similarly.
If that can't be solved in TD (and overcoming the hassle is worth the effort), you can always use C/C++ and write a DLL with a wrapper around the corresponding Win-API calls.
You might also find the defnitions in Sal Extensions or in some of the resources in Dave Rabelinks excellent TD Wiki.
hth, clem

FRBhote
India
Posts: 2215
Joined: 09 Mar 2017, 05:32
Location: Hyderabad, India

Set default filter in SalDlgOpenFile

Post by FRBhote » 22 Apr 2016, 12:05

Works the same way for both. Let me look up the wiki.

Thanks.

clemdoc
Austria
Posts: 251
Joined: 08 Mar 2017, 09:51
Location: Austria

Set default filter in SalDlgOpenFile

Post by clemdoc » 08 Jun 2016, 13:54

I had the same issue just today (albeit using SalDlgOpenFile) and the solution was to initialize the Filename with the same value as the desired filter pattern before calling SalDlgOpenFile. It seems that somewhere between the TD runtime and the WinAPI function [1], funny things are going on.
nIndex seems to be ignored, so according to [2], the value of lpstrCustomFilteris used. Quote from [2]:
If the nFilterIndex member is zero, the dialog box uses the custom filter.
As lpstrCustomFilter seems to be initialised with strFile of SalDlgOpen/SaveFile, that seems to work (and indeed be the only solut^H^H workaround).

Maybe you want to try, whether that works for you too by including:

Code: Select all

Set sFileName = '*.wri'
[1] GetOpenFileName
[2] OPENFILENAME

hth, clem

FRBhote
India
Posts: 2215
Joined: 09 Mar 2017, 05:32
Location: Hyderabad, India

Set default filter in SalDlgOpenFile

Post by FRBhote » 10 Jun 2016, 14:02

Will try it out first thing tomorrow morning.

But if I have something like:

Code: Select all

Set sFilters[12] = 'NSDL ' || sgCsvFiles || ' 3.41'
Set sFilters[13] = sgCsvFiles1
Set sFilters[14] = 'DP 57'
Set sFilters[15] = '*DP57*.*'
Set sFilters[16] = 'NSDL ' || sgCsvFiles || ' 3.5'
Set sFilters[17] = sgCsvFiles1
Both 13 & 17 have the same format but the index is important, it won't work.

Return to “General Discussion (TD version independent)”

Who is online

Users browsing this forum: [Ccbot] and 0 guests