home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / FILEDLG6.ZIP / SOURCE.ZIP / FILEDLG.TXT < prev    next >
Text File  |  1990-11-14  |  25KB  |  505 lines

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