home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / ole / wordpad / multconv.h < prev    next >
C/C++ Source or Header  |  1998-03-26  |  4KB  |  132 lines

  1. // convert.h : header file
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1998 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. {
  33. public:
  34. //Construction
  35.     CTrackFile(CFrameWnd* pWnd);
  36.     ~CTrackFile();
  37.  
  38. //Attributes
  39.     int m_nLastPercent;
  40.     DWORD m_dwLength;
  41.     CFrameWnd* m_pFrameWnd;
  42.     CString m_strComplete;
  43.     CString m_strWait;
  44.     CString m_strSaving;
  45. //Operations
  46.     void OutputPercent(int nPercentComplete = 0);
  47.     void OutputString(LPCTSTR lpsz);
  48.     virtual UINT Read(void FAR* lpBuf, UINT nCount);
  49.     virtual void Write(const void FAR* lpBuf, UINT nCount);
  50. };
  51.  
  52. class COEMFile : public CTrackFile
  53. {
  54. public:
  55.     COEMFile(CFrameWnd* pWnd);
  56.     virtual UINT Read(void FAR* lpBuf, UINT nCount);
  57.     virtual void Write(const void FAR* lpBuf, UINT nCount);
  58. };
  59.  
  60. #ifdef CONVERTERS
  61.  
  62. class CConverter : public CTrackFile
  63. {
  64. public:
  65.     CConverter(LPCSTR pszLibName, CFrameWnd* pWnd = NULL);
  66. protected:
  67.     CConverter(CFrameWnd* pWnd = NULL);
  68.  
  69. public:
  70. //Attributes
  71.     int m_nPercent;
  72.     BOOL m_bDone;
  73.     BOOL m_bConvErr;
  74.     virtual DWORD GetPosition() const;
  75.  
  76. // Operations
  77.     BOOL IsFormatCorrect(LPCTSTR pszFileName);
  78.     BOOL DoConversion();
  79.     virtual BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags,
  80.         CFileException* pError = NULL);
  81.     void WaitForConverter();
  82.     void WaitForBuffer();
  83.  
  84. // Overridables
  85.     virtual LONG Seek(LONG lOff, UINT nFrom);
  86.     virtual DWORD GetLength() const;
  87.  
  88.     virtual UINT Read(void* lpBuf, UINT nCount);
  89.     virtual void Write(const void* lpBuf, UINT nCount);
  90.  
  91.     virtual void Abort();
  92.     virtual void Flush();
  93.     virtual void Close();
  94.  
  95. // Unsupported
  96.     virtual CFile* Duplicate() const;
  97.     virtual void LockRange(DWORD dwPos, DWORD dwCount);
  98.     virtual void UnlockRange(DWORD dwPos, DWORD dwCount);
  99.     virtual void SetLength(DWORD dwNewLen);
  100.  
  101. //Implementation
  102. public:
  103.     ~CConverter();
  104.  
  105. protected:
  106.     int m_nBytesAvail;
  107.     int m_nBytesWritten;
  108.     BYTE* m_pBuf;
  109.     HANDLE m_hEventFile;
  110.     HANDLE m_hEventConv;
  111.     BOOL m_bForeignToRtf;
  112.     HGLOBAL m_hBuff;
  113.     HGLOBAL m_hFileName;
  114.     void LoadFunctions();
  115.     HINSTANCE m_hLibCnv;
  116.     PINITCONVERTER m_pInitConverter;
  117.     PISFORMATCORRECT m_pIsFormatCorrect;
  118.     PFOREIGNTORTF m_pForeignToRtf;
  119.     PRTFTOFOREIGN m_pRtfToForeign;
  120.     int CALLBACK WriteOut(int cch, int nPercentComplete);
  121.     int CALLBACK ReadIn(int nPercentComplete);
  122.     static HGLOBAL StringToHGLOBAL(LPCSTR pstr);
  123.     static int CALLBACK WriteOutStatic(int cch, int nPercentComplete);
  124.     static int CALLBACK ReadInStatic(int flags, int nPercentComplete);
  125.     static UINT ConverterThread(LPVOID pParam);
  126.     static CConverter *m_pThis;
  127. };
  128.  
  129. #endif
  130.  
  131. /////////////////////////////////////////////////////////////////////////////
  132.