<?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; CallBack</title>
	<atom:link href="http://www.ucosoft.com/tag/callback/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ucosoft.com</link>
	<description>Free Source Code and Program Tips</description>
	<lastBuildDate>Thu, 22 Jul 2010 05:17:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</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 />
]]></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>

