foobar2000 SDK  2015-08-03
clipboard.h
Go to the documentation of this file.
1 #ifdef _WIN32
2 namespace ClipboardHelper {
3 
4  class OpenScope {
5  public:
6  OpenScope() : m_open(false) {}
8  void Open(HWND p_owner) {
9  Close();
10  WIN32_OP(OpenClipboard(p_owner));
11  m_open = true;
12  }
13  void Close() {
14  if (m_open) {
15  m_open = false;
16  CloseClipboard();
17  }
18  }
19  private:
20  bool m_open;
21 
22  PFC_CLASS_NOT_COPYABLE_EX(OpenScope)
23  };
24 
25  void SetRaw(UINT format,const void * buffer, t_size size);
26  void SetString(const char * in);
27 
28  bool GetString(pfc::string_base & out);
29 
30  template<typename TArray>
31  bool GetRaw(UINT format,TArray & out) {
33  HANDLE data = GetClipboardData(format);
34  if (data == NULL) return false;
35  CGlobalLockScope lock(data);
36  out.set_size( lock.GetSize() );
37  memcpy(out.get_ptr(), lock.GetPtr(), lock.GetSize() );
38  return true;
39  }
40  bool IsTextAvailable();
41 };
42 #endif // _WIN32
void * GetPtr() const
Definition: win-objects.h:77
bool GetRaw(UINT format, TArray &out)
Definition: clipboard.h:31
bool IsTextAvailable()
Definition: clipboard.cpp:36
typedef HANDLE(WINAPI *pPowerCreateRequest_t)(__in void *Context)
void Open(HWND p_owner)
Definition: clipboard.h:8
size_t t_size
Definition: int_types.h:48
void SetString(const char *in)
Definition: clipboard.cpp:25
t_size GetSize() const
Definition: win-objects.h:78
bool GetString(pfc::string_base &out)
Definition: clipboard.cpp:30
void SetRaw(UINT format, const void *data, t_size size)
Definition: clipboard.cpp:12