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

  1. /*
  2.  * OPENTEST.C -- Program to test the FileOpenDlg function.
  3.  *               Compile command used:
  4.  *                  cl -c -AC -Os -Gs opentest.c
  5.  */
  6.  
  7. #define INCL_DOSFILEMGR
  8. #define INCL_WINWINDOWMGR
  9. #define INCL_WINDIALOGS
  10. #define INCL_DOSMISC
  11. #include <os2.h>
  12. #include <string.h>
  13. #include <malloc.h>
  14. #include "filedlg.h"
  15.  
  16. void CALLBACK HelpProc( HWND hwnd );
  17.  
  18. void main( void )
  19. {
  20.     HAB     hab = WinInitialize( 0 );
  21.     HMQ     hmq = WinCreateMsgQueue( hab,DEFAULT_QUEUE_SIZE );
  22.     USHORT  usPathLen;
  23.     PSZ     pszFile,pszBuf;
  24.     HFILE   hf;
  25.     USHORT  usAction;
  26.     USHORT  usResult;
  27.  
  28.     DosQSysInfo( 0,(PBYTE)&usPathLen,sizeof(USHORT) );
  29.     pszFile = malloc( usPathLen );
  30.     pszBuf  = malloc( usPathLen );
  31.  
  32.     usResult = FileOpenDlg( HWND_DESKTOP,
  33.                             NULL,
  34.                             NULL,
  35.                             "*.*",
  36.                             FILE_NORMAL,
  37.                             HelpProc,
  38.                             pszFile,
  39.                             &hf,
  40.                             0L,
  41.                             &usAction,
  42.                             FILE_NORMAL,
  43.                             FILE_OPEN,
  44.                             OPEN_ACCESS_READONLY|OPEN_SHARE_DENYWRITE,
  45.                             0L );
  46.  
  47.     switch ( usResult ) {
  48.         case FDLG_OK:
  49.             strcpy( pszBuf,pszFile );
  50.             break;
  51.  
  52.         case FDLG_CANCEL:
  53.             strcpy( pszBuf,"Open file dialog box was cancelled." );
  54.             break;
  55.  
  56.         default:
  57.             strcpy( pszBuf,"Internal error in FileOpenDlg procedure." );
  58.             break;
  59.         }
  60.  
  61.     WinMessageBox( HWND_DESKTOP,HWND_DESKTOP,
  62.                    pszBuf,"Debugging information",
  63.                    0,MB_OK|MB_NOICON );
  64.  
  65.     WinDestroyMsgQueue( hmq );
  66.     WinTerminate( hab );
  67. }
  68.  
  69. void CALLBACK HelpProc( HWND hwnd )
  70. {
  71.     WinMessageBox( HWND_DESKTOP,hwnd,
  72.                    "This message box was activated by the HELP button.",
  73.                    "Help",
  74.                    0,MB_OK|MB_NOICON );
  75. }
  76.