file-picker: implement save-file-dialog on windows

char-rename
Alexander Iljin 2017-05-25 02:37:39 +03:00 committed by John Benediktsson
parent 646f14f249
commit 4ceb098907
4 changed files with 52 additions and 3 deletions

View File

@ -1,8 +1,8 @@
USING: accessors alien.c-types alien.data alien.strings USING: accessors alien.c-types alien.data alien.strings
alien.syntax classes.struct destructors file-picker alien.syntax classes.struct destructors file-picker
io.encodings.string io.encodings.utf8 kernel libc literals math io.encodings.string io.encodings.utf8 kernel libc literals math
system windows windows.kernel32 windows.shell32 windows.types system windows windows.comdlg32 windows.kernel32 windows.shell32
windows.user32 ; windows.types windows.user32 ;
IN: file-picker.windows IN: file-picker.windows
LIBRARY: shell32 LIBRARY: shell32
@ -70,4 +70,11 @@ M: windows open-file-dialog
] if* ] if*
] with-destructors ; ] 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 ;

View File

@ -0,0 +1 @@
Alexander Ilin

View File

@ -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

View File

@ -0,0 +1 @@
windows