home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / FILEDLG6.ZIP / FILEDLG.H < prev    next >
C/C++ Source or Header  |  1990-11-14  |  26KB  |  515 lines

  1. /****************************************************************************
  2.  * FILEDLG.H                                                                *
  3.  *                                                                          *
  4.  *  This header file contains the function declarations and constant        *
  5.  *  definitions for the standard open file and save file dialog             *
  6.  *  boxes.                                                                  *
  7.  *                                                                          *
  8.  *                                                                          *
  9.  *  Modifications -                                                         *
  10.  *      09-Aug-1989 : Initial version.                                      *
  11.  *      11-Oct-1990 : Changed "CALLBACK" to "EXPENTRY"                      *
  12.  *                                                                          *
  13.  *  (c)Copyright 1990 Rick Yoder                                            *
  14.  ****************************************************************************/
  15.  
  16. #if !defined(_FILEDLG_INCLUDED)
  17. #define _FILEDLG_INCLUDED
  18.  
  19. #if !defined(_QC)
  20. #pragma comment( lib,"filedlg.lib" )
  21. #endif
  22.  
  23. /****************************************************************************
  24.  *  Constant Definitions                                                    *
  25.  ****************************************************************************/
  26.     #define FDLG_OK         0   // Function exit codes
  27.     #define FDLG_CANCEL     1
  28.  
  29.     #define FDLG_OPEN       1   // Used by help functions.
  30.     #define FDLG_SAVE       2
  31.     #define FDLG_FIND       3
  32. /****************************************************************************/
  33.  
  34.  
  35. /****************************************************************************
  36.  *  Open File dialog box procedure                                          *
  37.  ****************************************************************************/
  38. extern USHORT EXPENTRY FileOpenDlg( HWND hwndOwner,
  39.                                     PSZ pszTitle,PSZ pszIns,
  40.                                     PSZ pszShowSpec,USHORT usShowAttr,
  41.                                     void (EXPENTRY *pfnHelpProc)(HWND hDlg),
  42.                                     PSZ pszFile,
  43.                                     PHFILE phf,
  44.                                     ULONG ulFileSize,
  45.                                     PUSHORT pusAction,
  46.                                     USHORT usAttribute,
  47.                                     USHORT fsOpenFlags,
  48.                                     USHORT fsOpenMode,
  49.                                     ULONG ulReserved  );
  50. /****************************************************************************\
  51. The FileOpenDlg function displays a dialog box and opens the file selected
  52. by the user. This function returns a handle that can be used to read from
  53. and write to the file, as well as to retrieve information about the file.
  54.  
  55. Parameters   Description
  56. ----------------------------------------------------------------------------
  57. hwndOwner    Identifies the owner window.
  58.  
  59. pszTitle     Points to the null-terminated string that specifies the
  60.              dialog box title. If pszTitle is NULL then the default value
  61.              "Open File" is used.
  62.  
  63. pszIns       Points to the null-terminated string that specifies the
  64.              dialog box instructions. If pszIns is NULL then the default
  65.              value "Select file or type filename" is used.
  66.  
  67. pszShowSpec  Points the the null-terminated string that specifies the
  68.              initial search specifications for the files that are to
  69.              be listed in the file list box.
  70.  
  71. usShowAttr   Specifies the attribute(s) of the files that are to be
  72.              listed in the file list box. This parameter can be a
  73.              combination of the following values
  74.  
  75.              Value          Meaning
  76.              ---------------------------------------------------------------
  77.              FILE_NORMAL    List all normal files.
  78.  
  79.              FILE_READONLY  List read-only files.
  80.  
  81.              FILE_HIDDEN    List hidden files.
  82.  
  83.              FILE_SYSTEM    List system files.
  84.  
  85.              FILE_ARCHIVED  List archived files.
  86.  
  87. pfnHelpProc  Points to the user supplied help procedure. This procedure
  88.              is called whenever the help button or the F1 key is pressed.
  89.              The HelpProc function is defined as follows:
  90.  
  91.              void EXPENTRY HelpProc( HWND hDlg )
  92.              The hDlg parameter is a handle to the open file dialog box.
  93.  
  94.              When the help procedure is called, the identity of the
  95.              dialog box that requested the help can be determined
  96.              by a call to WinQueryWindowUShort(hDlg,QWS_ID). The
  97.              value returned can be one of the following:
  98.  
  99.                 FDLG_OPEN ..... Help requested by open dialog box.
  100.                 FDLG_FIND ..... Help requested by find file dialog box.
  101.                 FDLG_SAVE ..... Help requested by save file dialog box.
  102.  
  103.              If no help is available, set the pfnHelpProc parameter to
  104.              NULL. This will cause the Help button to be removed from
  105.              the dialog box.
  106.  
  107. pszFileName  Points to the location where the fully qualified filename of
  108.              the file selected by the user is to be stored. Use the
  109.              DosQSysInfo function to get the maximum path length in order
  110.              to determine how large to make the memory block pointed to
  111.              by pszFile.
  112.  
  113. phf          Points to the variable that receives the handle of the opened
  114.              file.
  115.  
  116. pusAction    Points to the variable receiving the value that specifies the
  117.              action taken by the FileOpenDlg function. If the dialog box is
  118.              cancelled then this value has no meaning. Otherwise, it is
  119.              one of the following values:
  120.  
  121.              Value           Meaning
  122.              ---------------------------------------------------------------
  123.              FILE_CREATED    File was created.
  124.  
  125.              FILE_EXISTED    File already existed.
  126.  
  127.              FILE_TRUNCATED  File existed and was truncated.
  128.  
  129. ulFileSize   Specifies the file's new size (in bytes). This parameter
  130.              applies only if the file is created or truncated. The size
  131.              specification has no effect on a file that is opened only for
  132.              reading.
  133.  
  134. usAttribute  Specifies the file attributes. This parameter can be a
  135.              combination of the following values:
  136.  
  137.              Value          Meaning
  138.              ---------------------------------------------------------------
  139.              FILE_NORMAL    File can be read from or written to.
  140.  
  141.              FILE_READONLY  File can be read from, but not written to.
  142.  
  143.              FILE_HIDDEN    File is hidden and does not appear in a
  144.                             directory listing.
  145.  
  146.              FILE_SYSTEM    File is a system file.
  147.  
  148.              FILE_ARCHIVED  File has been archived.
  149.  
  150.              File attributes apply only if the file is created.
  151.  
  152. fsOpenFlags  Specifies the action to take both when the file exists and when
  153.              it does not exist. This parameter may be one of the following
  154.              values:
  155.  
  156.              Value                        Meaning
  157.              ---------------------------------------------------------------
  158.              FILE_CREATE                  Create a new file; fail if the
  159.                                           file already exists.
  160.  
  161.              FILE_OPEN                    Open an existing file; fail if the
  162.                                           file does not exist.
  163.  
  164.              FILE_OPEN | FILE_CREATE      Open an existing file or create
  165.                                           the file if it does not exist.
  166.  
  167.              FILE_TRUNCATE                Open an existing file and change
  168.                                           to a given size.
  169.  
  170.              FILE_TRUNCATE | FILE_CREATE  Open an existing file and truncate
  171.                                           it, or create the file if it does
  172.                                           not exist.
  173.  
  174. fsOpenMode   Specifies the modes with which to open the file. It consists of
  175.              one access mode and one share mode. The other values are option
  176.              and can be given in any combination:
  177.  
  178.              Value                     Meaning
  179.              ---------------------------------------------------------------
  180.              OPEN_ACCESS_READONLY         Data can be read from the file but
  181.                                           not written to it.
  182.  
  183.              OPEN_ACCESS_READWRITE        Data can be read from or written
  184.                                           to the file.
  185.  
  186.              OPEN_ACCESS_WRITEONLY        Data can be written to the file
  187.                                           but not read from it.
  188.  
  189.              OPEN_SHARE_DENYNONE          Other processes can open the file
  190.                                           for any access: read-only,
  191.                                           write-only, or read-write.
  192.  
  193.              OPEN_SHARE_DENYREAD          Other processes can open the file
  194.                                           for write-only access but they
  195.                                           cannot open it for read-only or
  196.                                           read-write access.
  197.  
  198.              OPEN_SHARE_DENYREADWRITE     The current process has exclusive
  199.                                           access to the file. The file
  200.                                           cannot be opened by any process
  201.                                           (including the current process).
  202.  
  203.              OPEN_SHARE_DENYWRITE         Other processes can open the file
  204.                                           for read-only access but they
  205.                                           cannot open it for write-only or
  206.                                           read-write access.
  207.  
  208.              OPEN_FLAGS_FAIL_ON_ERROR     Any function that uses the file
  209.                                           handle returns immediately with an
  210.                                           error value if there is an I/O
  211.                                           error--for example, when the drive
  212.                                           door is open or a sector is
  213.                                           missing. If this value is not
  214.                                           specified, the system passes the
  215.                                           error to the system critical-error
  216.                                           handler, which then reports the
  217.                                           error to the user with a
  218.                                           hard-error popup. The
  219.                                           fail-on-error flag is not
  220.                                           inherited by child processes.
  221.  
  222.                                           The fail-on-error flag applies to
  223.                                           all functions that use the file
  224.                                           handle, with the exception of the
  225.                                           DosDevIOCtl function.
  226.  
  227.              OPEN_FLAGS_NOINHERIT         The file handle is not available
  228.                                           to any child process started by
  229.                                           the current process. If this value
  230.                                           is not specified, any child
  231.                                           process started by the current
  232.                                           process may use the file handle.
  233.  
  234.              OPEN_FLAGS_WRITE_THROUGH     This flag applies to functions,
  235.                                           such as DosWrite, that write data
  236.                                           to the file. If this value is
  237.                                           specified, the system writes data
  238.                                           to the device before the given
  239.                                           function returns. Otherwise, the
  240.                                           system may store the data in an
  241.                                           internal file buffer and write the
  242.                                           data to the device only when the
  243.                                           buffer is full or the file is
  244.                                           closed.
  245.  
  246.              OPEN_FLAGS_NO_LOCALITY       There is no specific information
  247.                                           regarding the locality of
  248.                                           reference (the degree of
  249.                                           randomness with which the file is
  250.                                           accessed).
  251.  
  252.              OPEN_FLAGS_SEQUENTIAL        The file is accessed
  253.                                           sequentially.
  254.  
  255.              OPEN_FLAGS_RANDOM            The file is accessed randomly.
  256.  
  257.              OPEN_FLAGS_RANDOMSEQUENTIAL  The file is accessed randomly, but
  258.                                           that there is a degree of
  259.                                           sequential I/O within that random
  260.                                           access. For example, this flag is
  261.                                           specified if large blocks of data
  262.                                           are to be read or written at
  263.                                           random locations in the file.
  264.  
  265.              OPEN_FLAGS_NO_CACHE          The disk drive should not cache
  266.                                           data in I/O operations on this
  267.                                           file.
  268.  
  269. ulReserved   Specifies a reserved value; must be zero.
  270.  
  271. Return Value
  272.  
  273. The return value may be one of the following:
  274.  
  275.     FDLG_OK
  276.     FDLG_CANCEL
  277.  
  278. Comments
  279.  
  280. On exit from this function, hard-error processing will be enabled.
  281. \****************************************************************************/
  282.  
  283.  
  284. /****************************************************************************
  285.  *  Save File dialog box procedure                                          *
  286.  ****************************************************************************/
  287. extern USHORT EXPENTRY FileSaveDlg( HWND hwndOwner,
  288.                                     PSZ pszTitle,PSZ pszIns,
  289.                                     void (EXPENTRY *pfnHelpProc)(HWND hDlg),
  290.                                     PSZ pszDefault,
  291.                                     PSZ pszFile,
  292.                                     PHFILE phf,
  293.                                     ULONG ulFileSize,
  294.                                     PUSHORT pusAction,
  295.                                     USHORT usAttribute,
  296.                                     USHORT fsOpenFlags,
  297.                                     USHORT fsOpenMode,
  298.                                     ULONG ulReserved  );
  299. /****************************************************************************\
  300. The FileSaveDlg function displays a dialog box and opens the file selected
  301. by the user. This function returns a handle that can be used to read from
  302. and write to the file, as well as to retrieve information about the file.
  303.  
  304. Parameters   Description
  305. ----------------------------------------------------------------------------
  306. hwndOwner    Identifies the owner window.
  307.  
  308. pszTitle     Points to the null-terminated string that specifies the
  309.              dialog box title. If pszTitle is NULL then the default value
  310.              "Save File" is used.
  311.  
  312. pszIns       Points to the null-terminated string that specifies the
  313.              dialog box instructions. If pszIns is NULL then the default
  314.              value "Type filename" is used.
  315.  
  316. pfnHelpProc  Points to the user supplied help procedure. This procedure
  317.              is called whenever the help button or the F1 key is pressed.
  318.              The HelpProc function is defined as follows:
  319.  
  320.              void EXPENTRY HelpProc( HWND hDlg )
  321.              The hDlg parameter is a handle to the save file dialog box.
  322.  
  323.              When the help procedure is called, the identity of the
  324.              dialog box that requested the help can be determined
  325.              by a call to WinQueryWindowUShort(hDlg,QWS_ID). The
  326.              value returned can be one of the following:
  327.  
  328.                 FDLG_OPEN ..... Help requested by open dialog box.
  329.                 FDLG_FIND ..... Help requested by find file dialog box.
  330.                 FDLG_SAVE ..... Help requested by save file dialog box.
  331.  
  332.              If no help is available, set the pfnHelpProc parameter to
  333.              NULL. This will cause the Help button to be removed from
  334.              the dialog box.
  335.  
  336. pszDefault   Points to the null-terminated string that specifies the
  337.              default save file name.
  338.  
  339. pszFileName  Points to the location where the fully qualified filename of
  340.              the file selected by the user is to be stored. Use the
  341.              DosQSysInfo function to get the maximum path length in order
  342.              to determine how large to make the memory block pointed to
  343.              by pszFile.
  344.  
  345. phf          Points to the variable that receives the handle of the opened
  346.              file.
  347.  
  348. pusAction    Points to the variable receiving the value that specifies the
  349.              action taken by the FileSaveDlg function. If the dialog box is
  350.              cancelled then this value has no meaning. Otherwise, it is
  351.              one of the following values:
  352.  
  353.              Value           Meaning
  354.              ---------------------------------------------------------------
  355.              FILE_CREATED    File was created.
  356.  
  357.              FILE_EXISTED    File already existed.
  358.  
  359.              FILE_TRUNCATED  File existed and was truncated.
  360.  
  361. ulFileSize   Specifies the file's new size (in bytes). This parameter
  362.              applies only if the file is created or truncated. The size
  363.              specification has no effect on a file that is opened only for
  364.              reading.
  365.  
  366. usAttribute  Specifies the file attributes. This parameter can be a
  367.              combination of the following values:
  368.  
  369.              Value          Meaning
  370.              ---------------------------------------------------------------
  371.              FILE_NORMAL    File can be read from or written to.
  372.  
  373.              FILE_READONLY  File can be read from, but not written to.
  374.  
  375.              FILE_HIDDEN    File is hidden and does not appear in a
  376.                             directory listing.
  377.  
  378.              FILE_SYSTEM    File is a system file.
  379.  
  380.              FILE_ARCHIVED  File has been archived.
  381.  
  382.              File attributes apply only if the file is created.
  383.  
  384. fsOpenFlags  Specifies the action to take both when the file exists and when
  385.              it does not exist. This parameter may be one of the following
  386.              values:
  387.  
  388.              Value                        Meaning
  389.              ---------------------------------------------------------------
  390.              FILE_CREATE                  Create a new file; fail if the
  391.                                           file already exists.
  392.  
  393.              FILE_OPEN                    Open an existing file; fail if the
  394.                                           file does not exist.
  395.  
  396.              FILE_OPEN | FILE_CREATE      Open an existing file or create
  397.                                           the file if it does not exist.
  398.  
  399.              FILE_TRUNCATE                Open an existing file and change
  400.                                           to a given size.
  401.  
  402.              FILE_TRUNCATE | FILE_CREATE  Open an existing file and truncate
  403.                                           it, or create the file if it does
  404.                                           not exist.
  405.  
  406. fsOpenMode   Specifies the modes with which to open the file. It consists of
  407.              one access mode and one share mode. The other values are option
  408.              and can be given in any combination:
  409.  
  410.              Value                     Meaning
  411.              ---------------------------------------------------------------
  412.              OPEN_ACCESS_READONLY         Data can be read from the file but
  413.                                           not written to it.
  414.  
  415.              OPEN_ACCESS_READWRITE        Data can be read from or written
  416.                                           to the file.
  417.  
  418.              OPEN_ACCESS_WRITEONLY        Data can be written to the file
  419.                                           but not read from it.
  420.  
  421.              OPEN_SHARE_DENYNONE          Other processes can open the file
  422.                                           for any access: read-only,
  423.                                           write-only, or read-write.
  424.  
  425.              OPEN_SHARE_DENYREAD          Other processes can open the file
  426.                                           for write-only access but they
  427.                                           cannot open it for read-only or
  428.                                           read-write access.
  429.  
  430.              OPEN_SHARE_DENYREADWRITE     The current process has exclusive
  431.                                           access to the file. The file
  432.                                           cannot be opened by any process
  433.                                           (including the current process).
  434.  
  435.              OPEN_SHARE_DENYWRITE         Other processes can open the file
  436.                                           for read-only access but they
  437.                                           cannot open it for write-only or
  438.                                           read-write access.
  439.  
  440.              OPEN_FLAGS_FAIL_ON_ERROR     Any function that uses the file
  441.                                           handle returns immediately with an
  442.                                           error value if there is an I/O
  443.                                           error--for example, when the drive
  444.                                           door is open or a sector is
  445.                                           missing. If this value is not
  446.                                           specified, the system passes the
  447.                                           error to the system critical-error
  448.                                           handler, which then reports the
  449.                                           error to the user with a
  450.                                           hard-error popup. The
  451.                                           fail-on-error flag is not
  452.                                           inherited by child processes.
  453.  
  454.                                           The fail-on-error flag applies to
  455.                                           all functions that use the file
  456.                                           handle, with the exception of the
  457.                                           DosDevIOCtl function.
  458.  
  459.              OPEN_FLAGS_NOINHERIT         The file handle is not available
  460.                                           to any child process started by
  461.                                           the current process. If this value
  462.                                           is not specified, any child
  463.                                           process started by the current
  464.                                           process may use the file handle.
  465.  
  466.              OPEN_FLAGS_WRITE_THROUGH     This flag applies to functions,
  467.                                           such as DosWrite, that write data
  468.                                           to the file. If this value is
  469.                                           specified, the system writes data
  470.                                           to the device before the given
  471.                                           function returns. Otherwise, the
  472.                                           system may store the data in an
  473.                                           internal file buffer and write the
  474.                                           data to the device only when the
  475.                                           buffer is full or the file is
  476.                                           closed.
  477.  
  478.              OPEN_FLAGS_NO_LOCALITY       There is no specific information
  479.                                           regarding the locality of
  480.                                           reference (the degree of
  481.                                           randomness with which the file is
  482.                                           accessed).
  483.  
  484.              OPEN_FLAGS_SEQUENTIAL        The file is accessed
  485.                                           sequentially.
  486.  
  487.              OPEN_FLAGS_RANDOM            The file is accessed randomly.
  488.  
  489.              OPEN_FLAGS_RANDOMSEQUENTIAL  The file is accessed randomly, but
  490.                                           that there is a degree of
  491.                                           sequential I/O within that random
  492.                                           access. For example, this flag is
  493.                                           specified if large blocks of data
  494.                                           are to be read or written at
  495.                                           random locations in the file.
  496.  
  497.              OPEN_FLAGS_NO_CACHE          The disk drive should not cache
  498.                                           data in I/O operations on this
  499.                                           file.
  500.  
  501. ulReserved   Specifies a reserved value; must be zero.
  502.  
  503. Return Value
  504.  
  505. The return value may be one of the following:
  506.  
  507.     FDLG_OK
  508.     FDLG_CANCEL
  509.  
  510. Comments
  511.  
  512. On exit from this function, hard-error processing will be enabled.
  513. \****************************************************************************/
  514. #endif /* _FILEDLG_INCLUDED */
  515.