home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 19.ddi / OWLINC.PAK / CLIPBOAR.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  4.6 KB  |  146 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1992, 1993 by Borland International
  3. //   include\owl\clipboar.h
  4. //   OWL clipboard Encapsulation
  5. //----------------------------------------------------------------------------
  6. #if !defined(__OWL_CLIPBOAR_H)
  7. #define __OWL_CLIPBOAR_H
  8.  
  9. #if !defined(__OWL_OWLDEFS_H)
  10.   #include <owl\owldefs.h>
  11. #endif
  12. #if defined(_INC_OLE)
  13.   #include <ole.h>
  14. #endif
  15.  
  16. class _OWLCLASS TClipboard {
  17.  public:
  18.     ~TClipboard() {if (IsOpen) ::CloseClipboard();}
  19.  
  20.     static TClipboard& GetClipboard() {return TheClipboard;}
  21.  
  22.     BOOL        OpenClipboard(HWND hWnd)
  23.                     {return IsOpen = ::OpenClipboard(hWnd);}
  24.     void        CloseClipboard() {if (IsOpen) {::CloseClipboard(); IsOpen = FALSE;}}
  25.  
  26.     operator    BOOL() const {return IsOpen;}
  27.     HANDLE      GetClipboardData(UINT format) const;
  28.     HWND        GetOpenClipboardWindow() const;
  29.     HWND        GetClipboardOwner() const;
  30.     HWND        GetClipboardViewer() const;
  31.     int         GetClipboardFormatName(UINT format, char far* formatName, int maxCount) const;
  32.     int         GetPriorityClipboardFormat(UINT far* priorityList, int count) const;
  33.     int         CountClipboardFormats() const;
  34.     BOOL        IsClipboardFormatAvailable(UINT format) const;
  35.     BOOL        EmptyClipboard();
  36.     UINT        RegisterClipboardFormat(const char far* formatName) const;
  37.     HANDLE      SetClipboardData(UINT format, HANDLE handle);
  38.     HWND        SetClipboardViewer(HWND hWnd) const;
  39.  
  40.   #if defined(__OLE_H) || defined(_INC_OLE)
  41.     static const char* DefaultProtocol;
  42.  
  43.     BOOL        QueryCreate(const char far* protocol = DefaultProtocol,
  44.                             OLEOPT_RENDER   renderopt= olerender_draw,
  45.                             OLECLIPFORMAT   format   = 0);
  46.     BOOL        QueryLink(const char far* protocol = DefaultProtocol,
  47.                           OLEOPT_RENDER   renderopt= olerender_draw,
  48.                           OLECLIPFORMAT   format   = 0);
  49.   #endif
  50.  
  51.   protected:
  52.     static TClipboard TheClipboard;
  53.     BOOL              IsOpen;
  54.  
  55.     // Constructors / destructor
  56.     TClipboard() {IsOpen = FALSE;}
  57. };
  58.  
  59. class _OWLCLASS TClipboardFormatIterator {
  60.   public:
  61.     TClipboardFormatIterator();
  62.  
  63.     UINT          current();
  64.                   operator int();
  65.     UINT          operator ++();
  66.     UINT          operator ++(int);
  67.     void          restart();
  68.  
  69.   private:
  70.     UINT          _Current;
  71. };
  72.  
  73. //----------------------------------------------------------------------------
  74. // Inline
  75. //----------------------------------------------------------------------------
  76.  
  77. inline HANDLE TClipboard::GetClipboardData(UINT Format) const {
  78.   return ::GetClipboardData(Format);
  79. }
  80.  
  81. inline HWND TClipboard::GetOpenClipboardWindow() const {
  82.   return ::GetOpenClipboardWindow();
  83. }
  84.  
  85. inline HWND TClipboard::GetClipboardOwner() const {
  86.   return ::GetClipboardOwner();
  87. }
  88.  
  89. inline HWND TClipboard::GetClipboardViewer() const {
  90.   return ::GetClipboardViewer();
  91. }
  92.  
  93. inline int TClipboard::GetClipboardFormatName(UINT Format, char far* FormatName, int MaxCount) const {
  94.   return ::GetClipboardFormatName(Format, FormatName, MaxCount);
  95. }
  96.  
  97. inline int TClipboard::GetPriorityClipboardFormat(UINT far* priorityList, int count) const {
  98.   return ::GetPriorityClipboardFormat(priorityList, count);
  99. }
  100.  
  101. inline int TClipboard::CountClipboardFormats() const {
  102.   return ::CountClipboardFormats();
  103. }
  104.  
  105. inline BOOL TClipboard::IsClipboardFormatAvailable(UINT format) const {
  106.   return ::IsClipboardFormatAvailable(format);
  107. }
  108.  
  109. inline BOOL TClipboard::EmptyClipboard() {
  110.   return ::EmptyClipboard();
  111. }
  112.  
  113. inline UINT TClipboard::RegisterClipboardFormat(const char far* formatName) const {
  114.   return ::RegisterClipboardFormat(formatName);
  115. }
  116.  
  117. inline HANDLE TClipboard::SetClipboardData(UINT Format, HANDLE Handle) {
  118.   return ::SetClipboardData(Format,Handle);
  119. }
  120.  
  121. inline HWND TClipboard::SetClipboardViewer(HWND Wnd) const {
  122.   return ::SetClipboardViewer(Wnd);
  123. }
  124.  
  125. #if defined(__OLE_H) || defined(_INC_OLE)
  126. inline BOOL TClipboard::QueryCreate(
  127.                 LPCSTR        protocol,
  128.                 OLEOPT_RENDER renderopt,
  129.                 OLECLIPFORMAT format
  130.               )
  131. {
  132.   return ::OleQueryCreateFromClip(protocol, renderopt, format) == OLE_OK;
  133. }
  134.  
  135. inline BOOL TClipboard::QueryLink(
  136.                 LPCSTR        protocol,
  137.                 OLEOPT_RENDER renderopt,
  138.                 OLECLIPFORMAT format
  139.               )
  140. {
  141.   return ::OleQueryLinkFromClip(protocol, renderopt, format) == OLE_OK;
  142. }
  143. #endif
  144.  
  145. #endif  // __OWL_CLIPBOAR_H
  146.