home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / FILEDLG6.ZIP / SAMPLE.ZIP / SAVETEST.C < prev    next >
C/C++ Source or Header  |  1990-11-13  |  2KB  |  88 lines

  1. /*
  2.  * SAVETEST.C -- Program to test operation of FileSaveDlg function.
  3.  */
  4.  
  5. #define INCL_DOSFILEMGR
  6. #define INCL_WINWINDOWMGR
  7. #define INCL_WINDIALOGS
  8. #define INCL_DOSMISC
  9. #include <os2.h>
  10. #include <string.h>
  11. #include <malloc.h>
  12. #include <filedlg.h>
  13.  
  14. void EXPENTRY HelpProc( HWND hwnd );
  15.  
  16. void main( void )
  17. {
  18.     HAB     hab = WinInitialize( 0 );
  19.     HMQ     hmq = WinCreateMsgQueue( hab,DEFAULT_QUEUE_SIZE );
  20.     USHORT  usPathLen;
  21.     PSZ     pszFile,pszBuf;
  22.     HFILE   hf;
  23.     USHORT  usAction;
  24.     USHORT  usResult;
  25.  
  26.     DosQSysInfo( 0,(PBYTE)&usPathLen,sizeof(USHORT) );
  27.     pszFile = _fmalloc( usPathLen );
  28.     pszBuf  = _fmalloc( usPathLen );
  29.  
  30.     usResult = FileSaveDlg( HWND_DESKTOP,
  31.                             NULL,
  32.                             NULL,
  33.                             HelpProc,
  34.                             "unnamed",
  35.                             pszFile,
  36.                             &hf,
  37.                             0L,
  38.                             &usAction,
  39.                             FILE_NORMAL,
  40.                             FILE_OPEN,
  41.                             OPEN_ACCESS_READONLY|OPEN_SHARE_DENYWRITE,
  42.                             0L );
  43.  
  44.     switch ( usResult ) {
  45.         case FDLG_OK:
  46.             _fstrcpy( pszBuf,pszFile );
  47.             break;
  48.  
  49.         case FDLG_CANCEL:
  50.             _fstrcpy( pszBuf,"Save file dialog box was cancelled." );
  51.             break;
  52.  
  53.         default:
  54.             _fstrcpy( pszBuf,"Internal error in FileSaveDlg procedure." );
  55.             break;
  56.         }
  57.  
  58.     WinMessageBox( HWND_DESKTOP,HWND_DESKTOP,
  59.                    pszBuf,"Debugging information",
  60.                    0,MB_OK|MB_NOICON );
  61.  
  62.     WinDestroyMsgQueue( hmq );
  63.     WinTerminate( hab );
  64. }
  65.  
  66.  
  67. void EXPENTRY HelpProc( HWND hwnd )
  68. {
  69.     USHORT  id;
  70.     PSZ     pszMsg;
  71.  
  72.     switch ( id=WinQueryWindowUShort(hwnd,QWS_ID) ) {
  73.         case FDLG_OPEN: pszMsg = "Help requested by open dialog.";
  74.                         break;
  75.  
  76.         case FDLG_FIND: pszMsg = "Help requested by find dialog.";
  77.                         break;
  78.  
  79.         case FDLG_SAVE: pszMsg = "Help requested by save dialog.";
  80.                         break;
  81.  
  82.         default:        pszMsg = "Internal error in help.";
  83.                         break;
  84.         }
  85.  
  86.     WinMessageBox( HWND_DESKTOP,hwnd,pszMsg,"Help",0,MB_OK|MB_NOICON );
  87. }
  88.