home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / WORDPAD.PAK / MULTCONV.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  3.7 KB  |  132 lines

  1. // convert.h : header file
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #ifdef CONVERTERS
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CConverter
  17.  
  18. typedef int (CALLBACK *LPFNOUT)(int cch, int nPercentComplete);
  19. typedef int (CALLBACK *LPFNIN)(int flags, int nPercentComplete);
  20. typedef BOOL (FAR PASCAL *PINITCONVERTER)(HWND hWnd, LPCSTR lpszModuleName);
  21. typedef BOOL (FAR PASCAL *PISFORMATCORRECT)(HANDLE ghszFile, HANDLE ghszClass);
  22. typedef int (FAR PASCAL *PFOREIGNTORTF)(HANDLE ghszFile, LPVOID lpv, HANDLE ghBuff, 
  23.     HANDLE ghszClass, HANDLE ghszSubset, LPFNOUT lpfnOut);
  24. typedef int (FAR PASCAL *PRTFTOFOREIGN)(HANDLE ghszFile, LPVOID lpv, HANDLE ghBuff, 
  25.     HANDLE ghszClass, LPFNIN lpfnIn);
  26.  
  27. #endif
  28.  
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CTrackFile
  31. class CTrackFile : public CFile
  32. public:
  33. //Construction
  34.     CTrackFile(CFrameWnd* pWnd);
  35.     ~CTrackFile();
  36.     
  37. //Attributes
  38.     int m_nLastPercent;
  39.     DWORD m_dwLength;
  40.     CFrameWnd* m_pFrameWnd;
  41.     CString m_strComplete;
  42.     CString m_strWait;
  43.     CString m_strSaving;
  44. //Operations
  45.     void OutputPercent(int nPercentComplete = 0);
  46.     void OutputString(LPCTSTR lpsz);
  47.     virtual UINT Read(void FAR* lpBuf, UINT nCount);
  48.     virtual void Write(const void FAR* lpBuf, UINT nCount);
  49. };
  50.  
  51. class COEMFile : public CTrackFile
  52. {
  53. public:
  54.     COEMFile(CFrameWnd* pWnd);
  55.     virtual UINT Read(void FAR* lpBuf, UINT nCount);
  56.     virtual void Write(const void FAR* lpBuf, UINT nCount);
  57. };
  58.  
  59. #ifdef CONVERTERS
  60.  
  61. class CConverter : public CTrackFile
  62. {
  63. public:
  64.     CConverter(LPCSTR pszLibName, CFrameWnd* pWnd = NULL);
  65. protected:
  66.     CConverter(CFrameWnd* pWnd = NULL);
  67.  
  68. public:
  69. //Attributes
  70.     int m_nPercent;
  71.     BOOL m_bDone;
  72.     BOOL m_bConvErr;
  73.     virtual DWORD GetPosition() const;
  74.  
  75. // Operations
  76.     BOOL IsFormatCorrect(LPCTSTR pszFileName);
  77.     BOOL DoConversion();
  78.     virtual BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags,
  79.         CFileException* pError = NULL);
  80.     void WaitForConverter();
  81.     void WaitForBuffer();
  82.  
  83. // Overridables
  84.     virtual LONG Seek(LONG lOff, UINT nFrom);
  85.     virtual DWORD GetLength() const;
  86.  
  87.     virtual UINT Read(void* lpBuf, UINT nCount);
  88.     virtual void Write(const void* lpBuf, UINT nCount);
  89.  
  90.     virtual void Abort();
  91.     virtual void Flush();
  92.     virtual void Close();
  93.  
  94. // Unsupported
  95.     virtual CFile* Duplicate() const;
  96.     virtual void LockRange(DWORD dwPos, DWORD dwCount);
  97.     virtual void UnlockRange(DWORD dwPos, DWORD dwCount);
  98.     virtual void SetLength(DWORD dwNewLen);
  99.  
  100. //Implementation
  101. public:
  102.     ~CConverter();
  103.  
  104. protected:
  105.     int m_nBytesAvail;
  106.     int m_nBytesWritten;
  107.     BYTE* m_pBuf;
  108.     HANDLE m_hEventFile;
  109.     HANDLE m_hEventConv;
  110.     BOOL m_bForeignToRtf;
  111.     HGLOBAL m_hBuff;
  112.     HGLOBAL m_hFileName;
  113.     void LoadFunctions();
  114.     HINSTANCE m_hLibCnv;
  115.     PINITCONVERTER m_pInitConverter;
  116.     PISFORMATCORRECT m_pIsFormatCorrect;
  117.     PFOREIGNTORTF m_pForeignToRtf;
  118.     PRTFTOFOREIGN m_pRtfToForeign;
  119.     int CALLBACK WriteOut(int cch, int nPercentComplete);
  120.     int CALLBACK ReadIn(int nPercentComplete);
  121.     static HGLOBAL StringToHGLOBAL(LPCSTR pstr);
  122.     static int CALLBACK WriteOutStatic(int cch, int nPercentComplete);
  123.     static int CALLBACK ReadInStatic(int flags, int nPercentComplete);
  124.     static UINT ConverterThread(LPVOID pParam);
  125.     static CConverter *m_pThis;
  126. };
  127.  
  128. #endif
  129.  
  130. /////////////////////////////////////////////////////////////////////////////
  131.