#case capital

#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 word  WORD
typedef dword DWORD
typedef long  LPARAM
typedef sys   SYS,HWND,HINSTANCE,LPOFNHOOKPROC
typedef char  *LPCSTR,*LPSTR


typedef struct tagOFNA {
   DWORD        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;

def OPENFILENAME OPENFILENAMEA

Declare GetModuleHandle      lib "kernel32.dll" alias "GetModuleHandleA" (optional char*n) as sys
Declare GetOpenFileName      Lib "comdlg32.dll" Alias "GetOpenFileNameA" (OPENFILENAME*opfn) As sys
Declare CommDlgExtendedError Lib "comdlg32.dll" () as dword


'FileDialog( $ iDir , $ filter ,$ title , % parent ,% flag )

Function FileDialog(string iDir, filter, Title, sys Hwnd, Flags) As String
'==================

def FileNameLen 512
Dim ofn As OPENFILENAME
Dim filename[FileNameLen] As zstring
int retval	
 ofn.lStructSize       = sizeof(OPENFILENAME)
 ofn.hwndOwner         = hWnd
 ofn.hInstance         = GetModuleHandle
 ofn.lpstrFilter       = filter
 ofn.lpstrCustomFilter = null
 ofn.nMaxCustFilter    = 0
 ofn.nFilterIndex      = 2
 ofn.lpstrFile         = filename 'coupling to zstring buffer
 ofn.nMaxFile          = FileNameLen
 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

'dir="OxygenBasic\demos\GUI"
string dir=""
string sep=chr(0)
'filter=""
string filter="text"+sep+"*.txt"+sep+
       "basic"+sep+"*.bas;*.o2bas"+sep+
       "include"+sep+"*.inc"+sep+
       "header"+sep+"*.h"+sep+
       sep

string title="Test File Opening Dialog"
sys hwnd=0
string f
f=FileDialog(dir,filter,title,hwnd,OFN_EXPLORER or OFN_OVERWRITEPROMPT or OFN_HIDEREADONLY)
if f then print f

