Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple file selection in ui_choose_file #559

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions libs/ui/ui_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) )
Expand All @@ -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) {
Expand Down