Documentation for Win32lib v0.60.6
Table of Contents

Dialogs

These are functions the bring up common dialogs.


  • func buildDefaultOfn( integer window, sequence file, sequence filters, atom flags )   Creates a OpenFile structure used by the standard dialog.
  • func getColorDialog( window, default color )   "Get Color" Dialog
  • proc getFindText( id )   Opens the "Find" Dialog
  • func getFontDialog( window )   "Get Font" Dialog
  • func getOpenFileName( window, file, filters )   "Open File" dialog.
  • func getPageSetup()   Page setup dialog
  • func getPageSetupEx(atom Flags)   Page setup dialog
  • proc getReplaceText( id )   Opens the "Replace" Dialog
  • func getSaveFileName( window, file, filters )   "Save File" dialog.

    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    buildDefaultOfn
    ( integer window, sequence file, sequence filters, atom flags )

    Creates a OpenFile structure used by the standard dialog.

    Returns: The address of the structure.

    Category: Dialogs

    Note, you must call w32release_mem() when you have finished with the structure.

           atom lOfn
           lOfn = buildDefaultOfn(0, "newfile.txt", {"Text Files","*.txt"},
                    OFN_FILEMUSTEXIST)
           w32store(lOfn, OfnDefExt, "TXT")
           if w32Func(xGetOpenFileName, {lOfn}) then
             -- get the name
             fName = w32fetch( lOfn, ofnFile )
             fNamePtr = w32fetch( lOfn, ofnFileOffset)
             fExtPtr = w32fetch( lOfn, ofnFileExtension)
           else
             fName = ""
           end if
           w32release_mem(lOfn)
    

    See Also: getColorDialog, getFindText, getFontDialog, getOpenFileName, getPageSetup, getPageSetupEx, getReplaceText, getSaveFileName


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    getColorDialog
    ( window, default color )

    "Get Color" Dialog

    Returns: Selected color, or default color if nothing selected.

    Category: Dialogs

    Calling this function brings up the modal "Select Color" dialog, allowing the user to select a color from the default color list, or add a color to the custom color list.

    The parameter passed in default color is an atom representing the default color to select, in #RRGGBB format. Passing -1 specifies that the color black (#000000) is the default color.

    Example:

              -- get a color; red ( #FF0000 ) is the default
              atom color
              color = getColorDialog( Window, #FF0000 )
    

    See Also: buildDefaultOfn, getFindText, getFontDialog, getOpenFileName, getPageSetup, getPageSetupEx, getReplaceText, getSaveFileName


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    getFindText
    ( id )

    Opens the "Find" Dialog

    Category: Dialogs

    id should be the id of the control in which the Find Dialog will search. The Find dialog is a modeless dialog, which means that it will remain open and on top, until the user closes it.

    See Also: buildDefaultOfn, getColorDialog, getFontDialog, getOpenFileName, getPageSetup, getPageSetupEx, getReplaceText, getSaveFileName


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    getFontDialog
    ( window )

    "Get Font" Dialog

    Returns: { font name, points, style flags, color } or -1 if cancelled.

    Category: Dialogs

    Calling this function brings up the modal "Select Font" dialog, allowing the user to select a font from the list of available fonts.

    Example:

              integer flags, points
              atom color
              sequence font
              object result
    

    -- get a font choice from the user result = getFontDialog( MyWindow ) if sequence( result ) then -- get the values font = result[1] points = result[2] flags = result[3] color = result[4] end if

    See Also: buildDefaultOfn, getColorDialog, getFindText, getOpenFileName, getPageSetup, getPageSetupEx, getReplaceText, getSaveFileName


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    getOpenFileName
    ( window, file, filters )

    "Open File" dialog.

    Returns: Selected file name, or empty sequence if cancelled.

    Category: Dialogs

    Calling this function brings up the modal "Open File" dialog, allowing the user to select a file name. file is a sequence holding the default file name. filters is a list of patterns to limit displayed files to, in the format:

          { "text", pattern, "text", pattern ... }
    

    For example:

          constant FileTypes = {
              "Text File", "*.TXT",
              "Euphoria Program", "*.EX;*.EXW;*.E;*.EW",
              "All Files", "*.*" }
    

    Note that a pattern can contain several different values.

    Example:

              -- get file name to open
              sequence filename
    

    filename = getOpenFileName( TheWindow, -- parent window "", -- no default name { "Text File", "*.TXT", -- text files "All Files", "*.*" } ) -- everything else

    It is possible to modify the default flags set for the dialog by adding a special 'pattern' of "DIALOG FLAGS" followed by the additional flags required. The usual use of this is to allow multiple files to be selected.

    Multiple Selections
    When doing this, the routine returns a sequence of sequences. The first element is the directory name, which always ends with a '\', and each subsequent element is a file name selected from that directory.

              filename = getOpenFileName(
                              TheWindow,                  -- parent window
                              "",                         -- no default name
                              { "Dialog Flags", {OFN_ALLOWMULTISELECT},
                                "Text File", "*.TXT",     -- text files
                                "All Files", "*.*" } )    -- everything else
    

    if length(filename) > 0 then theDir = filename[1] for i = 2 to length(filename) do ProcessTheFile( theDir, filename[i]) end for end if

    See Also: buildDefaultOfn, getColorDialog, getFindText, getFontDialog, getPageSetup, getPageSetupEx, getReplaceText, getSaveFileName


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    getPageSetup
    ()

    Page setup dialog

    Returns: SEQUENCE: { paperSize, margins, orientation, papertype } or w32False if the user cancels

    Category: Dialogs

    This calls getPageSetupEx() using the default flags of ...

    See Also: buildDefaultOfn, getColorDialog, getFindText, getFontDialog, getOpenFileName, getPageSetupEx, getReplaceText, getSaveFileName


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    getPageSetupEx
    (atom Flags)

    Page setup dialog

    Returns: SEQUENCE : { paperSize, margins , orientation, papertype} or w32False if the user cancels

    Category: Dialogs

    Flags are the or'd flags...

  • paperSize: { x, y }
  • margins: {left, top, right, bottom }
  • orientation: Either DMORIENT_PORTRAIT or DMORIENT_LANDSCAPE.
  • papertype: The numeric code for the type of paper.

    This also sets the printer to the user's selection.

    See Also: buildDefaultOfn, getColorDialog, getFindText, getFontDialog, getOpenFileName, getPageSetup, getReplaceText, getSaveFileName


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    getReplaceText
    ( id )

    Opens the "Replace" Dialog

    Category: Dialogs

    id should be the id of the control in which the Replace Dialog will search. The Replace dialog is a modeless dialog, which means that it will remain open and on top, until the user closes it.

    See Also: buildDefaultOfn, getColorDialog, getFindText, getFontDialog, getOpenFileName, getPageSetup, getPageSetupEx, getSaveFileName


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    getSaveFileName
    ( window, file, filters )

    "Save File" dialog.

    Returns: Selected file name, or empty sequence if cancelled.

    Category: Dialogs

    Calling this function brings up the modal "Save File" dialog, allowing the user to select a file name. file is a sequence holding the default file name. filters is a list of patterns to limit displayed files to, in the format:

          { "text", pattern, "text", pattern ... }
    

    For example:

          constant FileTypes = {
              "Text File", "*.TXT",
              "Euphoria Program", "*.EX;*.EXW;*.E;*.EW",
              "All Files", "*.*" }
    

    Note that a pattern can contain several different values.

    Example:

              -- get file name to save
              filename = getSaveFileName(
                              TheWindow,                  -- parent window
                              "MyFile.txt",               -- default name
                              { "Text File", "*.TXT",     -- text files
                                "All Files", "*.*" } )    -- everything else
    

    See Also: buildDefaultOfn, getColorDialog, getFindText, getFontDialog, getOpenFileName, getPageSetup, getPageSetupEx, getReplaceText