home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / os2 / filedlg5 / source / filedlg.txt < prev    next >
Encoding:
Text File  |  1989-09-01  |  21.1 KB  |  436 lines

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