Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cClipboard.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cClipboard_H
7 #define _INC_cClipboard_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "../GrayLibBase.h"
14 
15 #ifdef _WIN32
16 namespace GrayLib
17 {
18  class GRAYLIB_LINK cClipboard
19  {
24  public:
25  bool m_bOpenClipboard;
26  HWND m_hWnd;
27  protected:
28  static cString GRAYCALL GetClipboardTextLocked(const void* pDataVoid, bool bUnicode, StrLen_t iSizeMax = StrT::k_LEN_MAX - 1);
29  public:
30  cClipboard(HWND hWnd) noexcept
31  : m_bOpenClipboard(::OpenClipboard(hWnd))
32  , m_hWnd(hWnd)
33  {
35  }
36  ~cClipboard()
37  {
38  CloseClipboard();
39  }
40 
41  bool isOpenClipboard() const noexcept
42  {
43  return m_bOpenClipboard;
44  }
45 
46  void CloseClipboard() noexcept
47  {
48  if (m_bOpenClipboard)
49  {
50  ::CloseClipboard();
51  m_bOpenClipboard = false;
52  }
53  }
54 
55  static bool GRAYCALL IsClipboardDataAvail(HWND hWnd, UINT uFormat = CF_TEXT);
56  static cString GRAYCALL GetClipboardText(HWND hWnd, StrLen_t iSizeMax = StrT::k_LEN_MAX - 1);
57 
58  bool AddClipboardData(const void* pData, size_t nLen, UINT uFormat);
59  static bool GRAYCALL SetClipboardData(HWND hWnd, const void* pData, size_t nLen, UINT uFormat = CF_TEXT); // CF_TEXT
60  static bool GRAYCALL SetClipboardText(HWND hWnd, cString sText);
61  };
62 };
63 
64 #endif // _WIN32
65 #endif // _INC_cClipboard_H
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
Definition: cMesh.h:22
int StrLen_t
the length of a string in chars (bytes for UTF8, wchar_t for UNICODE). or offset in characters....
Definition: StrConst.h:32
cStringT< GChar_t > cString
Definition: cString.h:636
static const StrLen_t k_LEN_MAX
arbitrary max size for Format() etc. NOTE: _MSC_VER says stack frame should be at least 16384
Definition: StrT.h:75