File: wx44.htm

package info (click to toggle)
wxwin2-doc 2.01-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 6,540 kB
  • ctags: 5,968
  • sloc: cpp: 15,157; makefile: 434; sh: 6
file content (130 lines) | stat: -rw-r--r-- 5,085 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<HTML>
<head><title>wxClipboard</title></head>

<BODY BGCOLOR=#FFFFFF>
<A NAME="wxclipboard"></A><CENTER>
<A HREF="wx.htm"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="wx22.htm#classref"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="wx43.htm#wxclientdc"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx45.htm#wxcloseevent"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>

<H2>wxClipboard</H2>
<P>
A class for manipulating the clipboard. Note that this is not compatible with the
clipboard class from wxWindows 1.xx, which has the same name but a different implementation.<P>
To use the clipboard, you call member functions of the global <B>wxTheClipboard</B> object.<P>
Call <A HREF="wx44.htm#wxclipboardopen">wxClipboard::Open</A> to get ownership of the clipboard. If this operation returns TRUE, you
now own the clipboard. Call <A HREF="wx44.htm#wxclipboardadddata">wxClipboard::AddData</A> to put data
on the clipboard (one or more times), or <A HREF="wx44.htm#wxclipboardgetdata">wxClipboard::GetData</A> to
retrieve data from the clipboard. Call <A HREF="wx44.htm#wxclipboardclose">wxClipboard::Close</A> to close
the clipboard and relinquish ownership. You should keep the clipboard open only momentarily.<P>
For example:<P>
<PRE>
  // Write some text to the clipboard
  if (wxTheClipboard-&gt;Open())
  {
    // This data objects are held by the clipboard, 
    // so do not delete them in the app.
    wxTheClipboard-&gt;AddData( new wxTextDataObject("Some text") );
    wxTheClipboard-&gt;Close();
  }

  // Read some text
  if (wxTheClipboard-&gt;Open())
  {
    wxTextDataObject data;
    if (wxTheClipboard-&gt;IsSupported(data))
    {
      wxTheClipboard-&gt;GetData(data);
      wxMessageBox(data.GetText());
    }  
    wxTheClipboard-&gt;Close();
  }
</PRE>
<B><FONT COLOR="#FF0000">Derived from</FONT></B><P>
<A HREF="wx158.htm#wxobject">wxObject</A><P>
<B><FONT COLOR="#FF0000">Include files</FONT></B><P>
&lt;wx/clipbrd.h&gt;<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx312.htm#wxdndoverview">Drag and drop overview</A>, <A HREF="wx61.htm#wxdataobject">wxDataObject</A><P>
<B><FONT COLOR="#FF0000">Members</FONT></B><P>
<A HREF="#topic86">wxClipboard::wxClipboard</A><BR>
<A HREF="#topic87">wxClipboard::~wxClipboard</A><BR>
<A HREF="#wxclipboardadddata">wxClipboard::AddData</A><BR>
<A HREF="#wxclipboardclear">wxClipboard::Clear</A><BR>
<A HREF="#wxclipboardclose">wxClipboard::Close</A><BR>
<A HREF="#wxclipboardgetdata">wxClipboard::GetData</A><BR>
<A HREF="#wxclipboardissupported">wxClipboard::IsSupported</A><BR>
<A HREF="#wxclipboardopen">wxClipboard::Open</A><BR>
<A HREF="#wxclipboardsetdata">wxClipboard::SetData</A><BR>
<P>

<HR>
<A NAME="topic86"></A>
<H3>wxClipboard::wxClipboard</H3>
<P>
<B></B> <B>wxClipboard</B>()<P>
Constructor.<P>

<HR>
<A NAME="topic87"></A>
<H3>wxClipboard::~wxClipboard</H3>
<P>
<B></B> <B>~wxClipboard</B>()<P>
Destructor.<P>

<HR>
<A NAME="wxclipboardadddata"></A>
<H3>wxClipboard::AddData</H3>
<P>
<B>bool</B> <B>AddData</B>(<B>wxDataObject*</B><I> data</I>)<P>
Call this function to add a data object to the clipboard. This function can be called several times
to put different formats on the clipboard.<P>

<HR>
<A NAME="wxclipboardclear"></A>
<H3>wxClipboard::Clear</H3>
<P>
<B>void</B> <B>Clear</B>()<P>
Clears the global clipboard object and the system's clipboard if possible.<P>

<HR>
<A NAME="wxclipboardclose"></A>
<H3>wxClipboard::Close</H3>
<P>
<B>bool</B> <B>Close</B>()<P>
Call this function to close the clipboard, having opened it with <A HREF="wx44.htm#wxclipboardopen">wxClipboard::Open</A>.<P>

<HR>
<A NAME="wxclipboardgetdata"></A>
<H3>wxClipboard::GetData</H3>
<P>
<B>bool</B> <B>GetData</B>(<B>wxDataObject&amp;</B><I> data</I>)<P>
Call this function to fill <I>data</I> with data on the clipboard, if available in the required
format. Returns TRUE on success.<P>

<HR>
<A NAME="wxclipboardissupported"></A>
<H3>wxClipboard::IsSupported</H3>
<P>
<B>bool</B> <B>IsSupported</B>(<B>wxDataObject&amp;</B><I> data</I>)<P>
Returns TRUE if the format of the given data object is available on the clipboard.<P>

<HR>
<A NAME="wxclipboardopen"></A>
<H3>wxClipboard::Open</H3>
<P>
<B>bool</B> <B>Open</B>()<P>
Call this function to open the clipboard before calling <A HREF="wx44.htm#wxclipboardsetdata">wxClipboard::SetData</A> 
and <A HREF="wx44.htm#wxclipboardgetdata">wxClipboard::GetData</A>.<P>
Call <A HREF="wx44.htm#wxclipboardclose">wxClipboard::Close</A> when you have finished with the clipboard. You
should keep the clipboard open for only a very short time.<P>
Returns TRUE on success. This should be tested (as in the sample shown above).<P>

<HR>
<A NAME="wxclipboardsetdata"></A>
<H3>wxClipboard::SetData</H3>
<P>
<B>bool</B> <B>SetData</B>(<B>wxDataObject*</B><I> data</I>)<P>
Call this function to set the data object to the clipboard. This function will
clear all previous contents in the clipboard, so calling it several times
does not make any sense.<P>

</BODY></HTML>