Thanxx a lot Roland
but i found that when i run the modified version of DialogOpenFile1 ( modified to have rtl64 only)
the filter isn't working
i preset the filter to display files that have exe and dll extension
but the dialog open display all the files similar to *.* ?
why ? what must be done so that the open dialog display *.exe and *.dll only
' OpenFile1.o2bas
$ filename "OpenFile1.exe"
uses rtl64
#define OFN_READONLY 0x00000001
#define OFN_OVERWRITEPROMPT 0x00000002
#define OFN_HIDEREADONLY 0x00000004
#define OFN_NOCHANGEDIR 0x00000008
#define OFN_SHOWHELP 0x00000010
#define OFN_ENABLEHOOK 0x00000020
#define OFN_ENABLETEMPLATE 0x00000040
#define OFN_ENABLETEMPLATEHANDLE 0x00000080
#define OFN_NOVALIDATE 0x00000100
#define OFN_ALLOWMULTISELECT 0x00000200
#define OFN_EXTENSIONDIFFERENT 0x00000400
#define OFN_PATHMUSTEXIST 0x00000800
#define OFN_FILEMUSTEXIST 0x00001000
#define OFN_CREATEPROMPT 0x00002000
#define OFN_SHAREAWARE 0x00004000
#define OFN_NOREADONLYRETURN 0x00008000
#define OFN_NOTESTFILECREATE 0x00010000
#define OFN_NONETWORKBUTTON 0x00020000
#define OFN_NOLONGNAMES 0x00040000 // force no long names for 4.x modules
#define OFN_EXPLORER 0x00080000 // new look commdlg
#define OFN_NODEREFERENCELINKS 0x00100000
#define OFN_LONGNAMES 0x00200000 // force long names for 3.x modules
#define OFN_ENABLEINCLUDENOTIFY 0x00400000 // send include message to callback
#define OFN_ENABLESIZING 0x00800000
#define OFN_DONTADDTORECENT 0x02000000
#define OFN_FORCESHOWHIDDEN 0x10000000 // Show All files including System and hidden files
/*
typedef struct tagOFNA {
sys lStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
LPCSTR lpstrFilter;
LPSTR lpstrCustomFilter;
DWORD nMaxCustFilter;
DWORD nFilterIndex;
LPSTR lpstrFile;
DWORD nMaxFile;
LPSTR lpstrFileTitle;
DWORD nMaxFileTitle;
LPCSTR lpstrInitialDir;
LPCSTR lpstrTitle;
DWORD Flags;
WORD nFileOffset;
WORD nFileExtension;
LPCSTR lpstrDefExt;
LPARAM lCustData;
LPOFNHOOKPROC lpfnHook;
LPCSTR lpTemplateName;
} OPENFILENAMEA, *LPOPENFILENAMEA;
*/
' Apr 24 2018 -- modified to replace handle and pointer
' from DWORD or LONG to sys otherwise
' when compile to 64bits it won't run
Type OPENFILENAME
lStructSize As sys
hwndOwner As sys
hInstance As sys
lpstrFilter as sys 'string
lpstrCustomFilter As sys
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As sys 'string
nMaxFile As Long
lpstrFileTitle As sys 'string
nMaxFileTitle As Long
lpstrInitialDir As sys 'string
lpstrTitle As sys 'string
flags As Long
nFileOffset As word
nFileExtension As word
lpstrDefExt As sys 'string
lCustData As Long
lpfnHook As sys
lpTemplateName As sys 'string
End Type
'76 bytes
Declare GetModuleHandle lib "kernel32.dll" alias "GetModuleHandleA" (sys n) as sys
Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As sys
Declare CommDlgExtendedError Lib "comdlg32.dll" () as dword
'==================
Function FileDialog(string iDir, filter, Title, sys Hwnd, Flags) As String
Dim ofn As OPENFILENAME
Dim filename[255] As zstring
int retval
ofn.lStructSize = sizeof(OPENFILENAME)
ofn.hwndOwner = hWnd
ofn.hInstance = GetModuleHandle(0)
ofn.lpstrFilter = ?filter
ofn.lpstrCustomFilter= NULL
ofn.nMaxCustFilter = 0
ofn.nFilterIndex = 2
ofn.lpstrFile = @filename 'zstring buffer
ofn.nMaxFile = 255
ofn.lpstrFileTitle = NULL
ofn.nMaxFileTitle = 0
ofn.lpstrInitialDir = ?idir
ofn.lpstrTitle = ?title
ofn.Flags = OFN_PATHMUSTEXIST or OFN_FILEMUSTEXIST or OFN_HIDEREADONLY
ofn.nFileOffset = 0
ofn.nFileExtension = 0
ofn.lpstrDefExt = NULL
ofn.lCustData = 0
ofn.lpfnHook = 0
ofn.lpTemplateName = NULL
'
retval = GetOpenFileName(ofn)
'http://msdn.microsoft.com/en-us/library/windows/desktop/ms646916(v=vs.85).aspx
'if retval=0 then print "Dialog Error " CommDlgExtendedError
return filename
'
End Function
'======================
' Main
' opening folder
dir="C:\Temp"
' Separator for the file filter
sep=chr(0)
filter= "*.exe;*.dll"
' "text"+sep+"*.txt"+sep+
' "basic"+sep+"*.bas;*.o2bas"+sep+
' "include"+sep+"*.inc"+sep+
' "header"+sep+"*.h"+sep+
' sep
title="File Browser"
hwnd=0
f=FileDialog(dir,filter,title,hwnd,OFN_EXPLORER or OFN_OVERWRITEPROMPT or OFN_HIDEREADONLY)
if f then print f