diff --git a/libs/ui/ui_win.c b/libs/ui/ui_win.c index a7ea27a9a..36c7e0015 100644 --- a/libs/ui/ui_win.c +++ b/libs/ui/ui_win.c @@ -281,9 +281,12 @@ HL_PRIM vbyte *HL_NAME(ui_choose_file)( bool forSave, vdynamic *options ) { wref *win = (wref*)hl_dyn_getp(options,hl_hash_utf8("window"), &hlt_abstract); varray *filters = (varray*)hl_dyn_getp(options,hl_hash_utf8("filters"),&hlt_array); wchar_t *fileName = (wchar_t*)hl_dyn_getp(options,hl_hash_utf8("fileName"),&hlt_bytes); + bool multiple = hl_dyn_geti(options,hl_hash_utf8("multiple"),&hlt_bool); + OPENFILENAME op; wchar_t filterStr[1024]; - wchar_t outputFile[1024] = {0}; + // Add two extra wchar for multi-file terminator. + wchar_t outputFile[2052] = {0}; ZeroMemory(&op, sizeof(op)); op.lStructSize = sizeof(op); op.hwndOwner = win ? win->h : NULL; @@ -307,6 +310,8 @@ HL_PRIM vbyte *HL_NAME(ui_choose_file)( bool forSave, vdynamic *options ) { op.lpstrInitialDir = hl_dyn_getp(options,hl_hash_utf8("directory"),&hlt_bytes); op.lpstrTitle = hl_dyn_getp(options,hl_hash_utf8("title"),&hlt_bytes); op.Flags |= OFN_NOCHANGEDIR; + if( multiple ) + op.Flags |= OFN_ALLOWMULTISELECT | OFN_EXPLORER; if( forSave ) { op.Flags |= OFN_OVERWRITEPROMPT; if( !GetSaveFileName(&op) ) @@ -316,7 +321,7 @@ HL_PRIM vbyte *HL_NAME(ui_choose_file)( bool forSave, vdynamic *options ) { if( !GetOpenFileName(&op) ) return NULL; } - return hl_copy_bytes((vbyte*)outputFile, (int)(wcslen(outputFile)+1)*2); + return hl_copy_bytes((vbyte*)outputFile, sizeof(outputFile)); } HL_PRIM bool HL_NAME(ui_set_clipboard_text)(char* text) {