Skip to content

Commit

Permalink
GUI: Windows native Choose file dialog
Browse files Browse the repository at this point in the history
git-svn-id: https://freearc.svn.sourceforge.net/svnroot/freearc@75 3a4f7f31-9599-433d-91b1-573e8b61252c
  • Loading branch information
bulatz committed Feb 14, 2009
1 parent 54b556b commit 8f3f77e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,11 @@ int BrowseForFile(TCHAR *prompt, TCHAR *in_filename, TCHAR *out_filename)
OPENFILENAME ofn;
ZeroMemory (&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = GetActiveWindow();
ofn.lpstrFile = out_filename;
ofn.nMaxFile = MY_FILENAME_MAX;

_tcscpy (out_filename, in_filename);

return GetOpenFileName(&ofn)? 1 : 0;
}
Expand Down
8 changes: 5 additions & 3 deletions GUI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -768,12 +768,14 @@ chooseFile parentWindow dialogType dialogTitle filters getFilename setFilename =
withCFilePath title $ \c_prompt -> do
withCFilePath filename $ \c_filename -> do
allocaBytes (long_path_size*4) $ \c_outpath -> do
result <- c_BrowseForFolder c_prompt c_filename c_outpath
result <- case dialogType of
FileChooserActionSelectFolder -> c_BrowseForFolder c_prompt c_filename c_outpath
_ -> c_BrowseForFile c_prompt c_filename c_outpath
when (result/=0) $ do
setFilename =<< peekCFilePath c_outpath

foreign import ccall safe "Environment.h BrowseForFolder"
c_BrowseForFolder :: CFilePath -> CFilePath -> CFilePath -> IO CInt
foreign import ccall safe "Environment.h BrowseForFolder" c_BrowseForFolder :: CFilePath -> CFilePath -> CFilePath -> IO CInt
foreign import ccall safe "Environment.h BrowseForFile" c_BrowseForFile :: CFilePath -> CFilePath -> CFilePath -> IO CInt

#else

Expand Down

0 comments on commit 8f3f77e

Please sign in to comment.