'$Let UNICODE = TRUE
Const MAX_PATH
= 65534 'Since the MAX_PATH for unicode is 32767 and it is a wide string, two bytes are needed per character. So, double the length
Const OFN_ALLOWMULTISELECT
= &H00000200 Const OFN_CREATEPROMPT
= &H00002000 Const OFN_DONTADDTORECENT
= &H02000000 Const OFN_EXPLORER
= &H00080000 Const OFN_EXTENSIONDIFFERENT
= &H00000400 Const OFN_FILEMUSTEXIST
= &H00001000 Const OFN_FORCESHOWHIDDEN
= &H10000000 Const OFN_HIDEREADONLY
= &H00000004 Const OFN_NOCHANGEDIR
= &H00000008 Const OFN_NODEREFERENCELINKS
= &H00100000 Const OFN_NONETWORKBUTTON
= &H00020000 Const OFN_NOREADONLYRETURN
= &H00008000 Const OFN_NOTESTFILECREATE
= &H00010000 Const OFN_NOVALIDATE
= &H00000100 Const OFN_OVERWRITEPROMPT
= &H00000002 Const OFN_PATHMUSTEXIST
= &H00000800 Const OFN_READONLY
= &H00000001 Const OFN_SHAREAWARE
= &H00004000 Const OFN_SHOWHELP
= &H00000010 Const SAVE_DIALOG
= &H01000000 Const OPEN_DIALOG
= &H02000000
file
= ComDlgFileName
("Open Source File", _CWD$, "QB64 Files (*.BAS, *.BI, *.BM, *.FRM)|*.BAS;*.BI;*.BM;*.FRM|C/C++ Files (*.CPP, *.HPP, *.H, *.C)|*.CPP;*.HPP;*.H;*.C|All Files|*.*", OFN_FORCESHOWHIDDEN
)
'Print SelectFolder("Pick a folder")
As _Offset hwndOwner
, hInstance
, lpstrFilter
, lpstrCustomFilter
As _Offset lpstrDefExt
, lCustData
, lpfnHook
, lpTemplateName
, pvReserved
Title
= ANSIToUnicode
(Title
+ Chr$(0)) InitialDir
= ANSIToUnicode
(InitialDir
+ Chr$(0)) Filter
= ANSIToUnicode
(Filter
+ Chr$(0) + Chr$(0)) InitialDir
= InitialDir
+ Chr$(0) ofn.lStructSize
= Len(ofn
) ofn.nFilterIndex = 1
ofn.nMaxFile
= Len(oFile
) ofn.lpstrFileTitle = ofn.lpstrFile
ofn.nMaxFileTitle = ofn.nMaxFile
ofn.lpstrInitialDir
= _Offset(InitialDir
) If OFN_ALLOWMULTISELECT
And Flags
Then Flags
= Flags
Or OFN_EXPLORER
ofn.Flags = Flags
Dim As _Offset tmp: tmp
= ofn.lpstrFile
+ (ofn.nFileOffset
* 2) Dim As _MEM dir: dir
= _Mem(ofn.lpstrFile
, wcslen
(ofn.lpstrFile
) * 2) directory
= Space$(wcslen
(ofn.lpstrFile
) * 2) Dim As _MEM dir: dir
= _Mem(ofn.lpstrFile
, tcslen
(ofn.lpstrFile
)) directory
= Space$(tcslen
(ofn.lpstrFile
)) file
= Space$(wcslen
(tmp
) * 2) _MemGet pFiles
, pFiles.OFFSET
, file
outfiles = directory + ANSIToUnicode("\") + file
outfiles = outfiles + ANSIToUnicode("|") + directory + ANSIToUnicode("\") + file
i = i + 1
tmp
= tmp
+ Len(file
) + 2 pFiles
= _Mem(tmp
, wcslen
(tmp
) * 2) _MemGet pFiles
, pFiles.OFFSET
, file
outfiles = directory + "\" + file
outfiles = outfiles + "|" + directory + "\" + file
i = i + 1
tmp = tmp + (tcslen(tmp) + 1)
pFiles
= _Mem(tmp
, tcslen
(tmp
)) file
= wCharPtrToString
(_Offset(directory
)) file = directory
ComDlgFileName = file
outfiles
= wCharPtrToString
(_Offset(outfiles
)) ComDlgFileName = outfiles
ComDlgFileName = selectedfile
ofn.Flags = Flags
selectedfile
= wCharPtrToString
(_Offset(oFile
)) ComDlgFileName = selectedfile
As _Offset hwndOwner
, pidlRoot
, pszDisplayName
, lpszTitle
title
= ANSIToUnicode
(title
+ Chr$(0)) browse.pszDisplayName
= _Offset(folder
) pfolder
= SHBrowseForFolder
(_Offset(browse
)) SelectFolder
= wCharPtrToString
(_Offset(resolvedPath
)) SelectFolder
= Mid$(resolvedPath
, 1, InStr(resolvedPath
, Chr$(0)) - 1)
Dim As _Offset wlen: wlen
= wcslen
(wchar
) * 2 'The length does not account for the 2-byte nature of Unicode so we multiply by 2 Dim As _MEM pChar: pChar
= _Mem(wchar
, wlen
) 'Declaring a new _MEM block and setting it to grab the number of bytes referenced by wlen at pointer wchar Dim As String char: char
= Space$(wlen
) 'Declaring a new string large enough to hold the unicode string _MemGet pChar
, pChar.OFFSET
, char
'Storing the data in the string wCharPtrToString = UnicodeToANSI(char) 'Returning the converted Unicode string
'$INCLUDE:'unicodetoansi.bas'