home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / OWLINC.PAK / OPENSAVE.H < prev    next >
C/C++ Source or Header  |  1995-08-29  |  4KB  |  142 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // (C) Copyright 1992, 1994 by Borland International, All Rights Reserved
  4. //
  5. //   Definition of TOpenSave- abstract, TFileOpen-, TFileSave- common Dialog 
  6. //   classes
  7. //----------------------------------------------------------------------------
  8. #if !defined(OWL_OPENSAVE_H)
  9. #define OWL_OPENSAVE_H
  10.  
  11. #if !defined(OWL_COMMDIAL_H)
  12. # include <owl/commdial.h>
  13. #endif
  14.  
  15. //
  16. //  class TOpenSaveDialog
  17. //  ----- ---------------
  18. //
  19. class _OWLCLASS TOpenSaveDialog : public TCommonDialog {
  20.   public:
  21.     class _OWLCLASS TData {
  22.       public:
  23.         uint32     Flags;
  24.         uint32     Error;
  25.         char*      FileName;
  26.         char*      Filter;
  27.         char*      CustomFilter;
  28.         int        FilterIndex;
  29.         char*      InitialDir;
  30.         char*      DefExt;
  31.         int        MaxPath;
  32.       
  33.         TData(uint32 flags=0, const char* filter=0, char* customFilter=0, 
  34.               char* initialDir=0, char* defExt=0, int maxPath=0);
  35.         TData(const TData& src);
  36.         ~TData();
  37.  
  38.         TData& operator =(const TData& src);
  39.  
  40.         void     SetFilter(const char* filter = 0);
  41.  
  42.         void     Write(opstream& os);
  43.         void     Read(ipstream& is);
  44.     };
  45.  
  46.     TOpenSaveDialog(TWindow*        parent,
  47.                     TData&          data,
  48.                     TResId          templateId = 0,
  49.                     const char far* title = 0,
  50.                     TModule*        module = 0);
  51.  
  52.     static int GetFileTitleLen(const char far* fileName)
  53.            {return ::GetFileTitle((LPSTR)fileName, 0, 0);} //Win32 cast
  54.  
  55.     static int GetFileTitle(const char far* fileName, char far* fileTitle, 
  56.                             int fileTitleLen) //Win32 casts
  57.            {return ::GetFileTitle((LPSTR)fileName, fileTitle,(uint16)fileTitleLen);}
  58.  
  59.   protected:
  60.     OPENFILENAME ofn;
  61.     TData&       Data;
  62.  
  63.     TOpenSaveDialog(TWindow* parent, TData& data, TModule*   module = 0);
  64.     void    Init(TResId templateId);
  65.     bool    DialogFunction(uint message, WPARAM, LPARAM);
  66.  
  67.     //
  68.     // override TWindow & TDialog virtuals
  69.     //
  70.     int     DoExecute() = 0;
  71.  
  72.     //
  73.     // Virtual function called when a share violation occurs in dlg
  74.     //
  75.     virtual int ShareViolation();
  76.  
  77.     //
  78.     // Messages registered by the common dialog DLL
  79.     //
  80.     static uint ShareViMsgId;
  81.  
  82.     //
  83.     // Default behavior inline for message response functions
  84.     //
  85.     void    CmOk() {DefaultProcessing();}           //EV_COMMAND(IDOK,
  86.     void    CmLbSelChanged() {DefaultProcessing();} //EV_COMMAND(lst1 or lst2
  87.   
  88.   private:
  89.     TOpenSaveDialog(const TOpenSaveDialog&);
  90.     TOpenSaveDialog& operator =(const TOpenSaveDialog&);
  91.  
  92.   DECLARE_RESPONSE_TABLE(TOpenSaveDialog);
  93. };
  94.  
  95.  
  96. //
  97. //  class TFileOpenDialog
  98. //  ----- ---------------
  99. //
  100. class _OWLCLASS TFileOpenDialog : public TOpenSaveDialog {
  101.   public:
  102.     TFileOpenDialog(TWindow*        parent,
  103.                     TData&          data,
  104.                     TResId          templateId = 0,
  105.                     const char far* title = 0,
  106.                     TModule*        module = 0);
  107.  
  108.     //
  109.     // override TDialog virtual functions
  110.     //
  111.     int  DoExecute();
  112.  
  113.   private:
  114.     TFileOpenDialog(const TOpenSaveDialog&);
  115.     TFileOpenDialog& operator=(const TOpenSaveDialog&);
  116. };
  117.  
  118.  
  119. //
  120. //  class TFileSaveDialog
  121. //  ----- ---------------
  122. //
  123. class _OWLCLASS TFileSaveDialog : public TOpenSaveDialog {
  124.   public:
  125.     TFileSaveDialog(TWindow*        parent,
  126.                     TData&          data,
  127.                     TResId          templateId = 0,
  128.                     const char far* title = 0,
  129.                     TModule*        module = 0);
  130.  
  131.     //
  132.     // override TDialog virtual functions
  133.     //
  134.     int  DoExecute();
  135.  
  136.   private:
  137.     TFileSaveDialog(const TFileSaveDialog&);
  138.     TFileSaveDialog& operator=(const TFileSaveDialog&);
  139. };
  140.  
  141. #endif  // OWL_OPENSAVE_H
  142.