$IFNDEF _RQDIALOGINC
$DEFINE _RQDIALOGINC
CONST OFN_OVERWRITEPROMPT = &H2
CONST OFN_HIDEREADONLY = &H4
TYPE OPENFILENAME
lStructSize AS LONG
hwndOwner AS LONG
hInstance AS LONG
lpstrFilter AS LONG
lpstrCustomFilter AS LONG
nMaxCustFilter AS LONG
nFilterIndex AS LONG
lpstrFile AS LONG
nMaxFile AS LONG
lpstrFileTitle AS LONG
nMaxFileTitle AS LONG
lpstrInitialDir AS LONG
lpstrTitle AS LONG
flags AS LONG
nFileOffset AS SHORT
nFileExtension AS SHORT
lpstrDefExt AS LONG
lCustData AS LONG
lpfnHook AS LONG
lpTemplateName AS LONG
END TYPE
DIM RQDlog AS OPENFILENAME
DECLARE FUNCTION GetSaveFileName LIB "COMDLG32" ALIAS "GetSaveFileNameA" (pOpenfilename AS OPENFILENAME) AS LONG
DECLARE FUNCTION GetOpenFileName LIB "COMDLG32" ALIAS "GetOpenFileNameA" (pOpenfilename AS OPENFILENAME) AS LONG
FUNCTION RQshowdialog(capt$,filter$,fltrindex%,initdir$,savedlog%,nooverwriteprompt%,formhnd&) AS STRING
DEFSTR strcapt, strdrstr, strFile, strFileTitle, strFilter
DEFLNG rv
IF capt$="" THEN
IF savedlog% THEN
strcapt="Save"
ELSE
strcapt="Open"
END IF
ELSE
strcapt=capt$
END IF
IF INITDIR$="" THEN
strdrstr="."
ELSE
strdrstr=initdir$
END IF
strFile=STRING$(1024,0)
strFileTitle=STRING$(1024,0)
IF FILTER$="" THEN
strFilter = "All Files|*.*" + CHR$(0) + CHR$(0)
ELSE
strFilter = filter$ + CHR$(0) + CHR$(0)
END IF
strFilter = REPLACESUBSTR$(strFilter, "|", CHR$(0))
RQDlog.lStructSize = SIZEOF(RQDlog)
RQDlog.hwndOwner = formhnd&
RQDlog.hInstance = 0
RQDlog.lpstrFilter = VARPTR(strFilter)
RQDlog.nFilterIndex = FLTRINDEX%
RQDlog.lpstrFile = VARPTR(strFile)
RQDlog.nMaxFile = LEN(strFile)
RQDlog.lpstrFileTitle = VARPTR(strFileTitle)
RQDlog.nMaxFileTitle = LEN(strFileTitle)
RQDlog.lpstrInitialDir = VARPTR(strdrstr)
RQDlog.lpstrTitle = VARPTR(strcapt)
IF nooverwriteprompt% THEN
RQDlog.flags =OFN_HIDEREADONLY
ELSE
RQDlog.flags =OFN_HIDEREADONLY OR OFN_OVERWRITEPROMPT
END IF
IF savedlog%=0 THEN
IF GetOpenFileName(RQDlog) THEN
RESULT=LEFT$(strFile,INSTR(strFile,CHR$(0))-1)
END IF
ELSE
IF GetSaveFileName(RQDlog) THEN
RESULT=LEFT$(strFile,INSTR(strFile,CHR$(0))-1)
END IF
END IF
END FUNCTION
$ENDIF
|