Ok,
The file browser is now completed.
Here's the code for the file browser:
Set Window On
Sync On : Sync Rate 30
Show Mouse
Minimize Window
FileBoxTitle$="Add ^"
FileFilter$="Music Files Wav, Mp3, Mid^*.wav;*.mp3;*.mid^^"
filename$=getFileName(FileBoxTitle$,FileFilter$)
Maximize Window
Cls
Set Cursor 10,10
Print Filename$
rem show the file identification dialog
function getFileName(FileBoxTitle$,FileFilter$)
load dll "user32.dll",1
load dll "kernel32.dll",2
load dll "comdlg32.dll",3
rem Memblock Table
OFN_MB = 1
PathBuffer_MB = 2
FileFilter_MB = 3
FileBoxTitle_MB = 4
rem Offset Table OPENFILENAME Struct
lStructSize = 0
hwndOwner = 4
hInstance = 8
lpstrFilter = 12
lpstrCustomFilter = 16
nMaxCustFilter = 20
nFilterIndex = 24
lpstrFile = 28
nMaxFile = 32
lpstrFileTitle = 36
nMaxFileTitle = 40
lpstrInitialDir = 44
lpstrTitle = 48
Flags = 52
nFileOffset = 56
nFileExtension = 58
lpstrDefExt = 60
lCustData = 64
lpfnHook = 68
lpTemplateName = 72
StructEnd = 76
rem OPENFILENAME Flag Table
OFN_ALLOWMULTISELECT = 512:rem 0x00000200
OFN_CREATEPROMPT = 8192:rem 0x00002000
OFN_ENABLEHOOK = 32:rem 0x00000020
OFN_ENABLETEMPLATE = 64:rem 0x00000040
OFN_ENABLETEMPLATEHANDLE = 128:rem 0x00000080
OFN_EXPLORER = 524288:rem 0x00080000
OFN_EXTENSIONDIFFERENT = 1024:rem 0x00000400
OFN_FILEMUSTEXIST = 4096:rem 0x00001000
OFN_HIDEREADONLY = 4:rem 0x00000004
OFN_LONGNAMES = 2097152:rem 0x00200000
OFN_NOCHANGEDIR = 8:rem 0x00000008
OFN_NODEREFERENCELINKS = 1048576:rem 0x00100000
OFN_NOLONGNAMES = 262144:rem 0x00040000
OFN_NONETWORKBUTTON = 131072:rem 0x00020000
OFN_NOREADONLYRETURN = 32768:rem 0x00008000
OFN_NOTESTFILECREATE = 65536:rem 0x00010000
OFN_NOVALIDATE = 256:rem 0x00000100
OFN_OVERWRITEPROMPT = 2:rem 0x00000002
OFN_PATHMUSTEXIST = 2048:rem 0x00000800
OFN_READONLY = 1:rem 0x00000001
OFN_SHAREAWARE = 16384:rem 0x00004000
OFN_SHOWHELP = 16:rem 0x00000010
rem FileBox Info
FileBoxFlags = OFN_EXPLORER + OFN_FILEMUSTEXIST + OFN_PATHMUSTEXIST + OFN_LONGNAMES + OFN_HIDEREADONLY + OFN_NONETWORKBUTTON
PathBufferSize = 256
hWnd = call dll(1,"GetActiveWindow")
hMod = call dll(2,"GetModuleHandleA",0)
rem Create Memblock Struct
make memblock OFN_MB,StructEnd
make memblock PathBuffer_MB,PathBufferSize
make memblock FileFilter_MB,len(FileFilter$)
make memblock FileBoxTitle_MB,len(FileBoxTitle$)
OFN = get memblock ptr(OFN_MB)
PathBuffer = get memblock ptr(PathBuffer_MB)
FileFilter = get memblock ptr(FileFilter_MB)
FileBoxTitle = get memblock ptr(FileBoxTitle_MB)
rem Dump Strings to Memblock
dump(FileFilter_MB,FileFilter$)
dump(FileBoxTitle_MB,FileBoxTitle$)
rem Write to OPENFILENAME Struct
write memblock dword OFN_MB,lStructSize,StructEnd
write memblock dword OFN_MB,hWndOwner,hWnd
write memblock dword OFN_MB,hInstance,hMod
write memblock dword OFN_MB,lpstrFilter,FileFilter
write memblock dword OFN_MB,lpstrFile,PathBuffer
write memblock dword OFN_MB,nMaxFile,PathBufferSize
write memblock dword OFN_MB,Flags,FileBoxFlags
write memblock dword OFN_MB,lpstrTitle,FileBoxTitle
rem Open FileBox
call dll 3,"GetOpenFileNameA",OFN
result$ = getstr(PathBuffer_MB)
rem Delete Memblock Struct
delete memblock OFN_MB
delete memblock PathBuffer_MB
delete memblock FileFilter_MB
delete memblock FileBoxTitle_MB
delete dll 1
delete dll 2
delete dll 3
endfunction result$
rem fonctions utilisées pour l'identification d'une fichier
function dump(m,s$)
for p=1 to len(s$)
b=asc(mid$(s$,p))
if b=asc("^") then b=0
write memblock byte m,p-1,b
next p
endfunction
function getstr(m)
p=0:s$=""
do
b=memblock byte(m,p)
if b=0 then exit
s$=s$+chr$(b)
inc p
loop
endfunction s$
Thanks to BlinkOk for the idea and Kelebrindae for the code
I'll add the file browser code to my code later and put out a small demo
Feel free to use the file browser code all you want. Its very confusing code, but all you have to do is play around with the first part of it to make it do what you want.