home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / os2 / filedlg5 / sample / savetest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-31  |  1.7 KB  |  64 lines

  1. /*
  2.  * SAVETEST.C -- Program to test operation of FileSaveDlg function.
  3.  *               Compile using compact memory model.
  4.  */
  5.  
  6. #define INCL_DOSFILEMGR
  7. #define INCL_WINWINDOWMGR
  8. #define INCL_WINDIALOGS
  9. #define INCL_DOSMISC
  10. #include <os2.h>
  11. #include <string.h>
  12. #include <malloc.h>
  13. #include "filedlg.h"
  14.  
  15. void main( void )
  16. {
  17.     HAB     hab = WinInitialize( 0 );
  18.     HMQ     hmq = WinCreateMsgQueue( hab,DEFAULT_QUEUE_SIZE );
  19.     USHORT  usPathLen;
  20.     PSZ     pszFile,pszBuf;
  21.     HFILE   hf;
  22.     USHORT  usAction;
  23.     USHORT  usResult;
  24.  
  25.     DosQSysInfo( 0,(PBYTE)&usPathLen,sizeof(USHORT) );
  26.     pszFile = malloc( usPathLen );
  27.     pszBuf  = malloc( usPathLen );
  28.  
  29.     usResult = FileSaveDlg( HWND_DESKTOP,
  30.                             NULL,
  31.                             NULL,
  32.                             NULL,
  33.                             "unnamed",
  34.                             pszFile,
  35.                             &hf,
  36.                             0L,
  37.                             &usAction,
  38.                             FILE_NORMAL,
  39.                             FILE_OPEN,
  40.                             OPEN_ACCESS_READONLY|OPEN_SHARE_DENYWRITE,
  41.                             0L );
  42.  
  43.     switch ( usResult ) {
  44.         case FDLG_OK:
  45.             strcpy( pszBuf,pszFile );
  46.             break;
  47.  
  48.         case FDLG_CANCEL:
  49.             strcpy( pszBuf,"Save file dialog box was cancelled." );
  50.             break;
  51.  
  52.         default:
  53.             strcpy( pszBuf,"Internal error in FileSaveDlg procedure." );
  54.             break;
  55.         }
  56.  
  57.     WinMessageBox( HWND_DESKTOP,HWND_DESKTOP,
  58.                    pszBuf,"Debugging information",
  59.                    0,MB_OK|MB_NOICON );
  60.  
  61.     WinDestroyMsgQueue( hmq );
  62.     WinTerminate( hab );
  63. }
  64.