diff --git a/extra/file-picker/windows/windows.factor b/extra/file-picker/windows/windows.factor index dba941fa63..ef4f8b78b4 100644 --- a/extra/file-picker/windows/windows.factor +++ b/extra/file-picker/windows/windows.factor @@ -1,8 +1,8 @@ USING: accessors alien.c-types alien.data alien.strings alien.syntax classes.struct destructors file-picker io.encodings.string io.encodings.utf8 kernel libc literals math -system windows windows.kernel32 windows.shell32 windows.types -windows.user32 ; +system windows windows.comdlg32 windows.kernel32 windows.shell32 +windows.types windows.user32 ; IN: file-picker.windows LIBRARY: shell32 @@ -70,4 +70,11 @@ M: windows open-file-dialog ] if* ] with-destructors ; -M: windows save-file-dialog ; +M: windows save-file-dialog + [ + drop ! TODO: support supplying a suggested file name or path + OPENFILENAME [ malloc-struct &free ] [ heap-size ] bi >>lStructSize + MAX_UNICODE_PATH [ 2 calloc &free >>lpstrFile ] [ >>nMaxFile ] bi + OFN_OVERWRITEPROMPT >>Flags + dup GetSaveFileName zero? [ drop f ] [ lpstrFile>> ] if + ] with-destructors ; diff --git a/extra/windows/comdlg32/authors.txt b/extra/windows/comdlg32/authors.txt new file mode 100644 index 0000000000..8e1955f8e1 --- /dev/null +++ b/extra/windows/comdlg32/authors.txt @@ -0,0 +1 @@ +Alexander Ilin diff --git a/extra/windows/comdlg32/comdlg32.factor b/extra/windows/comdlg32/comdlg32.factor new file mode 100644 index 0000000000..4b1ba1bcec --- /dev/null +++ b/extra/windows/comdlg32/comdlg32.factor @@ -0,0 +1,40 @@ +! Copyright (C) 2017 Alexander Ilin. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors alien alien.c-types alien.libraries +alien.syntax classes.struct destructors kernel libc math +sequences strings windows windows.types ; + +IN: windows.comdlg32 + +<< "comdlg32" "comdlg32.dll" stdcall add-library >> + +LIBRARY: comdlg32 + +CONSTANT: OFN_OVERWRITEPROMPT 2 + +STRUCT: OPENFILENAME + { lStructSize DWORD } + { hwndOwner HWND } + { hInstance HINSTANCE } + { lpstrFilter LPCTSTR } + { lpstrCustomFilter LPTSTR } + { nMaxCustFilter DWORD } + { nFilterIndex DWORD } + { lpstrFile LPTSTR } + { nMaxFile DWORD } + { lpstrFileTitle LPTSTR } + { nMaxFileTitle DWORD } + { lpstrInitialDir LPCTSTR } + { lpstrTitle LPCTSTR } + { Flags DWORD } + { nFileOffset WORD } + { nFileExtension WORD } + { lpstrDefExt LPCTSTR } + { lCustData LPARAM } + { lpfnHook PVOID } + { lpTemplateName LPCTSTR } ; + +TYPEDEF: OPENFILENAME* LPOPENFILENAME + +FUNCTION: BOOL GetSaveFileNameW ( LPOPENFILENAME lpofn ) +ALIAS: GetSaveFileName GetSaveFileNameW diff --git a/extra/windows/comdlg32/platforms.txt b/extra/windows/comdlg32/platforms.txt new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/extra/windows/comdlg32/platforms.txt @@ -0,0 +1 @@ +windows