Hi,
I'm converting PowerBasic projects made with PB Forms to FireFly environnement; I have two questions :
1. Is there any differences between these two functions :
Buit-in FireFly function FF_OpenFileDialog and OpenFileDialog from ComDlg32.inc (same question for FF_SaveFiledialog versus SaveFileDialog from ComDlg32.inc).
2. Does I have to use FF_OpenFileDialog and FF_SaveFileDialog in a FireFly Project or it doesn't change anything if I still use the "classic" OpenFileDialog and SaveFileDialog from ComDlg32.inc ?
Thank you.
You can use either. There isn't anything special about the FF function other than Paul added a little more extras to center them for you in a special Callback function that the dialogs use and it is much easier to use the FF functions in my opinion. It works nice the way they return values, etc. You only have to remember if you want the newer explorer looking style that Win9X and up has and you specify some styles yourself that you need to specify the style because when the Callback stuff is used with the dialogs they default to the old Win3.x look. If you specify no styles Paul defaults them to %OFN_EXPLORER OR %OFN_ENABLESIZING for you, that way it makes it a little easier and still allows for you to use the old Win3.x look if you wish.
Also, PB's Open File Function in the inc has a flaw and I've posted a couple times on their site and in the beta group it needs fixed with a post Tom made a while back. As it stands right now it doesn't support multiple filenames correctly cause it scans for the first nul first and multiple names are seperated by nul, so first it needs to scan for nul + nul which is the end of the list then the calling function can parse it.
FUNCTION OpenFileDialog (BYVAL hWnd AS DWORD, _ ' parent window
BYVAL sCaption AS STRING, _ ' caption
sFileSpec AS STRING, _ ' filename
BYVAL sInitialDir AS STRING, _ ' start directory
BYVAL sFilter AS STRING, _ ' filename filter
BYVAL sDefExtension AS STRING, _ ' default extension
dFlags AS DWORD _ ' flags
) AS LONG
LOCAL ix AS LONG
LOCAL ofn AS OPENFILENAME
LOCAL szFileTitle AS ASCIIZ * %MAX_PATH
' Filter is a sequence of ASCIIZ strings with a final (extra) $NUL terminator
REPLACE "|" WITH $NUL IN sFilter
sFilter = sFilter + $NUL
IF LEN(sInitialDir) = 0 THEN
sInitialDir = CURDIR$
END IF
ix = INSTR(sFileSpec, $NUL)
IF ix THEN
sFileSpec = LEFT$(sFileSpec, ix) + SPACE$(%OFN_FILEBUFFERSIZE - ix)
ELSE
sFileSpec = sFileSpec + $NUL + SPACE$(%OFN_FILEBUFFERSIZE - (LEN(sFileSpec) + 1))
END IF
ofn.lStructSize = SIZEOF(ofn)
ofn.hWndOwner = hWnd
ofn.lpstrFilter = STRPTR(sFilter)
ofn.nFilterIndex = 1
ofn.lpstrFile = STRPTR(sFileSpec)
ofn.nMaxFile = LEN(sFileSpec)
ofn.lpstrFileTitle = VARPTR(szFileTitle)
ofn.nMaxFileTitle = SIZEOF(szFileTitle)
ofn.lpstrInitialDir = STRPTR(sInitialDir)
IF LEN(sCaption) THEN
ofn.lpstrTitle = STRPTR(sCaption)
END IF
ofn.Flags = dFlags
IF LEN(sDefExtension) THEN
ofn.lpstrDefExt = STRPTR(sDefExtension)
END IF
FUNCTION = GetOpenFilename(ofn)
ix = INSTR(sFileSpec, $NUL + $NUL)
IF ix THEN
sFileSpec = LEFT$(sFileSpec, ix - 1)
ELSE
ix = INSTR(sFileSpec, $NUL)
IF ix THEN
sFileSpec = LEFT$(sFileSpec, ix - 1)
ELSE
sFileSpec = ""
END IF
END IF
dFlags = ofn.Flags
END FUNCTION
Paul uses GetOpenFileName() and Rtrims the nuls for you and gives you the string all ready to go with no problems...which is what PB should have done in the first place. There is a style for multiple files, if the programmer doesn't want to process them then they don't need the style, but if they do then they specify it and parse what comes back by nuls. PB looks like they were trying to parse for us, but in the process they only return one file all the time.
Hi Roger,
Thank you very much indeed for your detailed explanation.
Since, I want to select multiple filenames, you convince me to use the FireFly built-in functions.
Regards,
Jean-Pierre