<?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>Code Library &#187; SetItemData</title>
	<atom:link href="http://www.ucosoft.com/tag/setitemdata/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ucosoft.com</link>
	<description>Free Source Code and Program Tips</description>
	<lastBuildDate>Mon, 19 Jul 2010 04:51:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to sort items of CListCtrl or CListView?</title>
		<link>http://www.ucosoft.com/how-to-sort-items-of-clistctrl-or-clistview.html</link>
		<comments>http://www.ucosoft.com/how-to-sort-items-of-clistctrl-or-clistview.html#comments</comments>
		<pubDate>Mon, 22 Oct 2007 06:23:02 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[Win32/MFC]]></category>
		<category><![CDATA[CallBack]]></category>
		<category><![CDATA[CListCtrl]]></category>
		<category><![CDATA[CListView]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[SetItemData]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/2007/10/22/how-to-sort-items-of-clistctrl-or-clistview.html</guid>
		<description><![CDATA[How to sort the items of a CListCtrl or CListView(CReportView)? First, when you add items, you need to call SetItemData to attach an data structure(an integer or a pointer) to the item. Then, define a callback sort function. int CALLBACK SortFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); And here, the prarameters lParam1 and lParam2 are the]]></description>
			<content:encoded><![CDATA[<p>How to sort the items of a CListCtrl or CListView(CReportView)?</p>
<p>First, when you add items, you need to call <strong>SetItemData </strong>to attach an data structure(an integer or a pointer) to the item.</p>
<p>Then, define a callback sort function. </p>
<pre>int CALLBACK SortFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);</pre>
<p>And here, the prarameters lParam1 and lParam2 are the data structure you set in <strong>SetItemData</strong>. With the parameters, you can get the item content and calculate the sort order. Please notice, the parameters are <strong>NOT</strong> the item index.</p>
<p>Last, you can reponse the message <strong>HDN_ITEMCLICK</strong> or <strong>LVN_COLUMNCLICK</strong>, and call CListCtrl::SortItems with the callback function.</p>
<p>The examples from the CListCtrl::SortItems in MSDN is obsolescent, you&#8217;d better refer to the KB article:</p>
<p>250614 HOWTO: <a href="http://support.microsoft.com/?id=250614">Sort Items in a CListCtrl in Report View</a></p>

	Tags: <strong><a href="http://www.ucosoft.com/tag/callback" title="CallBack" rel="tag">CallBack</a>, <a href="http://www.ucosoft.com/tag/clistctrl" title="CListCtrl" rel="tag">CListCtrl</a>, <a href="http://www.ucosoft.com/tag/clistview" title="CListView" rel="tag">CListView</a>, <a href="http://www.ucosoft.com/tag/how-to" title="How-to" rel="tag">How-to</a>, <a href="http://www.ucosoft.com/tag/setitemdata" title="SetItemData" rel="tag">SetItemData</a></strong><br />

	<ul class="st-related-posts">
	<li><a href="http://www.ucosoft.com/write-and-read-binary-data-in-variant.html" title="Write and read binary data in VARIANT (November 22, 2006)">Write and read binary data in VARIANT</a> (0)</li>
	<li><a href="http://www.ucosoft.com/the-simplest-way-to-change-the-row-height-of-clistctrl.html" title="The Simplest way to change the row height of CListCtrl (January 14, 2008)">The Simplest way to change the row height of CListCtrl</a> (0)</li>
	<li><a href="http://www.ucosoft.com/set-the-head-backgroud-color-of-cpropertypage.html" title="Set the head backgroud color of CPropertyPage (October 18, 2007)">Set the head backgroud color of CPropertyPage</a> (0)</li>
	<li><a href="http://www.ucosoft.com/moving-selection-of-clistctrl.html" title="Moving selection of CListCtrl (December 3, 2006)">Moving selection of CListCtrl</a> (0)</li>
	<li><a href="http://www.ucosoft.com/how-to-translate-among-cstringstring-and-char-array.html" title="How to translate among CString,string and char array (June 22, 2007)">How to translate among CString,string and char array</a> (0)</li>
	<li><a href="http://www.ucosoft.com/how-to-subclass-ctreectrl-in-ctreeview.html" title="How to subclass CTreeCtrl in CTreeView? (October 25, 2007)">How to subclass CTreeCtrl in CTreeView?</a> (0)</li>
	<li><a href="http://www.ucosoft.com/how-to-sendpost-message-to-cdocument.html" title="How to send/post message to CDocument? (October 24, 2007)">How to send/post message to CDocument?</a> (2)</li>
	<li><a href="http://www.ucosoft.com/how-to-select-the-item-of-listviewclistctrl.html" title="How to select the item of ListView(CListCtrl) (October 18, 2007)">How to select the item of ListView(CListCtrl)</a> (0)</li>
	<li><a href="http://www.ucosoft.com/how-to-program-to-retrieve-the-authenticode-information.html" title="How to retrieve the authenticode information (December 31, 2006)">How to retrieve the authenticode information</a> (3)</li>
	<li><a href="http://www.ucosoft.com/how-to-read-the-graphics-card-ram-capacity.html" title="How to read the graphics card RAM capacity (December 18, 2006)">How to read the graphics card RAM capacity</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/how-to-sort-items-of-clistctrl-or-clistview.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
