﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-《深入解析ATL》第二版中文版上市-随笔分类-Control</title><link>http://www.cppblog.com/TechLab/category/168.html</link><description>有问题请到CSDN-&gt;VC/MFC讨论</description><language>zh-cn</language><lastBuildDate>Tue, 20 May 2008 07:17:33 GMT</lastBuildDate><pubDate>Tue, 20 May 2008 07:17:33 GMT</pubDate><ttl>60</ttl><item><title>工具栏ToolBar上的CComboBox响应回车</title><link>http://www.cppblog.com/TechLab/archive/2006/05/15/7152.html</link><dc:creator>TechLab</dc:creator><author>TechLab</author><pubDate>Mon, 15 May 2006 01:50:00 GMT</pubDate><guid>http://www.cppblog.com/TechLab/archive/2006/05/15/7152.html</guid><wfw:comment>http://www.cppblog.com/TechLab/comments/7152.html</wfw:comment><comments>http://www.cppblog.com/TechLab/archive/2006/05/15/7152.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/TechLab/comments/commentRss/7152.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/TechLab/services/trackbacks/7152.html</trackback:ping><description><![CDATA[
		<p>在派生CToolBar类的时候, 注意如果用VC6的类向导, 类列表里是没有CToolBar的, 可以选择CToolBarCtrl, 然后手动改为CToolBar( 参考 <a href="http://support.microsoft.com/kb/99161/en-us">http://support.microsoft.com/kb/99161/en-us</a>),<br />//下面的代码是直接手写的<br />#define       IDC_COMBOBOX      11111<br />class CToolBarEx : public CToolBar<br />{<br />   .........//其他的类代码省略<br />   CComboBox   m_Combo;<br />   afx_msg void OnSelectComboBox();<br />   DECLARE_MESSAGE_MAP()<br />};</p>
		<p>BEGIN_MESSAGE_MAP(CToolBarEx, CToolBar)<br />      ON_CBN_SELENDOK(ID_COMBOBOX, OnSelectComboBox)<br />END_MESSAGE_MAP()</p>
		<p>void CToolBarEx::OnSelectComboBox()<br />{<br />}<br />      在上面的一小段代码中, 我们添加了对CBN_SELENDOK消息的处理, 这个消息是CComboBox在完成选择后发送给父窗口的. 处理回车还需要在用户的VK_RETURN<br />消息里模拟发送出这个CBN_SELENDOK消息.</p>
		<p>      所以我们还需要处理PreTranslateMessage函数.函数在类头文件的声明略.<br />BOOL CToolBarEx::PreTranslateMessage(MSG* pMsg)<br />{<br />       if (pMsg-&gt;message == WM_KEYDOWN)<br />       {<br />              NMHDR nm;   <br />              nm.hwndFrom = m_hWnd;<br />              nm.idFrom = GetDlgCtrlID();<br />              nm.code = NM_RETURN;<br />              switch (pMsg-&gt;wParam)<br />              {<br />              case VK_RETURN:<br />                     //发送通知消息<br />                     if( m_Combo.IsChild(GetFocus()) )<br />                     OnSelectComboBox();<br />                     GetOwner()-&gt;SendMessage(WM_NOTIFY, nm.idFrom, (LPARAM)&amp;nm);<br />                     return TRUE;<br />  }<br /> }<br /> return CToolBar::PreTranslateMessage(pMsg);<br />}<br /></p>
<img src ="http://www.cppblog.com/TechLab/aggbug/7152.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/TechLab/" target="_blank">TechLab</a> 2006-05-15 09:50 <a href="http://www.cppblog.com/TechLab/archive/2006/05/15/7152.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>CSpinButtonCtrl的弱智问题</title><link>http://www.cppblog.com/TechLab/archive/2005/11/03/920.html</link><dc:creator>TechLab</dc:creator><author>TechLab</author><pubDate>Thu, 03 Nov 2005 09:13:00 GMT</pubDate><guid>http://www.cppblog.com/TechLab/archive/2005/11/03/920.html</guid><wfw:comment>http://www.cppblog.com/TechLab/comments/920.html</wfw:comment><comments>http://www.cppblog.com/TechLab/archive/2005/11/03/920.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/TechLab/comments/commentRss/920.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/TechLab/services/trackbacks/920.html</trackback:ping><description><![CDATA[<P>今天做的一个复合控件中用到了CSpinButtonCtrl。直接就写了下面的代码：<BR>CEdit&nbsp;&nbsp;&nbsp;*pEdit=new CEdit;<BR>CRect&nbsp;&nbsp;&nbsp;rc;<BR>pEdit-&gt;CreateEx(WS_EX_STATICEDGE,"EDIT",NULL,|WS_CHILD|WS_TABSTOP,rc,this,ID_EDIT)<BR>pEdit-&gt;ShowWindow(SW_SHOW);<BR>CSpinButtonCtrl&nbsp;&nbsp;&nbsp;m_CornerSpin;<BR>m_CornerSpin.Create(UDS_ALIGNRIGHT|WS_CHILD|UDS_SETBUDDYINT,rc,this,ID_SPIN_BUTTON)<BR>m_CornerSpin.ShowWindow(SW_SHOW);&nbsp;<BR>m_CornerSpin.SetBuddy(pEdit);<BR>&nbsp;<BR>问题出来了，微调的SpinCtrl没有显示。后来多次调试发现，如果注释了最后一个SetBuddy函数的调用，又可以显示了。晕倒........<BR><BR>最后无意识的把SetBuddy和ShowWindow对换一下调用的顺序，嘿嘿，It is Working.<BR><BR>现在还不知道什么原因...........</P><img src ="http://www.cppblog.com/TechLab/aggbug/920.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/TechLab/" target="_blank">TechLab</a> 2005-11-03 17:13 <a href="http://www.cppblog.com/TechLab/archive/2005/11/03/920.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>让TOOLBAR呈多列显示</title><link>http://www.cppblog.com/TechLab/archive/2005/10/20/757.html</link><dc:creator>TechLab</dc:creator><author>TechLab</author><pubDate>Thu, 20 Oct 2005 06:25:00 GMT</pubDate><guid>http://www.cppblog.com/TechLab/archive/2005/10/20/757.html</guid><wfw:comment>http://www.cppblog.com/TechLab/comments/757.html</wfw:comment><comments>http://www.cppblog.com/TechLab/archive/2005/10/20/757.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/TechLab/comments/commentRss/757.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/TechLab/services/trackbacks/757.html</trackback:ping><description><![CDATA[<P>这是MSDN的例子，纪录于此，便于查找。有的时候需要让TOOLBAR呈多列显示，TBSTATE_WRAP表示让工具栏换行，而TBBS_WRAPPED是MFC中定义的一个宏MAKELONG(0, TBSTATE_WRAP)，下面的代码是MFC例子CTRLBARS中的。说明了如何设置多列的工具栏。<BR>void CPaletteBar::SetColumns(UINT nColumns)<BR>{<BR>       m_nColumns = nColumns;<BR>       int nCount = GetToolBarCtrl().GetButtonCount();<BR>       for (int i = 0; i < nCount; i++)<BR>       {<BR>              UINT nStyle = GetButtonStyle(i);<BR>              BOOL bWrap = (((i + 1) % nColumns) == 0);<BR>              if (bWrap)<BR>                     nStyle |= TBBS_WRAPPED;<BR>              else<BR>                     nStyle &= ~TBBS_WRAPPED;<BR>              SetButtonStyle(i, nStyle);<BR>       }<BR>       Invalidate();<BR>       GetParentFrame()->RecalcLayout();<BR>}</P><img src ="http://www.cppblog.com/TechLab/aggbug/757.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/TechLab/" target="_blank">TechLab</a> 2005-10-20 14:25 <a href="http://www.cppblog.com/TechLab/archive/2005/10/20/757.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>