<?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; Win32/MFC</title>
	<atom:link href="http://www.ucosoft.com/category/mfc/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>How to catch the events when click on the app icon on taskbar</title>
		<link>http://www.ucosoft.com/events-when-click-ontaskbar.html</link>
		<comments>http://www.ucosoft.com/events-when-click-ontaskbar.html#comments</comments>
		<pubDate>Wed, 24 Sep 2008 07:55:05 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[Win32/MFC]]></category>
		<category><![CDATA[message]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/2008/09/24/events-when-click-ontaskbar.html</guid>
		<description><![CDATA[How to catch the events when you click on the application's icon on the taskbar? It&#8217;s the WM_NC class messages. For example, you can handle the WM_NCLBUTTONDBLCLK message. And you can alse reponsible the&#160; WM_SYSCOMMAND messages.&#160; In particular, the special cases of SC_MINIMIZE and SC_MAXIMIZE are what are called from the system menu, which is [...]]]></description>
			<content:encoded><![CDATA[<pre class="csharpcode">How to catch the events when you click on the application's icon on the taskbar?</pre>
<p><span id="more-110"></span></p>
<p>It&#8217;s the WM_NC class messages. For example, you can handle the WM_NCLBUTTONDBLCLK message.</p>
<p>And you can alse reponsible the&#160; WM_SYSCOMMAND messages.&#160; In particular, the special cases of SC_MINIMIZE and SC_MAXIMIZE are what are called from the system menu, which is what is available from the taskbar. </p>

	Tags: <strong><a href="http://www.ucosoft.com/tag/message" title="message" rel="tag">message</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/events-when-click-ontaskbar.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 hilight an item in CTreeCtrl/CTreeView</title>
		<link>http://www.ucosoft.com/how-to-hilight-an-item-in-ctreectrlctreeview.html</link>
		<comments>http://www.ucosoft.com/how-to-hilight-an-item-in-ctreectrlctreeview.html#comments</comments>
		<pubDate>Thu, 25 Oct 2007 03:28:01 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[Win32/MFC]]></category>
		<category><![CDATA[CTreeCtrl]]></category>
		<category><![CDATA[CTreeView]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/2007/10/25/how-to-hilight-an-item-in-ctreectrlctreeview.html</guid>
		<description><![CDATA[How to hilight or bold an item in CTreeCtrl/CTreeView? There is no real difference between CTreeCtrl and CTreeView. You need to use an owner draw tree control. Takeover the NM_CUSTOMDRAW message, and it will allow you to change the font, brush, etc. of each individual item. You don&#8217;t need to do any owner draw if [...]]]></description>
			<content:encoded><![CDATA[<p>How to hilight or bold an item in CTreeCtrl/CTreeView?</p>
<p>There is no real difference between CTreeCtrl and CTreeView. You need to use an owner draw tree control. </p>
<p> Takeover the NM_CUSTOMDRAW message, and it will allow you to change the font, brush, etc. of each individual item. You don&#8217;t need to do any owner draw if you use customdraw.</p>
<p>The following articles wil save you plenty of work.
<ul>
<li><a href="http://www.codeproject.com/treectrl/#Custom+Tree+Controls">http://www.codeproject.com/treectrl/#Custom+Tree+Controls</a></li>
<li><a href="http://www.codeproject.com/treectrl/colortreectrl.asp">http://www.codeproject.com/treectrl/colortreectrl.asp</a></li>
</ul>

	Tags: <strong><a href="http://www.ucosoft.com/tag/ctreectrl" title="CTreeCtrl" rel="tag">CTreeCtrl</a>, <a href="http://www.ucosoft.com/tag/ctreeview" title="CTreeView" rel="tag">CTreeView</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/how-to-hilight-an-item-in-ctreectrlctreeview.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to subclass CTreeCtrl in CTreeView?</title>
		<link>http://www.ucosoft.com/how-to-subclass-ctreectrl-in-ctreeview.html</link>
		<comments>http://www.ucosoft.com/how-to-subclass-ctreectrl-in-ctreeview.html#comments</comments>
		<pubDate>Thu, 25 Oct 2007 03:16:23 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[Win32/MFC]]></category>
		<category><![CDATA[CTreeCtrl]]></category>
		<category><![CDATA[CTreeView]]></category>
		<category><![CDATA[CView]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[Subclass]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/2007/10/25/how-to-subclass-ctreectrl-in-ctreeview.html</guid>
		<description><![CDATA[Another title: How to use a derived CTreeCtrl in a CTreeView? It is similar with this article: &#8220;How to use an derived CListCtrl in CListView&#8221; or &#8220;How do I subclass the CListCtrl part of a CListView Class?&#8220;. Just like CListView, there is no CTreeCtrl to subclass in CTreeView. The CTreeView is the subclass of the [...]]]></description>
			<content:encoded><![CDATA[<p>Another title:</p>
<p><strong>How to use a derived CTreeCtrl in a CTreeView?</strong></p>
<p>It is similar with this article: &#8220;<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>&#8221; or &#8220;<a href="http://www.ucosoft.com/2007/10/22/how-do-i-subclass-the-clistctrl-part-of-a-clistview-class.html">How do I subclass the CListCtrl part of a CListView Class?</a>&#8220;.</p>
<p>Just like CListView, there is no CTreeCtrl to subclass in CTreeView. The CTreeView is the subclass of the WC_TREEVIEW common control. If you need some extra feature in the CTreeView, the best way is like the method mentioned in the previous two articles:</p>
<p>Forget CTreeView and derive your own view CMyView from CView, and bond your CMyTreeCtrl in the view. Now you got the full control of the tree.</p>
<p>These two articles may be helpful to you:&nbsp;
<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/ctreectrl" title="CTreeCtrl" rel="tag">CTreeCtrl</a>, <a href="http://www.ucosoft.com/tag/ctreeview" title="CTreeView" rel="tag">CTreeView</a>, <a href="http://www.ucosoft.com/tag/cview" title="CView" rel="tag">CView</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/subclass" title="Subclass" rel="tag">Subclass</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/how-to-subclass-ctreectrl-in-ctreeview.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>Link error when mix MBCS and Unicode in ONE project</title>
		<link>http://www.ucosoft.com/link-error-when-mix-mbcs-and-unicode-in-one-project.html</link>
		<comments>http://www.ucosoft.com/link-error-when-mix-mbcs-and-unicode-in-one-project.html#comments</comments>
		<pubDate>Thu, 18 Oct 2007 13:58:10 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[Win32/MFC]]></category>
		<category><![CDATA[Link error]]></category>
		<category><![CDATA[MBCS]]></category>
		<category><![CDATA[UNICODE]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/2007/10/18/link-error-when-mix-mbcs-and-unicode-in-one-project.html</guid>
		<description><![CDATA[A Solution which contents 3 projects and below are the names &#38; their character set encoding type 1. Utility &#8211; &#62; MBCS 2. Calculations -&#62; MBCS 3. User Interface -&#62; Unicode&#xA0; ( Earlier It used to be MBCS) WhenChanged the&#xA0; Character set encoding for User Interface and compiled the code, you will get hte Errors [...]]]></description>
			<content:encoded><![CDATA[<p>A Solution which contents 3 projects and below are the names &amp; their character set encoding type </p>
<p>1. Utility &#8211; &gt; MBCS    <br />2. Calculations -&gt; MBCS     <br />3. User Interface -&gt; Unicode&#xA0; ( Earlier It used to be MBCS) </p>
<p>WhenChanged the&#xA0; Character set encoding for User Interface and compiled the code, you will get hte Errors for the Char type that corrected all of then and made them Wide characters. </p>
<p>When&#xA0; the project gets compiled but it gives Linker errors. Can you please let me know Do I need to convert all the Projects to use Unicode character set ? </p>
<p><strong>Replies:</strong></p>
<p><strong>FIRST</strong>, you can mix Unicode and MBCS modules, if you keep the interface between them *clear*.</p>
<p>e.g. if you just specify CString in the interface between module, this is *not* clear and unambigous; in fact, CString is &quot;ambigous&quot;, because it can be considered CStringA (MBCS) or CStringW (Unicode) basing on build options. </p>
<p>This is the same with e.g. LPCTSTR, or TCHAR. </p>
<p>You can&#8217;t use LPCTSTR or TCHAR or CString at the *interface* between modules that are ANSI (MBCS) on one side and Unicode on the other side. </p>
<p>So, on the interface, you must explicit qualify the string type, e.g. using CStringA or CStringW, or wchar_t, or char, etc. &#8230; </p>
<p>For example, suppose that you have in Utility (ANSI) a function that you want to use in UserInterface module (Unicode). You must use an explicit unambigous prototype like so for Utility function: </p>
<p>&#xA0; void Utility_ProcessString( const char * string ); </p>
<p>&#xA0; // or:    <br />&#xA0; // void Utility_ProcessString( const CStringA &amp; string ); </p>
<p>Of course, in UserInterface you can convert a Unicode string to MBCS and pass the converted string (const char*) to Utility_ProcessString. </p>
<p><strong>BUT, </strong>Converting the interface is usually a much bigger job than converting the complete project to UNICODE. You should have a very very good reason to mix MBCS and UNICODE in the same project. I can not think of one.</p>
<p>But mixing UTF-8 and UTF-16 can be a valid strategy, and involves much the same issues. Unicode UTF-8 is good for storage (e.g. in XML files, or when sending string data through Internet), while UTF-16 is good for processing and use inside an app (being also Windows &quot;native&quot; Unicode format).</p>

	Tags: <strong><a href="http://www.ucosoft.com/tag/link-error" title="Link error" rel="tag">Link error</a>, <a href="http://www.ucosoft.com/tag/mbcs" title="MBCS" rel="tag">MBCS</a>, <a href="http://www.ucosoft.com/tag/unicode" title="UNICODE" rel="tag">UNICODE</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/link-error-when-mix-mbcs-and-unicode-in-one-project.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

