Re: Save As options and parameters

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

Voila! I love hacking Win32Lib. Here's a version of getSaveFileName() that
returns the index of the selected file type. Its simply a matter of fetching
and returning another value from the 'ofn' structure. Of course, it's up to
you to determine how to use the index from the filter list. It's basically a
matter of storing your filters properly so you can look them up with the
returned index.

-- begin code --
global function getSaveFileName2( integer id, sequence fName, sequence
filters )
-- getSaveFileName2()
-- returns { File name, Filter Index ) on success
-- returns {} on user cancel

    atom ofn, flags
    atom fIndex -- filter index

    -- build the structure
    if find("DIALOG FLAGS", upper(filters)) = 0 then
        -- Default setting
        flags = or_bits(OFN_OVERWRITEPROMPT, OFN_HIDEREADONLY)
    else
        flags = 0
    end if
    ofn = buildDefaultOfn( id, fName, filters, flags) -- warn if exists

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

    -- release the structure and strings
    release_mem( ofn )

    -- return result
    return {fName, fIndex}

end function
-- end code --

~Greg


----- Original Message -----
From: "Guest" <guest at RapidEuphoria.com>
To: <EUforum at topica.com>
Sent: Wednesday, February 11, 2004 10:56 AM
Subject: Save As options and parameters


>
>
> posted by: a.admin at myway.it
>
> In several demo programs I find the 'Save As' instruction. Let's take the
>
> .\Win32lib-59-1\Demo\GENERIC editor.EXW
>
> -- 07/Sep/2000 Wolfgang Fritz
> --------------------------------------------------------------------
> -- This demo shows off a lot of the features of Win32Lib, including:
> --
> -- Menus
> -- File Open/Save/SaveAs dialogs
>
>
> constant FileTypes = {
>     "dialog flags", {OFN_ALLOWMULTISELECT},
>     "Text File", "*.TXT",
>     "Euphoria Program", "*.EX;*.EXW;*.E;*.EW",
>     "All Files", "*.*" }
>
> and then
>
>     fName = getSaveFileName( Generic, openFileName, FileTypes )
>
>     if length(fName) = 0 then
>         return
>     end if
>
>     -- save the file
>     saveFile( fName )
>
>
> The question is to what do they serve all these defined FileTypes, since
'fName' will not include any of them, even if choosed?
>
> I mean, if I select "Euphoria Program", I expect one of the
"*.EX;*.EXW;*.E;*.EW" be appended to the typed name, exactly as every
Windows program naturally does.
>
> As is, this option is a booby-trap, 'cause it creates for more the
illusion...
> Is there a way to get the selected file_type, in order to add it before
saving ?
>
> Thanks to everyone.
>
> Antonio Alessi
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>
>

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

Search



Quick Links

User menu

Not signed in.

Misc Menu