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

  1. /*
  2.  * OPENTEST.C -- Program to test the FileOpenDlg 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 = FileOpenDlg( HWND_DESKTOP,
  31.                             NULL,
  32.                             NULL,
  33.                             "*.*",
  34.                             FILE_NORMAL,
  35.                             HelpProc,
  36.                             pszFile,
  37.                             &hf,
  38.                             0L,
  39.                             &usAction,
  40.                             FILE_NORMAL,
  41.                             FILE_OPEN,
  42.                             OPEN_ACCESS_READONLY|OPEN_SHARE_DENYWRITE,
  43.                             0L );
  44.  
  45.     switch ( usResult ) {
  46.         case FDLG_OK:
  47.             _fstrcpy( pszBuf,pszFile );
  48.             break;
  49.  
  50.         case FDLG_CANCEL:
  51.             _fstrcpy( pszBuf,"Open file dialog box was cancelled." );
  52.             break;
  53.  
  54.         default:
  55.             _fstrcpy( pszBuf,"Internal error in FileOpenDlg procedure." );
  56.             break;
  57.         }
  58.  
  59.     WinMessageBox( HWND_DESKTOP,HWND_DESKTOP,
  60.                    pszBuf,"Debugging information",
  61.                    0,MB_OK|MB_NOICON );
  62.  
  63.     WinDestroyMsgQueue( hmq );
  64.     WinTerminate( hab );
  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.