mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 19:33:40 +08:00
feat: file dialog filters for win32
This commit is contained in:
parent
393a4fceb2
commit
bc570999e8
@ -1792,7 +1792,7 @@ struct webview_priv
|
|||||||
WEBVIEW_API void webview_dialog(struct webview *w,
|
WEBVIEW_API void webview_dialog(struct webview *w,
|
||||||
enum webview_dialog_type dlgtype, int flags,
|
enum webview_dialog_type dlgtype, int flags,
|
||||||
const char *title, const char *arg,
|
const char *title, const char *arg,
|
||||||
char *result, size_t resultsz)
|
char *result, size_t resultsz, char *filter)
|
||||||
{
|
{
|
||||||
if (dlgtype == WEBVIEW_DIALOG_TYPE_OPEN ||
|
if (dlgtype == WEBVIEW_DIALOG_TYPE_OPEN ||
|
||||||
dlgtype == WEBVIEW_DIALOG_TYPE_SAVE)
|
dlgtype == WEBVIEW_DIALOG_TYPE_SAVE)
|
||||||
@ -1832,6 +1832,32 @@ struct webview_priv
|
|||||||
FOS_NOTESTFILECREATE | FOS_NODEREFERENCELINKS |
|
FOS_NOTESTFILECREATE | FOS_NODEREFERENCELINKS |
|
||||||
FOS_FORCESHOWHIDDEN | FOS_DEFAULTNOMINIMODE;
|
FOS_FORCESHOWHIDDEN | FOS_DEFAULTNOMINIMODE;
|
||||||
}
|
}
|
||||||
|
if (filter[0] != '\0')
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
int i=0;
|
||||||
|
char* token;
|
||||||
|
char* filter_dup = strdup(filter);
|
||||||
|
for (count=1; filter[count]; filter[count]==',' ? count++ : *filter++);
|
||||||
|
COMDLG_FILTERSPEC rgSpec[count];
|
||||||
|
char* filters[count];
|
||||||
|
token = strtok(filter_dup, ",");
|
||||||
|
while(token != NULL)
|
||||||
|
{
|
||||||
|
filters[i] = token;
|
||||||
|
token = strtok(NULL, ",");
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
for (int i=0; i < count; i++) {
|
||||||
|
wchar_t *wFilter = (wchar_t *)malloc(4096);
|
||||||
|
MultiByteToWideChar(CP_ACP, 0, filters[i], -1, wFilter, 4096);
|
||||||
|
rgSpec[i].pszName = wFilter;
|
||||||
|
rgSpec[i].pszSpec = wFilter;
|
||||||
|
}
|
||||||
|
if (dlg->lpVtbl->SetFileTypes(dlg, count, rgSpec) != S_OK) {
|
||||||
|
goto error_dlg;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (dlg->lpVtbl->GetOptions(dlg, &opts) != S_OK)
|
if (dlg->lpVtbl->GetOptions(dlg, &opts) != S_OK)
|
||||||
{
|
{
|
||||||
goto error_dlg;
|
goto error_dlg;
|
||||||
|
Loading…
Reference in New Issue
Block a user