📄 vc中使用listctrl经验总结(1.htm
字号:
// Fields this.ParentElement = null; this.OriginalText = ''; this.Enabled = true;}function Anthem_PostProcessCallBack( result, control, eventTarget, clientCallBack, clientCallBackArg, imageUrlDuringCallBack, textDuringCallBack, postCallBackFunction, preProcessOut) { if (postCallBackFunction) { postCallBackFunction(control); } control.disabled = !preProcessOut.Enabled; var inputType = control.getAttribute("type"); inputType = (inputType == null) ? '' : inputType.toUpperCase(); if (inputType == "IMAGE") { var form = document.getElementById(Anthem_FormID); Anthem_RemoveHiddenInput(form, eventTarget + ".x"); Anthem_RemoveHiddenInput(form, eventTarget + ".y"); } if (imageUrlDuringCallBack || textDuringCallBack) { if (control.nodeName.toUpperCase() == "INPUT") { if (inputType == "CHECKBOX" || inputType == "RADIO" || inputType == "TEXT") { SetLabelText(control.id, preProcessOut.OriginalText); } else if (inputType == "IMAGE") { if (imageUrlDuringCallBack) { control.src = preProcessOut.OriginalText; } else { preProcessOut.ParentElement.innerHTML = preProcessOut.OriginalText; } } else if (inputType == "SUBMIT") { control.value = preProcessOut.OriginalText; } } else if (control.nodeName.toUpperCase() == "SELECT") { SetLabelText(control.id, preProcessOut.OriginalText); } else { control.innerHTML = preProcessOut.OriginalText; } } if (clientCallBack) { clientCallBack(result, clientCallBackArg); }}function Anthem_FireCallBackEvent( control, e, eventTarget, eventArgument, causesValidation, validationGroup, imageUrlDuringCallBack, textDuringCallBack, enabledDuringCallBack, preCallBackFunction, postCallBackFunction, callBackCancelledFunction, includeControlValuesWithCallBack, updatePageAfterCallBack) { var preProcessOut = new Anthem_PreProcessCallBackOut(); var preProcessResult = Anthem_PreProcessCallBack( control, e, eventTarget, causesValidation, validationGroup, imageUrlDuringCallBack, textDuringCallBack, enabledDuringCallBack, preCallBackFunction, callBackCancelledFunction, preProcessOut ); if (preProcessResult) { Anthem_FireEvent( eventTarget, eventArgument, function(result) { Anthem_PostProcessCallBack( result, control, eventTarget, null, null, imageUrlDuringCallBack, textDuringCallBack, postCallBackFunction, preProcessOut ); }, null, includeControlValuesWithCallBack, updatePageAfterCallBack ); }}function AnthemListControl_OnClick( e, causesValidation, validationGroup, textDuringCallBack, enabledDuringCallBack, preCallBackFunction, postCallBackFunction, callBackCancelledFunction, includeControlValuesWithCallBack, updatePageAfterCallBack) { var target = e.target || e.srcElement; if (target.nodeName.toUpperCase() == "LABEL" && target.htmlFor != '') return; var eventTarget = target.id.split("_").join("$"); Anthem_FireCallBackEvent( target, e, eventTarget, '', causesValidation, validationGroup, '', textDuringCallBack, enabledDuringCallBack, preCallBackFunction, postCallBackFunction, callBackCancelledFunction, true, true );}function GetLabelText(id) { var labels = document.getElementsByTagName('label'); for (var i = 0; i < labels.length; i++) { if (labels[i].htmlFor == id) { return labels[i].innerHTML; } } return null;}function SetLabelText(id, text) { var labels = document.getElementsByTagName('label'); for (var i = 0; i < labels.length; i++) { if (labels[i].htmlFor == id) { labels[i].innerHTML = text; return; } }}//]]></SCRIPT>
<SCRIPT src="VC中使用ListCtrl经验总结(1.files/WebResource.axd"
type=text/javascript></SCRIPT>
<SCRIPT type=text/javascript>
<!--
function WebForm_OnSubmit() {
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
return true;
}
// -->
</SCRIPT>
<DIV id=top>
<DIV>
<TABLE>
<TBODY>
<TR>
<TD class=HeaderTitles>
<H1><A class=headermaintitle id=Header1_HeaderTitle
href="http://blog.csdn.net/handsomerun/">毛毛(handsomerun)的专栏</A></H1>
<P id=tagline></P></TD></TR></TBODY></TABLE></DIV>
<DIV class=HeaderBar>
<TABLE class=HeaderBar id=HeaderBar>
<TBODY>
<TR>
<TD class=HeaderBarTab noWrap> <A href="http://www.csdn.net/"
target=_blank>CSDN</A> | <A href="http://community.csdn.net/"
target=_blank>社区</A> | <A href="http://dev.csdn.net/"
target=_blank>技术中心</A> | <A id=Header1_MyLinks1_HomeLink
title=到聚合站点 href="http://blog.csdn.net/"
target=_blank>BLOG首页</A> | <A id=Header1_MyLinks1_PersonalHome
title="访问 毛毛(handsomerun)的专栏" href="http://blog.csdn.net/handsomerun/"
target=_blank>我的首页</A> | <A id=Header1_MyLinks1_PersonalResume
href="http://job.csdn.net/resumes/handsomerun.aspx">个人档案</A> |
<A id=Header1_MyLinks1_ContactLink accessKey=9
href="http://blog.csdn.net/handsomerun/contact.aspx">联系作者</A> |
<A id=Header1_MyLinks1_Syndication
href="http://blog.csdn.net/handsomerun/Rss.aspx">聚合</A> <A class=XMLLink
id=Header1_MyLinks1_XMLLink
href="http://blog.csdn.net/handsomerun/Rss.aspx"><IMG
src="VC中使用ListCtrl经验总结(1.files/xml.gif" border=0></A> | <A
id=Header1_MyLinks1_HyperLink1
href="http://search.csdn.net/search_blog.asp"
target=_blank>搜索</A> | <A id=Header1_MyLinks1_Admin
href="http://writeblog.csdn.net/">登录</A> <IMG id=Header1_BlueTab
src="VC中使用ListCtrl经验总结(1.files/BlueTabRight.jpg" align=absMiddle border=0>
</TD>
<TD class=HeaderBarTabBack noWrap width="100%">
<DIV class=BlogStatsBar>
<TABLE class=BlogStatsBar>
<TBODY>
<TR>
<TD width="100%"></TD>
<TD class=BlogStatsBar noWrap> 12篇原创: 0篇翻译: 1篇转载: 3261次点击:
6个评论<SPAN style="DISPLAY: none">: 0个Trackbacks</SPAN>
</TD></TR></TBODY></TABLE></DIV></TD></TR></TBODY></TABLE></DIV></DIV>
<DIV id=leftmenu>
<H3 class=listtitle>文章</H3>
<UL class=list>
<LI class=listitem><A
href="http://blog.csdn.net/handsomerun/category/191668.aspx">VC~基础(C/C++)</A><A
href="http://blog.csdn.net/handsomerun/category/191668.aspx/rss">(RSS)</A>
<LI class=listitem><A
href="http://blog.csdn.net/handsomerun/category/191676.aspx">VC~界面(控件等)</A><A
href="http://blog.csdn.net/handsomerun/category/191676.aspx/rss">(RSS)</A>
<LI class=listitem><A
href="http://blog.csdn.net/handsomerun/category/231910.aspx">VC~进程线程DLL</A><A
href="http://blog.csdn.net/handsomerun/category/231910.aspx/rss">(RSS)</A>
<LI class=listitem><A
href="http://blog.csdn.net/handsomerun/category/232049.aspx">VC~数据库/ATL/ActiveX/COM
</A><A
href="http://blog.csdn.net/handsomerun/category/232049.aspx/rss">(RSS)</A>
<LI class=listitem><A
href="http://blog.csdn.net/handsomerun/category/213750.aspx">数据库(SQL等)</A><A
href="http://blog.csdn.net/handsomerun/category/213750.aspx/rss">(RSS)</A>
<LI class=listitem><A
href="http://blog.csdn.net/handsomerun/category/191670.aspx">杂项</A><A
href="http://blog.csdn.net/handsomerun/category/191670.aspx/rss">(RSS)</A></LI></UL>
<H3 class=listtitle>收藏</H3>
<UL class=list></UL>
<H3 class=listtitle>相册</H3><!--category title-->
<UL class=list></UL>
<H3 class=listtitle>VC网站</H3>
<UL class=list>
<LI class=listitem><A href="http://www.codeproject.com/"
target=_blank>codeproject</A>
<LI class=listitem><A href="http://www.microsoft.com/china/MSDN/"
target=_blank>MSDN 中文网站</A></LI></UL>
<H3 class=listtitle>友情连接</H3>
<UL class=list>
<LI class=listitem><A href="http://blog.sina.com.cn/u/1402693732"
target=_blank>毛毛在新浪的博客~~</A></LI></UL>
<H3 class=listtitle>存档</H3>
<UL class=list>
<LI><A
href="http://blog.csdn.net/handsomerun/archive/2006/09.aspx">2006年09月(3)</A>
<LI><A
href="http://blog.csdn.net/handsomerun/archive/2006/08.aspx">2006年08月(3)</A>
<LI><A
href="http://blog.csdn.net/handsomerun/archive/2006/06.aspx">2006年06月(1)</A>
<LI><A
href="http://blog.csdn.net/handsomerun/archive/2006/04.aspx">2006年04月(6)</A></LI></UL><SPAN
id=Anthem_RecentComments_ltlComments__><SPAN id=RecentComments_ltlComments>
<H3 class=listtitle>最近评论</H3>
<UL class=list>
<LI class=listitem>毛毛:<A title=点击查看《回复:VC中使用ListCtrl经验总结(1)》
href="http://blog.csdn.net/handsomerun/archive/2006/04/13/662462.aspx#504506">to
liuxein : <BR>是可以的,注意设成report风格 <BR>另外,只有查出数据以后,才会显示, <BR><BR>实例代码
<BR><BR>//获得原有风格 <BR>DWORD dwStyle = ::GetWindowLong(plist->m_hWnd,
GWL_STYLE); <BR>dwStyle &= ~(LVS_TYPEMASK); <B……< a>
<LI class=listitem>liuxein:<A title=点击查看《回复:VC中使用ListCtrl经验总结(1)》
href="http://blog.csdn.net/handsomerun/archive/2006/04/13/662462.aspx#504119">我用你条款一的方法加CheckBox怎么加不上啊</A>
<LI class=listitem>毛毛:<A title=点击查看《回复:VC中使用ListCtrl经验总结(1)》
href="http://blog.csdn.net/handsomerun/archive/2006/04/13/662462.aspx#455697">托选是什么,多选吗??晕
<BR><BR>现在的listctrl,如果选择那个多选的属性(控件属性里有),那么就是;(2)按住鼠标左键,并按下ctrl键进行多选。
<BR><BR>如果你想只是左键多选,那么 <BR>自己模拟的,首先判断鼠标左键单击在了listCtrl里面,然后就截获这个消息,修改消息参数
<BR>WM_LBUTTONDOWN <BR><BR>WPARAM wP……</A>
<LI class=listitem>yyh9186:<A title=点击查看《回复:VC中使用ListCtrl经验总结(1)》
href="http://blog.csdn.net/handsomerun/archive/2006/04/13/662462.aspx#455464">您好,我最近遇到个难缠的问题,看了您的文章后,我想您在listctrl方面一定了解很透彻,希望您能帮我解决这个问题。描述如下:listctrl的托选功能,类似于windows托选功能。我分析分为两种情况:(1)按住鼠标左键进行托选;(2)按住鼠标左键,并按下ctrl键进行托选。
<BR>这个问题我自己实在是搞不定了,希望高手您给出代码,我的邮箱: <BR>yyh9186@163.com;ms……</A>
<LI class=listitem>PPG:<A title=点击查看《回复:VC中使用ListCtrl经验总结(1)》
href="http://blog.csdn.net/handsomerun/archive/2006/04/13/662462.aspx#433823">好文章,收藏一下</A></LI></UL></SPAN></SPAN><BR><BR></DIV>
<DIV id=main>
<DIV class=Tag>
<SCRIPT language=javascript src=""></SCRIPT>
<DIV style="CLEAR: both"></DIV></DIV>
<SCRIPT>function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}</SCRIPT>
<DIV class=post>
<DIV class=postTitle><A
href="http://blog.csdn.net/handsomerun/archive/2006/04/13/662462.aspx"><IMG
height=13 src="VC中使用ListCtrl经验总结(1.files/authorship.gif" width=15
border=0> VC中使用ListCtrl经验总结(1)</A> </DIV>
<DIV class=postText>
<P> ListCtrl在工作中,常常用到,也常常看到大家发帖问怎么用这个控件,</P>
<P>故总结了一下自己的使用经验,以供参考使用。</P>
<P> 先注明一下,这里,我们用m_listctrl来表示一个CListCtrl的类对象,</P>
<P>然后这里我们的ListCtrl都是report形式,至于其他的如什么大图标,小图标</P>
<P>的暂时不讲,毕竟report是大众话的使用。其次,我们这里用条款一,条款二</P>
<P>来描述第一点,第二点,这个是参照《Effective C++》的叫法,俺觉得这么</P>
<P>叫比较COOL :)</P>
<P> 条款一:设置ListCtrl的风格</P>
<P> 在CSDN上常常看到有人问怎么设置风格的,他们ListCtrl的样子是一个列表</P>
<P>,有横条和竖条分界线,然后选中一行,要整一行都选中,而不是只有某一列</P>
<P>被选中,等等,这里给一个比较全面的设置方法。</P>
<P>//获得原有风格<BR> DWORD dwStyle = ::GetWindowLong(m_listctrl.m_hWnd,
GWL_STYLE); <BR> dwStyle &= ~(LVS_TYPEMASK);<BR> dwStyle &=
~(LVS_EDITLABELS);</P>
<P> //设置新风格<BR> SetWindowLong(m_listctrl.m_hWnd,
GWL_STYLE, </P>
<P>dwStyle,|LVS_REPORT|LVS_NOLABELWRAP|LVS_SHOWSELALWAYS);</P>
<P><BR> //设置扩展风格<BR> DWORD styles = </P>
<P>LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_CHECKBOXES;</P>
<P> ListView_SetExtendedListViewStyleEx(m_listctrl.m_hWnd, styles, </P>
<P>styles );</P>
<P>其中LVS_EX_FULLROWSELECT 就是前面说得整行选中</P>
<P>LVS_EX_GRIDLINES 网格线(只适用与report风格的listctrl)</P>
<P>LVS_EX_CHECKBOXES 前面加个checkbox</P>
<P>pListCtrl->SetExtendedStyle( m_listctrl.GetExtendedStyle()</P>
<P>|LVS_EX_SUBITEMIMAGES);</P>
<P><BR>这也是一个很重要的属性,这样的话,可以在列表中加ICON,记得windows的</P>
<P>任务管理器吗,你想做得那样,这个属性也要加哦,这个我以后会讲的~</P>
<P>条款二:加入列头</P>
<P> 这是一个比较实质的东西,给列表框分列,然后加上列头</P>
<P> 代码说话,来了</P>
<P> TCHAR rgtsz[2][10] = {_T("列头1"), _T("列头2")};<BR> <BR> LV_COLUMN
lvcolumn;<BR> CRect
rect;<BR> m_listctrl.GetWindowRect(&rect);<BR> for(int
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -