SYSTEM-DIALOG GET-FILE extended version available ?

Chris Kelleher

Administrator
Staff member
I would like to select more then 1 file with the SYSTEM-DIALOG GET-FILE
just the same way as I attach 5 files to my email


Regards
Hans Jansen
 

Chris Kelleher

Administrator
Staff member
Hi,
If you're using v9, why not set a widget up as a DROP-TARGET instead of
using SDGF? That way, you can just drag any number of files from an Explorer
window onto your app...

HTH
Nick

-------------------------------------------------------------------
Nick Williamson, Progress Analyst/Programmer, Harness Software Ltd.
Phone +44 (0)161 613 8818 Fax +44 (0)161 718 7789
Email : nick.williamson@harness-software.com
Web : http://www.harness-software.com
-------------------------------------------------------------------
 

Chris Kelleher

Administrator
Staff member
That's funny, this question has been asked a lot the last couple of days.
Anyway, you can use procedure GetOpenfileNameA in "comdlg32.dll" with the
OFN_ALLOWMULTISELECT flag. I don't have an example right now, but it's
fairly easy to set it up once you found the definition in MSDN.

Bye,
Jurjen.


(PGP: Key ID=0x7E9DF75F)
------------------------
Search-engine for Progress related websites:
http://home.wxs.nl/~jurjen.dijkstra/prodevring/ringsearch.html

Windows API examples for Progress 4GL:
http://home.wxs.nl/~jurjen.dijkstra/api/index.html
 

Chris Kelleher

Administrator
Staff member
I think this might be what you want to mult-select.
Jurjen Dijkstra actually wrote most of this over a year ago. (Thanks,
Jurjen)

<BLOCKQUOTE><font size="1" face="Arial, Verdana">code:</font><HR><pre>

PROCEDURE GetOpenFileNameA EXTERNAL "comdlg32.dll" :
DEFINE INPUT PARAMETER pStruct AS LONG.
DEFINE RETURN PARAMETER pReturn AS LONG.
END PROCEDURE.


PROCEDURE SystemDialogGetFile :
/*------------------------------------------------------------------------------
Purpose: To replace the SYSTEM-DIALOG-GET-FILE common dialog.
Parameters:
Notes:
------------------------------------------------------------------------------*/

DEFINE INPUT PARAMETER Flags AS INTEGER NO-UNDO.
DEFINE INPUT PARAMETER Filter AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER DialogTitle AS CHARACTER NO-UNDO.
DEFINE OUTPUT PARAMETER FileNames AS CHARACTER NO-UNDO.
DEFINE OUTPUT PARAMETER OK AS INTEGER NO-UNDO.

DEFINE VARIABLE lpOfn AS MEMPTR NO-UNDO.
DEFINE VARIABLE lpstrFilter AS MEMPTR NO-UNDO.
DEFINE VARIABLE lpstrTitle AS MEMPTR NO-UNDO.
DEFINE VARIABLE lpstrFile AS MEMPTR NO-UNDO.
DEFINE VARIABLE numfilters AS INTEGER NO-UNDO.
DEFINE VARIABLE offset AS INTEGER NO-UNDO.

&SCOPED-DEFINE OFN_OVERWRITEPROMPT 2
&SCOPED-DEFINE OFN_HIDEREADONLY 4
&SCOPED-DEFINE OFN_NOCHANGEDIR 8
&SCOPED-DEFINE OFN_ALLOWMULTISELECT 512
&SCOPED-DEFINE OFN_PATHMUSTEXIST 2048
&SCOPED-DEFINE OFN_FILEMUSTEXIST 4096
&SCOPED-DEFINE OFN_NOREADONLYRETURN 32768
&SCOPED-DEFINE OFN_EXPLORER 524288

numfilters = 0.
offset = 1.
offset = offset + LENGTH(TRIM(Filter)) + 2.
SET-SIZE(lpstrFilter) = offset.
offset = 1.
numfilters = numfilters + 1.
PUT-STRING(lpstrFilter, offset) = TRIM(ENTRY(1, Filter, "|")).
offset = offset + LENGTH(TRIM(ENTRY(1, Filter, "|"))) + 1.
PUT-STRING(lpstrFilter, offset) = TRIM(ENTRY(2, Filter, "|")).
offset = offset + LENGTH(TRIM(ENTRY(2, Filter, "|"))) + 1.
PUT-STRING(lpstrFilter, offset) = "".

SET-SIZE(lpstrFile) = 1024. /* room for a couple of files... */
PUT-BYTE(lpstrFile,1) = 0. /* don't initialize dialog to a file */

SET-SIZE(lpstrTitle) = LENGTH(DialogTitle) + 1.
PUT-STRING(lpstrTitle,1) = DialogTitle.
SET-SIZE(lpOfn) = 76.

/* size */ PUT-LONG (lpOfn, 1) = GET-SIZE(lpOfn).
/* hwndOwner */ PUT-LONG (lpOfn, 5) = 0.
/* hInstance */ PUT-LONG (lpOfn, 9) = 0.
/* lpstrFilter */ PUT-LONG (lpOfn,13) = GET-POINTER-VALUE(lpstrFilter).
/* lpstrCustomFilter */ PUT-LONG (lpOfn,17) = 0.
/* nMaxCustFilter */ PUT-LONG (lpOfn,21) = 0.
/* nFilterIndex */ PUT-LONG (lpOfn,25) = 0.
/* lpstrFile */ PUT-LONG (lpOfn,29) = GET-POINTER-VALUE(lpstrFile).
/* nMaxFile */ PUT-LONG (lpOfn,33) = GET-SIZE(lpstrFile).
/* lpstrFileTitle */ PUT-LONG (lpOfn,37) = 0.
/* nMaxFileTitle */ PUT-LONG (lpOfn,41) = 0.
/* lpstrInitialDir */ PUT-LONG (lpOfn,45) = 0.
/* lpstrTitle */ PUT-LONG (lpOfn,49) = GET-POINTER-VALUE(lpstrTitle).
/* flags */ PUT-LONG (lpOfn,53) = Flags.
/*
/* nFileOffset */ PUT-SHORT(lpOfn,57)
/* nFileExtension */ PUT-SHORT(lpOfn,59)
/* lpstrDefExt */ PUT-LONG (lpOfn,61)
/* lCustData */ PUT-LONG (lpOfn,65)
*/

/* lpfnHook */ PUT-LONG (lpOfn,69) = 0.
/* lpTemplateName */ PUT-LONG (lpOfn,73) = 0.

RUN GetOpenFileNameA (GET-POINTER-VALUE(lpOfn), OUTPUT Ok).
SET-SIZE(lpstrFilter) = 0.
SET-SIZE(lpOfn) = 0.
SET-SIZE(lpstrTitle) = 0.

IF Ok <> 0 THEN
DO:
DEFINE VARIABLE cPath AS CHARACTER NO-UNDO.
DEFINE VARIABLE cList AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFile AS CHARACTER NO-UNDO.

cPath = GET-STRING(lpstrFile,1).
offset = LENGTH(cPath) + 2.
cFile = 'x'.

REPEAT:
cFile = GET-STRING(lpstrFile, offset).
IF cFile = "" THEN LEAVE.
ASSIGN cList = cList + ',' + cPath + '\' + cFile
offset = offset + LENGTH(cFile) + 1.
END.
ASSIGN cList = TRIM(cList, ",")
FileNames = IF cList <> "" THEN cList ELSE cPath.
END.
FileNames = CAPS(FileNames).
SET-SIZE(lpstrFile) = 0.

END PROCEDURE.

[/code]
 

Chris Kelleher

Administrator
Staff member
Hi,

I noticed that playing around with the flags sometimes gets me different
get-file dialogs. Whixh one should I use to take advantage of the
multi-select feature? Also, is there doc somewhere that shows which is
which?

TIA,
Ken Mc
 
Top