<?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; CListCtrl</title>
	<atom:link href="http://www.ucosoft.com/tag/clistctrl/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 get ClistCtrl item text of another process</title>
		<link>http://www.ucosoft.com/get-clistctrl-item-text-of-another-process.html</link>
		<comments>http://www.ucosoft.com/get-clistctrl-item-text-of-another-process.html#comments</comments>
		<pubDate>Wed, 24 Sep 2008 08:19:30 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[Win32/MFC]]></category>
		<category><![CDATA[CListCtrl]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[Injection]]></category>
		<category><![CDATA[Process]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/2008/09/24/get-clistctrl-item-text-of-another-process.html</guid>
		<description><![CDATA[Question: In some app like WinSpy/Spy++ to make adjustments to list controls. It can correctly set an app&#8217;s list control&#8217;s modes, alignments, sorting, styles, and extended styles. It can also get the widths of the columns and count of items. The problem is that you cannot seem to get the columns&#8217; names or the item [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Question:</strong></p>
<p>In some app like WinSpy/Spy++ to make adjustments to list controls. It can correctly set an app&#8217;s list control&#8217;s modes, alignments,    <br />sorting, styles, and extended styles. It can also get the widths of the columns and count of items. </p>
<p>The problem is that you cannot seem to get the columns&#8217; names or the item text. The app uses code like this, where lc is a pointer to the target app&#8217;s list control: </p>
<p>&#160; lc-&gt;GetColumnWidth();    <br />&#160; lc-&gt;GetItemCount();     <br />&#160; lc-&gt;ModifyStyle();     <br />&#160; lc-&gt;SetExtendedStyle();     <br />&#160; lc-&gt;GetHeaderCtrl()-&gt;GetItemCount(); </p>
<p>That all works fine, but when you try something like this, it doesn&#8217;t work: </p>
<p>&#160; TCHAR colname[256]=_T(&quot;&quot;);    <br />&#160; LVCOLUMN lvcol;     <br />&#160; ZeroMemory(&amp;lvcol, sizeof(lvcol));     <br />&#160; lvcol.mask=LVCF_TEXT;     <br />&#160; lvcol.cchTextMax=sizeof(colname)-1;     <br />&#160; lvcol.pszText=colname;     <br />&#160; lc-&gt;GetColumn(col, &amp;lvcol); </p>
<p>GetColumn may return TRUE or FALSE, but the LVCOLUMN structure remains unchanged. If you tried using that same code in a test app to get the name of a column from that app&#8217;s own list control and it worked. It only seems to fail when use it from a different app.</p>
<p><strong><u>Solution:</u></strong></p>
<p>Well, there is no surprise here; in fact, if there is any surprise, it is that you did not manage to totally crash the target app (I presume that lc is a CListCtrl::FromHandle of an HWND in another process). </p>
<p>Think about this case:</p>
<p>you are passing the address of a data structure in YOUR process as a LPARAM-sized value to some totally different process, where that LPARAM value is completely and utterly meaningless. </p>
<p>David Ching did a remote-sendmessage DLL some time ago.&#160; This essentially does DLL injection of the code so it is running in the target process; you can google for this by looking for SendMessageRemote.</p>
<p><a href="http://www.dcsoft.com/private/sendmessageremote.cpp">http://www.dcsoft.com/private/sendmessageremote.cpp</a></p>

	Tags: <strong><a href="http://www.ucosoft.com/tag/clistctrl" title="CListCtrl" rel="tag">CListCtrl</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/injection" title="Injection" rel="tag">Injection</a>, <a href="http://www.ucosoft.com/tag/process" title="Process" rel="tag">Process</a>, <a href="http://www.ucosoft.com/tag/win32mfc" title="Win32/MFC" rel="tag">Win32/MFC</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/get-clistctrl-item-text-of-another-process.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>30 Great Tips of CListCtrl Program(2)</title>
		<link>http://www.ucosoft.com/30-great-tips-of-clistctrl-program2.html</link>
		<comments>http://www.ucosoft.com/30-great-tips-of-clistctrl-program2.html#comments</comments>
		<pubDate>Tue, 03 Jun 2008 02:35:16 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[Win32/MFC]]></category>
		<category><![CDATA[CListCtrl]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/2008/06/03/30-great-tips-of-clistctrl-program2.html</guid>
		<description><![CDATA[30 Great Tips of CListCtrl Program(1) 8. Get Item Infomation TCHAR szBuf[1024];LVITEM lvi;lvi.iItem = nItemIndex;lvi.iSubItem = 0;lvi.mask = LVIF_TEXT;lvi.pszText = szBuf;lvi.cchTextMax = 1024;m_list.GetItem(&#38;lvi); More infomation: Q173242: Use Masks to Set/Get Item States in CListCtrl 9. Get the header titile of CListCtrl LVCOLUMN lvcol;char&#160; str[256];int&#160;&#160; nColNum;CString&#160; strColumnName[MAX_COL];nColNum = 0;lvcol.mask = LVCF_TEXT;lvcol.pszText = str;lvcol.cchTextMax = 256;while(m_list.GetColumn(nColNum, &#38;lvcol)){&#160;&#160;&#160; [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li>
<p><a href="http://www.ucosoft.com/2008/06/03/30-greate-tips-of-clistctrl-program1.html">30 Great Tips of CListCtrl Program(1)</a></p>
</li>
</ul>
<p><strong>8. Get Item Infomation</strong></p>
<p>TCHAR szBuf[1024];<br />LVITEM lvi;<br />lvi.iItem = nItemIndex;<br />lvi.iSubItem = 0;<br />lvi.mask = LVIF_TEXT;<br />lvi.pszText = szBuf;<br />lvi.cchTextMax = 1024;<br />m_list.GetItem(&amp;lvi);
<p>More infomation: <a href="http://support.microsoft.com/kb/173242/en-us" target="_blank">Q173242: Use Masks to Set/Get Item States in CListCtrl</a>
<p><strong>9. Get the header titile of CListCtrl</strong><br />
<blockquote>
<p>LVCOLUMN lvcol;<br />char&nbsp; str[256];<br />int&nbsp;&nbsp; nColNum;<br />CString&nbsp; strColumnName[MAX_COL];<br />nColNum = 0;<br />lvcol.mask = LVCF_TEXT;<br />lvcol.pszText = str;<br />lvcol.cchTextMax = 256;<br />while(m_list.GetColumn(nColNum, &amp;lvcol))<br />{<br />&nbsp;&nbsp;&nbsp; strColumnName[nColNum] = lvcol.pszText;<br />&nbsp;&nbsp;&nbsp; nColNum++;<br />}</p>
</blockquote>
<p><strong>10. Scoll the scollbar to ensure item visible</strong></p>
<p><span id="more-108"></span></p>
<p><strong></strong>&nbsp;</p>
<blockquote><p>m_list.EnsureVisible(i, FALSE);</p>
</blockquote>
<p><strong>11. Get the column count of CListCtrl</strong></p>
<blockquote><p>int nHeadNum = m_list.GetHeaderCtrl()-&gt;GetItemCount();</p>
</blockquote>
<p><strong>12. Delete all the columns</strong></p>
<p><strong>Method 1:</strong></p>
<blockquote><p>while ( m_list.DeleteColumn (0));</p>
</blockquote>
<p>Once you delete the first column, the next columns will move above.</p>
<p><strong>Method 2:</strong></p>
<blockquote><p>for (int i=nColumns-1; i&gt;=0; i&#8211;)
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_list.DeleteColumn (i);</p>
</blockquote>
<p><strong>13. Get the row and column index of the clicked item</strong>
<p><strong>Method 1:</strong><br />
<blockquote>
<p>void CTestDlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)<br />{<br />&nbsp;&nbsp; DWORD dwPos = GetMessagePos();<br />&nbsp;&nbsp; CPoint point( LOWORD(dwPos), HIWORD(dwPos) );<br />&nbsp;&nbsp; m_list.ScreenToClient(&amp;point);<br />&nbsp;&nbsp; LVHITTESTINFO lvinfo;<br />&nbsp;&nbsp; lvinfo.pt = point;<br />&nbsp;&nbsp; lvinfo.flags = LVHT_ABOVE;<br />&nbsp;&nbsp; int nItem = m_list.SubItemHitTest(&amp;lvinfo);<br />&nbsp;&nbsp; if(nItem != -1)<br />&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CString strtemp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strtemp.Format(&#8220;You clicked row %d column %d&#8221;, lvinfo.iItem, lvinfo.iSubItem);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AfxMessageBox(strtemp);<br />&nbsp;&nbsp; }<br />}</p>
</blockquote>
<p><strong>Method 2:</strong></p>
<blockquote><p>void CTestDlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)<br />{<br />&nbsp;&nbsp; NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;<br />&nbsp;&nbsp; if(pNMListView-&gt;iItem != -1)<br />&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CString strtemp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strtemp.Format(&#8220;You clicked row %d column %d&#8221;,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pNMListView-&gt;iItem, pNMListView-&gt;iSubItem);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AfxMessageBox(strtemp);<br />&nbsp;&nbsp; }<br />}</p>
</blockquote>
<p>14. Check if you clicked on the checkbox</p>
<blockquote><p>void CTestDlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)<br />{<br />&nbsp;&nbsp; DWORD dwPos = GetMessagePos();<br />&nbsp;&nbsp; CPoint point( LOWORD(dwPos), HIWORD(dwPos) );<br />&nbsp;&nbsp; m_list.ScreenToClient(&amp;point);<br />&nbsp;&nbsp; LVHITTESTINFO lvinfo;<br />&nbsp;&nbsp; lvinfo.pt = point;<br />&nbsp;&nbsp; lvinfo.flags = LVHT_ABOVE;<br />&nbsp;&nbsp; UINT nFlag;<br />&nbsp;&nbsp; int nItem = m_list.HitTest(point, &amp;nFlag);<br />&nbsp;&nbsp; if(nFlag == LVHT_ONITEMSTATEICON)<br />&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AfxMessageBox(&#8220;clicked on the checkbox&#8221;);<br />&nbsp;&nbsp; }<br />&nbsp;&nbsp; *pResult = 0;<br />}</p>
</blockquote>
<p><strong>15. pop up menu when right mouse button clicked</strong></p>
<blockquote><p>void CTestDlg::OnRclickList1(NMHDR* pNMHDR, LRESULT* pResult)<br />{<br />&nbsp;&nbsp;&nbsp; NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;<br />&nbsp;&nbsp;&nbsp; if(pNMListView-&gt;iItem != -1)<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DWORD dwPos = GetMessagePos();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CPoint point( LOWORD(dwPos), HIWORD(dwPos) );<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CMenu menu;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VERIFY( menu.LoadMenu( IDR_MENU1 ) );<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CMenu* popup = menu.GetSubMenu(0);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ASSERT( popup != NULL );<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; popup-&gt;TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this );<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; *pResult = 0;<br />}</p>
</blockquote>

	Tags: <strong><a href="http://www.ucosoft.com/tag/clistctrl" title="CListCtrl" rel="tag">CListCtrl</a>, <a href="http://www.ucosoft.com/tag/tips" title="Tips" rel="tag">Tips</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/30-great-tips-of-clistctrl-program2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>30 Great Tips of CListCtrl Program(1)</title>
		<link>http://www.ucosoft.com/30-greate-tips-of-clistctrl-program1.html</link>
		<comments>http://www.ucosoft.com/30-greate-tips-of-clistctrl-program1.html#comments</comments>
		<pubDate>Tue, 03 Jun 2008 01:21:22 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[Win32/MFC]]></category>
		<category><![CDATA[CListCtrl]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/2008/06/03/30-greate-tips-of-clistctrl-program1.html</guid>
		<description><![CDATA[Without a special note,the listctrl has the default view style of report. 1. CListCtrl style &#160;&#160;&#160;&#160;&#160;&#160; LVS_ICON: for each item displayed great icon &#160;&#160;&#160;&#160;&#160;&#160; LVS_SMALLICON: for each item displayed on the icon &#160;&#160;&#160;&#160;&#160;&#160; LVS_LIST: a show with a small icon on the item &#160;&#160;&#160;&#160;&#160;&#160; LVS_REPORT: Show item details &#160;&#160;&#160;&#160;&#160;&#160; You can inspect the Windows Explorer, [...]]]></description>
			<content:encoded><![CDATA[<p>Without a special note,the listctrl has the default view style of report. </p>
<p><strong>1. </strong><a href="http://www.ucosoft.com/tag/clistctrl" target="_blank"><strong>CListCtrl</strong></a><strong> style</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LVS_ICON: for each item displayed great icon</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LVS_SMALLICON: for each item displayed on the icon </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LVS_LIST: a show with a small icon on the item </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LVS_REPORT: Show item details </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; You can inspect the Windows Explorer, just like &#8220;View&#8221; tab with &#8220;icon, small icon, list details&#8221;</p>
<p><strong>2. </strong><a href="http://www.ucosoft.com/tag/clistctrl" target="_blank"><strong>CListctrl</strong></a><strong> style and expand style </strong></p>
<p>LONG lStyle; <br />lStyle = GetWindowLong (m_list.m_hWnd, GWL_STYLE); // Get the current window style <br />lStyle &amp;= ~ LVS_TYPEMASK; // Clear display <br />lStyle |= LVS_REPORT; // set style <br />SetWindowLong (m_list.m_hWnd, GWL_STYLE, lStyle); // set style <br />DWORD dwStyle = m_list.GetExtendedStyle (); <br />dwStyle |= LVS_EX_FULLROWSELECT; // highlight the selected full row<br />dwStyle |= LVS_EX_GRIDLINES; // grid lines (with the style of the report) <br />dwStyle |= LVS_EX_CHECKBOXES; // checkbox controls <br />m_list.SetExtendedStyle (dwStyle); // set expand style
<p>Note: Please check <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceshellui5/html/wce50lrflistviewstyles.asp" target="_blank">MSDN</a> for style details.</p>
<p><span id="more-107"></span></p>
<p><strong>3. Insert data</strong> </p>
<p>m_list.InsertColumn (0, &#8220;ID&#8221;, LVCFMT_LEFT, 40); // insert column <br />m_list.InsertColumn (1, &#8220;NAME&#8221;, LVCFMT_LEFT, 50); <br />int nRow = m_list.InsertItem (0, &#8220;11 &#8220;);// Row <br />m_list.SetItemText (nRow, 1, &#8220;jacky &#8220;);// set of data</p>
<p><strong>4. Always selected item <br /></strong>Check the style of Show selection always, or in the section 2&nbsp; above set LVS_SHOWSELALWAYS style.</p>
<p><strong>5. Check and uncheck a row</strong></p>
<p>int nIndex = 0; <br />// Check <br />m_list.SetItemState (nIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); <br />// Uncheck <br />m_list.SetItemState (nIndex, 0, LVIS_SELECTED | LVIS_FOCUSED);
<p><strong>6. Get the checkbox status of all the rows</strong>
<p>m_list.SetExtendedStyle(LVS_EX_CHECKBOXES);<br />CString str;<br />for(int i=0; i&lt;nRowCount;i++) <br />{<br />&nbsp;&nbsp; if( m_list.GetItemState(i, LVIS_SELECTED) == LVIS_SELECTED || m_list.GetCheck(i))<br />&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; str.Format(_T(&#8220;checkbox checked in row %d&#8221;), i);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AfxMessageBox(str);<br />&nbsp;&nbsp; }<br />}
<p><strong>7. Get the selected row index</strong>
<p><strong>Method 1:</strong>
<p>CString str;<br />for(int i=0; i&lt;nRowCount;i++)<br />{<br />&nbsp;&nbsp;&nbsp; if( m_list.GetItemState(i, LVIS_SELECTED) == LVIS_SELECTED )<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; str.Format(_T(&#8220;ROW %d selected.&#8221;), i);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AfxMessageBox(str);<br />&nbsp;&nbsp;&nbsp; }<br />}
<p><strong>Method 2:</strong></p>
<p>POSITION pos = m_list.GetFirstSelectedItemPosition();<br />if (pos == NULL)<br />TRACE0(&#8220;No items were selected!\n&#8221;);<br />else<br />{<br />&nbsp;&nbsp;&nbsp; while (pos)<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int nItem = m_list.GetNextSelectedItem(pos);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TRACE1(&#8220;Item %d was selected!\n&#8221;, nItem);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // you could do your own processing on nItem here<br />&nbsp;&nbsp;&nbsp; }<br />}  </p>

	Tags: <strong><a href="http://www.ucosoft.com/tag/clistctrl" title="CListCtrl" rel="tag">CListCtrl</a>, <a href="http://www.ucosoft.com/tag/tips" title="Tips" rel="tag">Tips</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/30-greate-tips-of-clistctrl-program1.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Simplest way to change the row height of CListCtrl</title>
		<link>http://www.ucosoft.com/the-simplest-way-to-change-the-row-height-of-clistctrl.html</link>
		<comments>http://www.ucosoft.com/the-simplest-way-to-change-the-row-height-of-clistctrl.html#comments</comments>
		<pubDate>Mon, 14 Jan 2008 01:41:38 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[Win32/MFC]]></category>
		<category><![CDATA[CListCtrl]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/2008/01/14/the-simplest-way-to-change-the-row-height-of-clistctrl.html</guid>
		<description><![CDATA[In the post &#8220;How to change the row height of CListCtrl&#8220;, it gives 2 solution example how to change row height or CListCtrl. Hower, it is not the simplest way. The simplest way to change the row height in a CListCtrl is: Display an icon with the desired height. All other ways that I know [...]]]></description>
			<content:encoded><![CDATA[<p>In the post &#8220;<a href="http://www.ucosoft.com/2006/12/05/how-to-change-the-row-height-of-clistctrl.html">How to change the row height of CListCtrl</a>&#8220;, it gives 2 solution example how to change row height or CListCtrl. Hower, it is not the simplest way.</p>
<p>The <strong>simplest</strong> way to change the row height in a CListCtrl is:<br />
<blockquote>
<p>Display an icon with the desired height. </p>
</blockquote>
<p>All other ways that I know of require significant programming (such as <strong>owner draw</strong>, which is often too much work). </p>

	Tags: <strong><a href="http://www.ucosoft.com/tag/clistctrl" title="CListCtrl" rel="tag">CListCtrl</a>, <a href="http://www.ucosoft.com/tag/tips" title="Tips" rel="tag">Tips</a>, <a href="http://www.ucosoft.com/tag/mfc" title="Win32/MFC" rel="tag">Win32/MFC</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/the-simplest-way-to-change-the-row-height-of-clistctrl.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Adding CTreeCtrl in CListCtrl</title>
		<link>http://www.ucosoft.com/how-to-adding-ctreectrl-in-clistctrl.html</link>
		<comments>http://www.ucosoft.com/how-to-adding-ctreectrl-in-clistctrl.html#comments</comments>
		<pubDate>Sun, 06 Jan 2008 23:09:57 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[CListCtrl]]></category>
		<category><![CDATA[CTreeCtrl]]></category>
		<category><![CDATA[Win32/MFC]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/2008/01/07/how-to-adding-ctreectrl-in-clistctrl.html</guid>
		<description><![CDATA[In some case, you need such a control as the following figure: It&#8217;s a CListCtrl like control, but it binds a CTreeCtrl in the first column. But you can also consider it as a CTreeCtrl and each of the items has the list style. All roads lead to Rome. But in 1999, David Lantsman has [...]]]></description>
			<content:encoded><![CDATA[<p>In some case, you need such a control as the following figure:</p>
<p><img height="260" alt="treelist" src="http://www.ucosoft.com/wp-content/uploads/2008/01/windowslivewriterhowtoaddingctreectrlinclistctrl-d7fetreelist-3.jpg" width="476"> </p>
<p>It&#8217;s a CListCtrl like control, but it binds a CTreeCtrl in the first column. But you can also consider it as a CTreeCtrl and each of the items has the list style.</p>
<p>All roads lead to Rome. But in 1999, <b><a href="http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=64">David Lantsman</a></b> has already given a solution on CodeProject and named it CTreeList: <a href="http://www.codeproject.com/KB/tree/treelist.aspx" target="_blank">A TreeList Control</a>.</p>
<p>You can <a href="http://www.codeproject.com/KB/tree/treelist/treelist_demo.zip">Download demo project &#8211; 60 Kb</a> and <a href="http://www.codeproject.com/KB/tree/treelist/treelist_src.zip">Download source files &#8211; 21 Kb</a> from codeproject.</p>

	Tags: <strong><a href="http://www.ucosoft.com/tag/clistctrl" title="CListCtrl" rel="tag">CListCtrl</a>, <a href="http://www.ucosoft.com/tag/ctreectrl" title="CTreeCtrl" rel="tag">CTreeCtrl</a>, <a href="http://www.ucosoft.com/tag/mfc" title="Win32/MFC" rel="tag">Win32/MFC</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/how-to-adding-ctreectrl-in-clistctrl.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How do I subclass the CListCtrl part of a CListView Class?</title>
		<link>http://www.ucosoft.com/how-do-i-subclass-the-clistctrl-part-of-a-clistview-class.html</link>
		<comments>http://www.ucosoft.com/how-do-i-subclass-the-clistctrl-part-of-a-clistview-class.html#comments</comments>
		<pubDate>Mon, 22 Oct 2007 06:49:07 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[Win32/MFC]]></category>
		<category><![CDATA[CListCtrl]]></category>
		<category><![CDATA[CListView]]></category>
		<category><![CDATA[Howto]]></category>
		<category><![CDATA[Subclass]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/2007/10/22/how-do-i-subclass-the-clistctrl-part-of-a-clistview-class.html</guid>
		<description><![CDATA[Read this article: How to use an derived CListCtrl in CListView Tags: CListCtrl, CListView, Howto, Subclass]]></description>
			<content:encoded><![CDATA[<p>Read this article:</p>
<p><a href="http://www.ucosoft.com/2007/10/22/how-to-use-an-derived-clistctrl-in-clistview.html">How to use an derived CListCtrl in CListView</a></p>

	Tags: <strong><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/howto" title="Howto" rel="tag">Howto</a>, <a href="http://www.ucosoft.com/tag/subclass" title="Subclass" rel="tag">Subclass</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/how-do-i-subclass-the-clistctrl-part-of-a-clistview-class.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>
		<item>
		<title>How to use an derived CListCtrl in CListView</title>
		<link>http://www.ucosoft.com/how-to-use-an-derived-clistctrl-in-clistview.html</link>
		<comments>http://www.ucosoft.com/how-to-use-an-derived-clistctrl-in-clistview.html#comments</comments>
		<pubDate>Mon, 22 Oct 2007 03:15:01 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[CListCtrl]]></category>
		<category><![CDATA[CListView]]></category>
		<category><![CDATA[CView]]></category>
		<category><![CDATA[Win32/MFC]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/2007/10/22/how-to-use-an-derived-clistctrl-in-clistview.html</guid>
		<description><![CDATA[Sometime you use CListView and need to extend the functionality of the CListCtrl of the view. For example, you want to overwrite the handler function of the NM_CUSTOMDRAW or WM_SIZE message. So the problem is: How to tell CListView to use your own CListCtrl? OK, you are on the wrong way now. The CListView does [...]]]></description>
			<content:encoded><![CDATA[<p>Sometime you use CListView and need to extend the functionality of the CListCtrl of the view. For example, you want to overwrite the handler function of the NM_CUSTOMDRAW or WM_SIZE message. So the problem is: <strong>How to tell CListView to use your own CListCtrl?</strong></p>
<p>OK, you are on the wrong way now.</p>
<p>The CListView does not use or contain the MFC <b>CListCtrl</b>, it only wraps a subclassed SysListView32 control as a CCtrlView, in the other hand, the view is the control. </p>
<p>If all you&#8217;ve done in your custom <b>CListCtrl</b> derived class is to handle the reflected NM_CUSTOMDRAW message, your best bet to get this working as a custom CListView is to derive a class from CListView and handle the reflected message for it just as you do in your <b>CListCtrl </b>derived implementation.</p>
<p>If you want get&nbsp; more custom control or you have already make an extended version of CList, It may be easier to derive a view class from CView and use your own CListCtrl in the view.</p>
<p>There are two articles about this topic on CodeGuru:</p>
<ul>
<li><a href="http://www.codeguru.com/doc_view/custom_view.shtml">http://www.codeguru.com/doc_view/custom_view.shtml</a> </li>
<li><a href="http://www.codeguru.com/doc_view/Control2View.shtml">http://www.codeguru.com/doc_view/Control2View.shtml</a></li>
</ul>

	Tags: <strong><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/cview" title="CView" rel="tag">CView</a>, <a href="http://www.ucosoft.com/tag/mfc" title="Win32/MFC" rel="tag">Win32/MFC</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/how-to-use-an-derived-clistctrl-in-clistview.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to select the item of ListView(CListCtrl)</title>
		<link>http://www.ucosoft.com/how-to-select-the-item-of-listviewclistctrl.html</link>
		<comments>http://www.ucosoft.com/how-to-select-the-item-of-listviewclistctrl.html#comments</comments>
		<pubDate>Thu, 18 Oct 2007 12:07:30 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[CListCtrl]]></category>
		<category><![CDATA[Win32/MFC]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/2007/10/18/how-to-select-the-item-of-listviewclistctrl.html</guid>
		<description><![CDATA[Use CListCtrl::SetItemState with LVIS_SELECTED Tags: CListCtrl, Win32/MFC]]></description>
			<content:encoded><![CDATA[<p>Use CListCtrl::SetItemState with LVIS_SELECTED</p>

	Tags: <strong><a href="http://www.ucosoft.com/tag/clistctrl" title="CListCtrl" rel="tag">CListCtrl</a>, <a href="http://www.ucosoft.com/tag/mfc" title="Win32/MFC" rel="tag">Win32/MFC</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/how-to-select-the-item-of-listviewclistctrl.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to change the row height of CListCtrl</title>
		<link>http://www.ucosoft.com/how-to-change-the-row-height-of-clistctrl.html</link>
		<comments>http://www.ucosoft.com/how-to-change-the-row-height-of-clistctrl.html#comments</comments>
		<pubDate>Wed, 06 Dec 2006 02:34:32 +0000</pubDate>
		<dc:creator>hamo</dc:creator>
				<category><![CDATA[Win32/MFC]]></category>
		<category><![CDATA[CListCtrl]]></category>
		<category><![CDATA[Cpp]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/archives/54.html</guid>
		<description><![CDATA[When you&#160;want to change the height of CListCtrl, you need to use an owner-draw version of CListCtrl and change the font of the control. But when&#160;you change the font of&#160;the CListCtrl, the control or its parent window does not get a chance to respecify the height of the rows and the effect will not be [...]]]></description>
			<content:encoded><![CDATA[<p>When you&nbsp;want to change the height of CListCtrl, you need to use an owner-draw version of CListCtrl and change the font of the control. But when&nbsp;you change the font of&nbsp;the CListCtrl, the control or its parent window does not get a chance to respecify the height of the rows and the effect will not be taken. The reason is that No WM_MEASUREITEM message is sent to the controls parent window. </p>
<p>The following article from <a href="http://www.codeproject.com" rel="nofollow">CodeProject</a>&nbsp;provided a good solution.</p>
<p><!--adsensex-->
<ul>
<li><a href="http://www.codeproject.com/listctrl/changerowheight.asp">Changing Row Height in an owner drawn Control</a></li>
</ul>
<p>And there is a similar&nbsp;article on CodeGuru.</p>
<ul>
<li><a href="http://www.codeguru.com/Cpp/controls/listview/advanced/article.php/c1013" rel="nofollow">Changing row height in owner drawn control</a></li>
</ul>

	Tags: <strong><a href="http://www.ucosoft.com/tag/clistctrl" title="CListCtrl" rel="tag">CListCtrl</a>, <a href="http://www.ucosoft.com/tag/cpp" title="Cpp" rel="tag">Cpp</a>, <a href="http://www.ucosoft.com/tag/win32mfc" title="Win32/MFC" rel="tag">Win32/MFC</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/how-to-change-the-row-height-of-clistctrl.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

