Re: win32lib: getSaveFileName

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Thu, 5 Oct 2000 05:28:25 -0400, Judith Evans wrote:

>Is there a way to know, if several file file filters are used in
>getSaveFileName(), to know which one the user selects? What I'm thinking of
>is:
>
>FILETYPES=("Euphoria DOS,*.ex",
>           "Euphoria WIN,*.exw",
>           "Text Files, *.txt",
>           "All Files, *.*"}
>
>Thanks,
>Judith Evans

No problem, if you don't mind modifying your Win32Lib...

Modify getSaveFileName as follows:
--------------------------------------------------------------
global function getSaveFileName( integer id, sequence fName, sequence
filters )
    integer fIndex
    atom ofn

    -- build the structure
    ofn = buildDefaultOfn( id, fName, filters, or_all( {
        OFN_OVERWRITEPROMPT } ) )   -- warn if exists

    -- call the routine
    if c_func(xGetSaveFileName, {ofn}) then
        -- get the name
        fName = fetch( ofn, ofnFile )
        -- ADDED: get filter index
        fIndex = fetch( ofn, ofnFilterIndex )
    else
        -- cancelled
        fName = ""
    end if

    -- release the structure and strings
    free( ofn )
    free_strings()

    -- return result
    -- ADDED: return a sequence that includes the filter index
    return { fName, fIndex }

end function
--------------------------------------------------------------

and a demo:
--------------------------------------------------------------
include Win32Lib.ew

constant
  Win = create( Window, "save demo", 0, 20, 20, 200, 200, 0 ),
  FILETYPES={"Euphoria DOS","*.ex",
             "Euphoria WIN","*.exw",
             "Text Files", "*.txt",
             "All Files", "*.*"}

sequence result
integer index

result = getSaveFileName( Win, "", FILETYPES )
index = 2*(result[2]-1)+1

puts(1, "File name: " & result[1] & "\n" )

puts(1, "File type: " & FILETYPES[index] &
        " -> " & FILETYPES[index+1] )

WinMain(Win,Normal)
--------------------------------------------------------------

-- Brian

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu