<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>gabehabe &#187; clipboard</title>
	<atom:link href="http://www.gabehabe.com/blog/tags/clipboard/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gabehabe.com/blog</link>
	<description>Cool blog, bro.</description>
	<lastBuildDate>Wed, 29 Jun 2011 01:26:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>wxWidgets: Threading, and using the Clipboard</title>
		<link>http://www.gabehabe.com/blog/wxwidgets-threading-and-using-the-clipboard/</link>
		<comments>http://www.gabehabe.com/blog/wxwidgets-threading-and-using-the-clipboard/#comments</comments>
		<pubDate>Sat, 31 Oct 2009 17:11:12 +0000</pubDate>
		<dc:creator>Danny</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[wxWidgets]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[clipboard]]></category>
		<category><![CDATA[gui design]]></category>
		<category><![CDATA[threading]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.gabehabe.com/blog/wxwidgets-threading-and-using-the-clipboard/</guid>
		<description><![CDATA[wxWidgets: Threading, and using the Clipboard Two for one in this tutorial. We're going to create a thread using wxWidgets, and make it monitor the clipboard for text. Then, if we detect a change, we're going to add the new contents to a list. It's a relatively simple process, but unfortunately wxWidgets isn't the most [...]]]></description>
			<content:encoded><![CDATA[<h3>wxWidgets: Threading, and using the Clipboard</h3>

Two for one in this tutorial. We're going to create a thread using wxWidgets, and make it monitor the clipboard for text. Then, if we detect a change, we're going to add the new contents to a list.

It's a relatively simple process, but unfortunately wxWidgets isn't the most documented GUI toolkit out there.

So, let's get started. I'm gonna pile all the code into a single file instead of breaking my classes up into seperate files, just for ease of navigation in this tutorial. The code is relatively short anyway, with only 62 lines.

First off, as with any other program, we're going to want to get our includes done. We'll be needing three: The standard wx header, the clipboard header, and the thread header.


<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include &lt;wx/wx.h&gt; // standard wx header</span>
<span style="color: #339900;">#include &lt;wx/clipbrd.h&gt; // clipboard - we'll monitor the clipboard for text</span>
<span style="color: #339900;">#include &lt;wx/thread.h&gt; // include threads!</span></pre></div></div>



The next thing we need to do is declare our <code>ClipLogger</code> class - this will inherit wxThread, and have two variables: One to hold the most recent text that we got from the clipboard, and one which is a pointer to a <code>wxListBox</code> object -- the object on the main window which we'll be updating.


<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">class</span> ClipLogger <span style="color: #008080;">:</span> <span style="color: #0000ff;">public</span> wxThread <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
        ClipLogger<span style="color: #008000;">&#40;</span>wxListBox<span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">private</span><span style="color: #008080;">:</span>
        <span style="color: #0000ff;">void</span><span style="color: #000040;">*</span> Entry<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// the entry point to the thread</span>
&nbsp;
        wxString LatestText<span style="color: #008080;">;</span> <span style="color: #666666;">// store the last text so we can check for changes</span>
        wxListBox<span style="color: #000040;">*</span> list<span style="color: #008080;">;</span> <span style="color: #666666;">// the list to update on a text change</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span></pre></div></div>



The constructor is <em>very</em> simple. All it does is take a wxListBox*, and assign it to a variable stored by the class - this is the list that we want to update on clipboard text changes.


<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">ClipLogger<span style="color: #008080;">::</span><span style="color: #007788;">ClipLogger</span><span style="color: #008000;">&#40;</span>wxListBox<span style="color: #000040;">*</span> l<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>list <span style="color: #000080;">=</span> l<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>



Next up is the main part of this tutorial. When we create a thread, we need to override the <code>Entry()</code> method of the class, like so:


<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">void</span><span style="color: #000040;">*</span> ClipLogger<span style="color: #008080;">::</span><span style="color: #007788;">Entry</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span></pre></div></div>



To save time and memory, rather than creating a variable every time we loop, we'll create it before and simply overwrite it inside the loop.


<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">wxTextDataObject temp<span style="color: #008080;">;</span></pre></div></div>



wxTextDataObject is the type of object that the clipboard will store.
Next, since our thread is a constant "monitor" for the clipboard, we want it to loop.


<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">true</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span></pre></div></div>



Then, we need to think about how we can help our application not be CPU-hungry. The simple solution is to make the thread sleep each time it loops. We can do this with <code>wxSleep(int time)</code>, where time is the length of time to sleep in <strong>seconds</strong>.


<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">wxSleep<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div>



The rest of the loop is the clipboard. It's very simple, so rather than break it up line-by-line, I've added comments along the way. We basically need to do the following:
 - Open the clipboard
 - If the clipboard is text, get it into our <code>temp</code> variable
 - Update the list and remember this is the most recent (so as not to constantly add the same data to the list)
 - Close the clipboard


<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">        <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>wxTheClipboard<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>Open<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> <span style="color: #666666;">// try to open the clipboard</span>
            <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>wxTheClipboard<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>IsSupported<span style="color: #008000;">&#40;</span>wxDF_TEXT<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> <span style="color: #666666;">// if the clipboard contains text</span>
                wxTheClipboard<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetData<span style="color: #008000;">&#40;</span>temp<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// get the data from the clipboard</span>
                <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>LatestText <span style="color: #000040;">!</span><span style="color: #000080;">=</span> temp.<span style="color: #007788;">GetText</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> <span style="color: #666666;">// if it's changed, we want to update</span>
                    <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>temp.<span style="color: #007788;">GetText</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">!</span><span style="color: #000080;">=</span> wxT<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> <span style="color: #666666;">// if it's not an empty string</span>
                        this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>LatestText <span style="color: #000080;">=</span> temp.<span style="color: #007788;">GetText</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>  <span style="color: #666666;">// update the &quot;LatestText&quot;</span>
                        this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>list<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>Append<span style="color: #008000;">&#40;</span>temp.<span style="color: #007788;">GetText</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// append to the list</span>
                    <span style="color: #008000;">&#125;</span>
                <span style="color: #008000;">&#125;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
        wxTheClipboard<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>Close<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// close the clipboard</span></pre></div></div>



The last thing left to do in the thread is simply close it off, and close off the loop.


<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>



Simple, huh? :)

And that's our thread defined. Now all we need to do is create the app itself, which is a simple process. I hope that you already know how to do it, so we can blitz through the majority of it.

Create the app:


<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">class</span> threaded_app <span style="color: #008080;">:</span> <span style="color: #0000ff;">public</span> wxApp <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
        <span style="color: #0000ff;">bool</span> OnInit<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span></pre></div></div>



The beginning of the <code>OnInit()</code> should be nothing new at this point either.


<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">bool</span> threaded_app<span style="color: #008080;">::</span><span style="color: #007788;">OnInit</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #666666;">// quickly create a wxFrame to display a window</span>
    wxFrame<span style="color: #000040;">*</span> f <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> wxFrame<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">NULL</span>, wxID_ANY, wxT<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;Threaded App!&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #666666;">// add a list to the frame we created</span>
    wxListBox<span style="color: #000040;">*</span> list <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> wxListBox<span style="color: #008000;">&#40;</span>f, wxID_ANY<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #666666;">// display the frame</span>
    f<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>Show<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">true</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div>



The last part of <code>OnInit()</code> that we need to do is actually create an instance of our thread and run it, like so:


<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">    <span style="color: #666666;">// pass the list to the clipboard monitor so it knows what to update</span>
    ClipLogger<span style="color: #000040;">*</span> cl <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> ClipLogger<span style="color: #008000;">&#40;</span>list<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// construct our thread</span>
    cl<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>Create<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// we have to create a thread before we can run it</span>
    cl<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>Run<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// run our thread</span></pre></div></div>



And we can simply finish off the <code>OnInit()</code> and IMPLEMENT_APP:


<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">    <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">true</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
IMPLEMENT_APP<span style="color: #008000;">&#40;</span>threaded_app<span style="color: #008000;">&#41;</span></pre></div></div>




And that's all there is to threading and using the clipboard in wxWidgets!

Here's the complete code:


<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include &lt;wx/wx.h&gt; // standard wx header</span>
<span style="color: #339900;">#include &lt;wx/clipbrd.h&gt; // clipboard - we'll monitor the clipboard for text</span>
<span style="color: #339900;">#include &lt;wx/thread.h&gt; // include threads!</span>
&nbsp;
<span style="color: #0000ff;">class</span> ClipLogger <span style="color: #008080;">:</span> <span style="color: #0000ff;">public</span> wxThread <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
        ClipLogger<span style="color: #008000;">&#40;</span>wxListBox<span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">private</span><span style="color: #008080;">:</span>
        <span style="color: #0000ff;">void</span><span style="color: #000040;">*</span> Entry<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// the entry point to the thread</span>
&nbsp;
        wxString LatestText<span style="color: #008080;">;</span> <span style="color: #666666;">// store the last text so we can check for changes</span>
        wxListBox<span style="color: #000040;">*</span> list<span style="color: #008080;">;</span> <span style="color: #666666;">// the list to update on a text change</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
ClipLogger<span style="color: #008080;">::</span><span style="color: #007788;">ClipLogger</span><span style="color: #008000;">&#40;</span>wxListBox<span style="color: #000040;">*</span> l<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>list <span style="color: #000080;">=</span> l<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span><span style="color: #000040;">*</span> ClipLogger<span style="color: #008080;">::</span><span style="color: #007788;">Entry</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    wxTextDataObject temp<span style="color: #008080;">;</span> <span style="color: #666666;">// create a &quot;wxTextDataObject&quot; to get the info from the clipboard</span>
    <span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">true</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> <span style="color: #666666;">// our thread will loop</span>
        wxSleep<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// sleep for 1 second, make the thread less cpu-hungry</span>
        <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>wxTheClipboard<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>Open<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> <span style="color: #666666;">// try to open the clipboard</span>
            <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>wxTheClipboard<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>IsSupported<span style="color: #008000;">&#40;</span>wxDF_TEXT<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> <span style="color: #666666;">// if the clipboard contains text</span>
                wxTheClipboard<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetData<span style="color: #008000;">&#40;</span>temp<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// get the data from the clipboard</span>
                <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>LatestText <span style="color: #000040;">!</span><span style="color: #000080;">=</span> temp.<span style="color: #007788;">GetText</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> <span style="color: #666666;">// if it's changed, we want to update</span>
                    <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>temp.<span style="color: #007788;">GetText</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">!</span><span style="color: #000080;">=</span> wxT<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> <span style="color: #666666;">// if it's not an empty string</span>
                        this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>LatestText <span style="color: #000080;">=</span> temp.<span style="color: #007788;">GetText</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>  <span style="color: #666666;">// update the &quot;LatestText&quot;</span>
                        this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>list<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>Append<span style="color: #008000;">&#40;</span>temp.<span style="color: #007788;">GetText</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// append to the list</span>
                    <span style="color: #008000;">&#125;</span>
                <span style="color: #008000;">&#125;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
        wxTheClipboard<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>Close<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// close the clipboard</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">class</span> threaded_app <span style="color: #008080;">:</span> <span style="color: #0000ff;">public</span> wxApp <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
        <span style="color: #0000ff;">bool</span> OnInit<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">bool</span> threaded_app<span style="color: #008080;">::</span><span style="color: #007788;">OnInit</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #666666;">// quickly create a wxFrame to display a window</span>
    wxFrame<span style="color: #000040;">*</span> f <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> wxFrame<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">NULL</span>, wxID_ANY, wxT<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;Threaded App!&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #666666;">// add a list to the frame we created</span>
    wxListBox<span style="color: #000040;">*</span> list <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> wxListBox<span style="color: #008000;">&#40;</span>f, wxID_ANY<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #666666;">// display the frame</span>
    f<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>Show<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">true</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #666666;">// pass the list to the clipboard monitor so it knows what to update</span>
    ClipLogger<span style="color: #000040;">*</span> cl <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> ClipLogger<span style="color: #008000;">&#40;</span>list<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// construct our thread</span>
    cl<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>Create<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// we have to create a thread before we can run it</span>
    cl<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>Run<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// run our thread</span>
&nbsp;
    <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">true</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
IMPLEMENT_APP<span style="color: #008000;">&#40;</span>threaded_app<span style="color: #008000;">&#41;</span></pre></div></div>



Happy coding! :)

]]></content:encoded>
			<wfw:commentRss>http://www.gabehabe.com/blog/wxwidgets-threading-and-using-the-clipboard/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

