﻿<?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++博客-lanshengsheng-随笔分类-vc++深入详解</title><link>http://www.cppblog.com/lanshengsheng/category/19963.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 06 Nov 2012 08:31:39 GMT</lastBuildDate><pubDate>Tue, 06 Nov 2012 08:31:39 GMT</pubDate><ttl>60</ttl><item><title>创建文本插入符(MFC单文档),创建图形插入符(MFC单文档)</title><link>http://www.cppblog.com/lanshengsheng/archive/2012/11/06/194708.html</link><dc:creator>盛胜</dc:creator><author>盛胜</author><pubDate>Tue, 06 Nov 2012 03:05:00 GMT</pubDate><guid>http://www.cppblog.com/lanshengsheng/archive/2012/11/06/194708.html</guid><wfw:comment>http://www.cppblog.com/lanshengsheng/comments/194708.html</wfw:comment><comments>http://www.cppblog.com/lanshengsheng/archive/2012/11/06/194708.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lanshengsheng/comments/commentRss/194708.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lanshengsheng/services/trackbacks/194708.html</trackback:ping><description><![CDATA[<div><span style="white-space:pre">	<br /></span><div>创建文本插入符(MFC单文档)，在OnCreate(LPCREATESTRUCT lpCreateStruct)函数中创建</div>&nbsp; &nbsp; &nbsp; //下面调用的gettextmetrics成员函数是在CClienDC类中的</div><div><span style="white-space:pre">	</span>CClientDC dc(this);</div><div><span style="white-space:pre">	</span>//TEXTMETRIC结构体包含设备描述表中当前字体的度量信息</div><div><span style="white-space:pre">	</span>TEXTMETRIC tm;</div><div><span style="white-space:pre">	</span>//Gettextmetrics成员函数可以得到设备描述表中当前字体的度量信息</div><div><span style="white-space:pre">	</span>dc.GetTextMetrics(&amp;tm);</div><div><span style="white-space:pre">	</span>CreateSolidCaret(tm.tmAveCharWidth/1,tm.tmHeight);</div><div><span style="white-space:pre">	</span>ShowCaret();<br /><br />要在OnCreate()函数的头文件中添加<br />private:<div><span style="white-space:pre">		</span>CBitmap bitmap;<br /><br />再在OnCreate()函数中添加</div><div><span style="white-space:pre">	</span>bitmap.LoadBitmap(IDB_BITMAP1);</div><div><span style="white-space:pre">	</span>CreateCaret(&amp;bitmap);</div><div><span style="white-space:pre">	</span>ShowCaret();</div></div><img src ="http://www.cppblog.com/lanshengsheng/aggbug/194708.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lanshengsheng/" target="_blank">盛胜</a> 2012-11-06 11:05 <a href="http://www.cppblog.com/lanshengsheng/archive/2012/11/06/194708.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>获取窗口句柄</title><link>http://www.cppblog.com/lanshengsheng/archive/2012/10/16/193356.html</link><dc:creator>盛胜</dc:creator><author>盛胜</author><pubDate>Tue, 16 Oct 2012 02:02:00 GMT</pubDate><guid>http://www.cppblog.com/lanshengsheng/archive/2012/10/16/193356.html</guid><wfw:comment>http://www.cppblog.com/lanshengsheng/comments/193356.html</wfw:comment><comments>http://www.cppblog.com/lanshengsheng/archive/2012/10/16/193356.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lanshengsheng/comments/commentRss/193356.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lanshengsheng/services/trackbacks/193356.html</trackback:ping><description><![CDATA[<pre id="best-answer-content"  mb10"="" data-accusearea="aContent" style="margin-top: 0px; margin-bottom: 10px; padding: 0px; font-family: Arial; white-space: pre-wrap; word-wrap: break-word; zoom: 1; line-height: 22px; background-color: #fffcf6;">在对话框类的成员函数里用  HWND hwnd = GetSafeHwnd();  得到的hwnd就是句柄了<br /><pre id="best-answer-content"  mb10"="" data-accusearea="aContent" style="margin-top: 0px; margin-bottom: 10px; padding: 0px; font-family: Arial; white-space: pre-wrap; word-wrap: break-word; zoom: 1;">通过窗口标题获取窗口句柄 CWnd *pWnd = FindWindow(_T("#32770"), _T("QQ用户登录")); </pre><div></div></pre><img src ="http://www.cppblog.com/lanshengsheng/aggbug/193356.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lanshengsheng/" target="_blank">盛胜</a> 2012-10-16 10:02 <a href="http://www.cppblog.com/lanshengsheng/archive/2012/10/16/193356.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>设插入符CreateSolidCaret()</title><link>http://www.cppblog.com/lanshengsheng/archive/2012/10/08/192996.html</link><dc:creator>盛胜</dc:creator><author>盛胜</author><pubDate>Mon, 08 Oct 2012 06:38:00 GMT</pubDate><guid>http://www.cppblog.com/lanshengsheng/archive/2012/10/08/192996.html</guid><wfw:comment>http://www.cppblog.com/lanshengsheng/comments/192996.html</wfw:comment><comments>http://www.cppblog.com/lanshengsheng/archive/2012/10/08/192996.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lanshengsheng/comments/commentRss/192996.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lanshengsheng/services/trackbacks/192996.html</trackback:ping><description><![CDATA[<div>int CtestddView::OnCreate(LPCREATESTRUCT lpCreateStruct)</div><div>{</div><div><span style="white-space:pre">	</span>if (CView::OnCreate(lpCreateStruct) == -1)</div><div><span style="white-space:pre">		</span>return -1;<br />//插入符设置宽高</div><div><span style="white-space:pre">	</span>CreateSolidCaret(20,100);<br /><br />//显示插入符</div><div><span style="white-space:pre">	</span>ShowCaret();</div><div><span style="white-space:pre">	</span>// TODO: &nbsp;在此添加您专用的创建代码</div><div></div><div><span style="white-space:pre">	</span>return 0;</div><div>}</div><img src ="http://www.cppblog.com/lanshengsheng/aggbug/192996.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lanshengsheng/" target="_blank">盛胜</a> 2012-10-08 14:38 <a href="http://www.cppblog.com/lanshengsheng/archive/2012/10/08/192996.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MFC单文档中绘图扇形，连续线条。</title><link>http://www.cppblog.com/lanshengsheng/archive/2012/09/29/192420.html</link><dc:creator>盛胜</dc:creator><author>盛胜</author><pubDate>Sat, 29 Sep 2012 08:23:00 GMT</pubDate><guid>http://www.cppblog.com/lanshengsheng/archive/2012/09/29/192420.html</guid><wfw:comment>http://www.cppblog.com/lanshengsheng/comments/192420.html</wfw:comment><comments>http://www.cppblog.com/lanshengsheng/archive/2012/09/29/192420.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lanshengsheng/comments/commentRss/192420.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lanshengsheng/services/trackbacks/192420.html</trackback:ping><description><![CDATA[<div><br />在视图类中添加私有bool类型的m_bDraw,m_bDraw在视图类构造函数中初始化为FALSE.在OnLButtonDown和OnLButtonUp消息函数中分别设置为TRUE和FALSE。<br />在视图类添加私有CPoint类型m_ptOld,在OnLButtonDown消息函数中初始化这个变量m_ptOld=point;<br />void CTestView::OnMouseMove(UINT nFlags, CPoint point)&nbsp;</div><div>{</div><div><span style="white-space:pre">	</span>// TODO: Add your message handler code here and/or call default</div><div><span style="white-space:pre">	</span>//扇形</div><div><span style="white-space:pre">	</span>CClientDC dc(this);</div><div></div><div><span style="white-space:pre">	</span>//SetROP2设置绘图模式函数</div><div><span style="white-space:pre">	</span>//dc.SetROP2(R2_BLACK);</div><div><span style="white-space:pre">	</span>//dc.SetROP2(R2_MERGENOTPEN);</div><div><span style="white-space:pre">	</span>CPen pen(PS_SOLID,1,#ff0000);</div><div><span style="white-space:pre">	</span>CPen *pOldpen=dc.SelectObject(&amp;pen);</div><div><span style="white-space:pre">	</span>if(TRUE==m_bDraw)</div><div><span style="white-space:pre">	</span>{</div><div><span style="white-space:pre">		</span>dc.MoveTo(m_ptOrigin);</div><div><span style="white-space:pre">		</span>dc.LineTo(point);</div><div><span style="white-space:pre">		</span>dc.LineTo(m_ptOld);</div><div><span style="white-space:pre">		</span>m_ptOld=point;</div><div><span style="white-space:pre">	</span>}</div><div><span style="white-space:pre">	</span>dc.SelectObject(pOldpen);</div><div><span style="white-space:pre">	</span></div><div></div><div><span style="white-space:pre">	</span>//连续线条</div><div><span style="white-space:pre">	</span>/*</div><div><span style="white-space:pre">	</span>CClientDC dc(this);</div><div><span style="white-space:pre">	</span>CPen pen(PS_SOLID,3,#ff0000);</div><div><span style="white-space:pre">	</span>CPen *pOldPen=dc.SelectObject(&amp;pen);</div><div><span style="white-space:pre">	</span>if(TRUE==m_bDraw)</div><div><span style="white-space:pre">	</span>{</div><div><span style="white-space:pre">		</span>dc.MoveTo(m_ptOrigin);</div><div><span style="white-space:pre">		</span>dc.LineTo(point);</div><div><span style="white-space:pre">		</span>m_ptOrigin=point;</div><div><span style="white-space:pre">	</span>}</div><div><span style="white-space:pre">	</span>dc.SelectObject(pOldPen);</div><div><span style="white-space:pre">	</span></div><div><span style="white-space:pre">	</span>*/</div><div><span style="white-space:pre">	</span>CView::OnMouseMove(nFlags, point);</div><div>}</div><img src ="http://www.cppblog.com/lanshengsheng/aggbug/192420.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lanshengsheng/" target="_blank">盛胜</a> 2012-09-29 16:23 <a href="http://www.cppblog.com/lanshengsheng/archive/2012/09/29/192420.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>画刷CBrush</title><link>http://www.cppblog.com/lanshengsheng/archive/2012/09/29/192409.html</link><dc:creator>盛胜</dc:creator><author>盛胜</author><pubDate>Sat, 29 Sep 2012 06:15:00 GMT</pubDate><guid>http://www.cppblog.com/lanshengsheng/archive/2012/09/29/192409.html</guid><wfw:comment>http://www.cppblog.com/lanshengsheng/comments/192409.html</wfw:comment><comments>http://www.cppblog.com/lanshengsheng/archive/2012/09/29/192409.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lanshengsheng/comments/commentRss/192409.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lanshengsheng/services/trackbacks/192409.html</trackback:ping><description><![CDATA[<div>普通画刷<br />void CTestView::OnLButtonUp(UINT nFlags, CPoint point) <br /> {<span style="font-size: 12px;"><span style="white-space: pre; ">	<br /></span></span>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 12px;">CBrush brushRed(RGB (255,0,0));</span></div><div><span style="font-size: 12px;"><span style="white-space:pre">	</span>CBrush brushGreen(RGB (0,255,0));</span></div><div><span style="font-size: 12px;"><span style="white-space:pre">	</span>CBrush brushBlue(RGB (0,0,255));</span></div><div><span style="font-size: 12px;"><span style="white-space:pre">	</span>CClientDC dc(this);</span></div><div><span style="font-size: 12px;"><span style="white-space:pre">	</span>dc.FillRect(CRect(m_ptOrigin,point),&amp;brushGreen);</span></div><div><span style="font-size: 12px;"><br /></span></div><div><span style="font-size: 12px;"><br /></span></div><div><span style="font-size: 12px;"><br /></span></div><div><span style="font-size: 12px;"><span style="white-space:pre">	</span>CView::OnLButtonUp(nFlags, point);</span></div><div><span style="font-size: 12px;">}</span><br /><span style="font-size: 12px;">位图画刷<br /></span>void CTestView::OnLButtonUp(UINT nFlags, CPoint point)&nbsp;<br />{<span style="font-size: 12px; "><span style="white-space: pre; ">	</span></span>&nbsp;<br /><div><span style="white-space: pre; ">	</span>//创建位图对象</div><div><span style="white-space:pre">	</span>CBitmap bitmap;</div><div><span style="white-space:pre">	</span>//加载位图资源</div><div><span style="white-space:pre">	</span>bitmap.LoadBitmap(IDB_BITMAP1);</div><div><span style="white-space:pre">	</span>//创建位图画刷</div><div><span style="white-space:pre">	</span>CBrush brush(&amp;bitmap);</div><div><span style="white-space:pre">	</span>//创建并获得设备描述表</div><div><span style="white-space:pre">	</span>CClientDC dc(this);</div><div><span style="white-space:pre">	</span>//利用位图画刷填充鼠标拖拽过程中形成的矩形区域</div><div><span style="white-space:pre">	</span>dc.FillRect(CRect(m_ptOrigin,point),&amp;brush);</div><div></div><div><span style="white-space:pre">	</span>CView::OnLButtonUp(nFlags, point);</div><div>}<br />透明画刷<br />void CTestView::OnLButtonUp(UINT nFlags, CPoint point)&nbsp;<br />{&nbsp;<br /><div><span style="white-space:pre">	</span>//创建并获得设备描述表</div><div><span style="white-space:pre">	</span>CClientDC dc(this);</div><div><span style="white-space:pre">	</span>//创建一个空画刷;getstockobject的返回类型是HGDIOBJECT，需要进行强制类型转换</div><div><span style="white-space:pre">	</span>//GetStockObject函数可以获取一个画刷句柄，FromHandle函数可以将画刷句柄转换为画刷对象，绘图操作需要的是一个画刷对象</div><div><span style="white-space:pre">	</span>CBrush *pBrush=CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));</div><div><span style="white-space:pre">	</span>//将空画刷填入设备描述表ccwf</div><div><span style="white-space:pre">	</span>CBrush *pOldBrush=dc.SelectObject(pBrush);</div><div><span style="white-space:pre">	</span>//绘制一个矩形</div><div><span style="white-space:pre">	</span>dc.Rectangle(CRect(m_ptOrigin,point));</div><div><span style="white-space:pre">	</span>dc.SelectObject(pOldBrush);<br /><div><span style="white-space: pre; ">	</span>CView::OnLButtonUp(nFlags, point);</div><div>}</div></div></div></div><div style="font-family: Tahoma; font-size: 11px; "></div><img src ="http://www.cppblog.com/lanshengsheng/aggbug/192409.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lanshengsheng/" target="_blank">盛胜</a> 2012-09-29 14:15 <a href="http://www.cppblog.com/lanshengsheng/archive/2012/09/29/192409.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>画笔的设置</title><link>http://www.cppblog.com/lanshengsheng/archive/2012/09/29/192375.html</link><dc:creator>盛胜</dc:creator><author>盛胜</author><pubDate>Sat, 29 Sep 2012 02:06:00 GMT</pubDate><guid>http://www.cppblog.com/lanshengsheng/archive/2012/09/29/192375.html</guid><wfw:comment>http://www.cppblog.com/lanshengsheng/comments/192375.html</wfw:comment><comments>http://www.cppblog.com/lanshengsheng/archive/2012/09/29/192375.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lanshengsheng/comments/commentRss/192375.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lanshengsheng/services/trackbacks/192375.html</trackback:ping><description><![CDATA[<div><br />void CTestView::OnLButtonUp(UINT nFlags, CPoint point)&nbsp;</div><div>{</div><div></div><div></div><div><span style="white-space:pre">	</span>//CClientDC派生于CDC类，构造时自动调用GetDC函数。一旦定义了CClientDC的一个对象就不用再调用GetDC和ReleaseDC</div><div><span style="white-space:pre">	</span>//CClientDC dc(this);</div><div><span style="white-space:pre">	</span>//pen里面第一个参数：线的类型，第二个参数：线的宽度；第三个参数：线的颜色（红，绿，蓝）</div><div><span style="white-space:pre">	</span>CPen pen(PS_DASH,1,RGB (255,0,0));</div><div><span style="white-space:pre">	</span>CClientDC dc(this);</div><div><span style="white-space:pre">	</span>CPen* pOldPen=dc.SelectObject(&amp;pen);</div><div><span style="white-space:pre">	</span>dc.MoveTo(m_ptOrigin);</div><div><span style="white-space:pre">	</span>dc.LineTo(point);</div><div><span style="white-space:pre">	</span>dc.SelectObject(pOldPen);</div><div><span style="white-space:pre">	</span>CView::OnLButtonUp(nFlags, point);</div><div>}</div><div></div><img src ="http://www.cppblog.com/lanshengsheng/aggbug/192375.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lanshengsheng/" target="_blank">盛胜</a> 2012-09-29 10:06 <a href="http://www.cppblog.com/lanshengsheng/archive/2012/09/29/192375.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>简单绘图</title><link>http://www.cppblog.com/lanshengsheng/archive/2012/09/28/192276.html</link><dc:creator>盛胜</dc:creator><author>盛胜</author><pubDate>Fri, 28 Sep 2012 08:08:00 GMT</pubDate><guid>http://www.cppblog.com/lanshengsheng/archive/2012/09/28/192276.html</guid><wfw:comment>http://www.cppblog.com/lanshengsheng/comments/192276.html</wfw:comment><comments>http://www.cppblog.com/lanshengsheng/archive/2012/09/28/192276.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lanshengsheng/comments/commentRss/192276.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lanshengsheng/services/trackbacks/192276.html</trackback:ping><description><![CDATA[建立工程文件<br />选择单文档其他全部默认<br /><img src="http://www.cppblog.com/images/cppblog_com/lanshengsheng/新建工程.png" width="741" height="479" alt="" /><br /><br />添加LButtonDown和LButtonUp的消息响应函数<br /><br />点击上边的 &nbsp;查看（v）-&gt;建立类向导<br /><img src="http://www.cppblog.com/images/cppblog_com/lanshengsheng/lbuttondown消息函数的添加.png" width="723" height="415" alt="" /><br />这里已经点击过Add Funtion ，点击后工程自动添加消息函数。点击edit code可以进行代码编辑。<br /><div>void CTestView::OnLButtonDown(UINT nFlags, CPoint point)&nbsp;</div><div>{</div><div><span style="white-space:pre">	</span>// TODO: Add your message handler code here and/or call default</div><div><span style="white-space:pre">	</span>m_ptOrigin=point;</div><div><span style="white-space:pre">	</span></div><div><span style="white-space:pre">	</span>//MessageBox("view Clicked!");</div><div><span style="white-space:pre">	</span>CView::OnLButtonDown(nFlags, point);</div><div>}<br />同理OnLButtonUp消息函数也一样添加，代码为下边：<br /><div></div><div>void CTestView::OnLButtonUp(UINT nFlags, CPoint point)&nbsp;</div><div>{</div><div><span style="white-space:pre">	</span>//1</div><div><span style="white-space:pre">	</span>/*</div><div><span style="white-space:pre">	</span>// TODO: Add your message handler code here and/or call default</div><div><span style="white-space:pre">	</span>//首先获取窗口的设备描述表</div><div><span style="white-space:pre">	</span>HDC hdc;</div><div><span style="white-space:pre">	</span>//m_hWnd是CWnd的一个成员变量用来保存窗口句柄，而CTestView派生于CWnd类。GetDC全局函数获取得当前窗口的设备描述表</div><div><span style="white-space:pre">	</span>hdc = ::GetDC(m_hWnd);</div><div><span style="white-space:pre">	</span>//移动到线条的起点</div><div><span style="white-space:pre">	</span>MoveToEx(hdc,m_ptOrigin.x,m_ptOrigin.y,NULL);</div><div><span style="white-space:pre">	</span>//画线</div><div><span style="white-space:pre">	</span>LineTo(hdc,point.x,point.y);</div><div><span style="white-space:pre">	</span>//释放设备描述表</div><div><span style="white-space:pre">	</span>::ReleaseDC(m_hWnd,hdc);</div><div><span style="white-space:pre">	</span>*/</div><div><span style="white-space:pre">	</span>//CWnd类提供了成员函数GetDC和ReleaseDC，先利用Platform SDK函数实现画线功能时，这两个函数前面都加::表示全局</div><div><span style="white-space:pre">	</span>//函数</div><div></div><div><span style="white-space:pre">	</span>//2</div><div><span style="white-space:pre">	</span>/*</div><div><span style="white-space:pre">	</span>//MFC封装了CDC类（一个设备描述表）</div><div><span style="white-space:pre">	</span>CDC* pDC=GetDC();</div><div><span style="white-space:pre">	</span>pDC-&gt;MoveTo(m_ptOrigin);</div><div><span style="white-space:pre">	</span>pDC-&gt;LineTo(point);</div><div><span style="white-space:pre">	</span>ReleaseDC(pDC);</div><div><span style="white-space:pre">	</span>*/</div><div><span style="white-space:pre">	</span></div><div><span style="white-space:pre">	</span>//3</div><div><span style="white-space:pre">	</span>/*</div><div><span style="white-space:pre">	</span>//CClientDC派生于CDC类，构造时自动调用GetDC函数。一旦定义了CClientDC的一个对象就不用再调用GetDC和ReleaseDC</div><div><span style="white-space:pre">	</span>//CClientDC dc(this);</div><div><span style="white-space:pre">	</span>CClientDC dc(GetParent());</div><div><span style="white-space:pre">	</span>dc.MoveTo(m_ptOrigin);</div><div><span style="white-space:pre">	</span>dc.LineTo(point);</div><div><span style="white-space:pre">	</span>*/</div><div></div><div><span style="white-space:pre">	</span>//4<br />&nbsp; &nbsp; &nbsp; &nbsp; //CwindowDC的优势：对象可以访问整个窗口区域</div><div><span style="white-space:pre">	</span>//CWindowDC dc(this);</div><div><span style="white-space:pre">	</span>CWindowDC dc(GetParent());</div><div><span style="white-space:pre">	</span>dc.MoveTo(m_ptOrigin);</div><div><span style="white-space:pre">	</span>dc.LineTo(point);</div><div></div><div></div><div><span style="white-space:pre">	</span>CView::OnLButtonUp(nFlags, point);</div><div>}</div><div></div><div></div></div><img src ="http://www.cppblog.com/lanshengsheng/aggbug/192276.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lanshengsheng/" target="_blank">盛胜</a> 2012-09-28 16:08 <a href="http://www.cppblog.com/lanshengsheng/archive/2012/09/28/192276.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>错误：无法找到sprintf标识符</title><link>http://www.cppblog.com/lanshengsheng/archive/2012/09/27/192169.html</link><dc:creator>盛胜</dc:creator><author>盛胜</author><pubDate>Thu, 27 Sep 2012 08:09:00 GMT</pubDate><guid>http://www.cppblog.com/lanshengsheng/archive/2012/09/27/192169.html</guid><wfw:comment>http://www.cppblog.com/lanshengsheng/comments/192169.html</wfw:comment><comments>http://www.cppblog.com/lanshengsheng/archive/2012/09/27/192169.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lanshengsheng/comments/commentRss/192169.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lanshengsheng/services/trackbacks/192169.html</trackback:ping><description><![CDATA[这个错误首先要在当前文档头文件添加#include "stdio.h"<br />尝试编译如果不行注意添加的stdio.h要在原来的XXXX.h的下面。<br />如果使用的是vs2008要把工程的属性从Unicode改成多字符集。<img src ="http://www.cppblog.com/lanshengsheng/aggbug/192169.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lanshengsheng/" target="_blank">盛胜</a> 2012-09-27 16:09 <a href="http://www.cppblog.com/lanshengsheng/archive/2012/09/27/192169.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>构造函数</title><link>http://www.cppblog.com/lanshengsheng/archive/2012/09/24/191796.html</link><dc:creator>盛胜</dc:creator><author>盛胜</author><pubDate>Mon, 24 Sep 2012 02:47:00 GMT</pubDate><guid>http://www.cppblog.com/lanshengsheng/archive/2012/09/24/191796.html</guid><wfw:comment>http://www.cppblog.com/lanshengsheng/comments/191796.html</wfw:comment><comments>http://www.cppblog.com/lanshengsheng/archive/2012/09/24/191796.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lanshengsheng/comments/commentRss/191796.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lanshengsheng/services/trackbacks/191796.html</trackback:ping><description><![CDATA[#include&lt;iostream.h&gt;<br />class point<br />{<br />&nbsp; &nbsp;public:<br />&nbsp; &nbsp; &nbsp; int x;<br />&nbsp; &nbsp; &nbsp; int y;<br />&nbsp; &nbsp;point()<br />&nbsp; &nbsp;{<br />&nbsp; &nbsp; &nbsp; x=0;<br />&nbsp; &nbsp; &nbsp; y=0;<br />&nbsp; &nbsp;}<br />&nbsp; &nbsp;point(int a,int b)<br />&nbsp; &nbsp;{<br />&nbsp; &nbsp; &nbsp; x=a;<br />&nbsp; &nbsp; &nbsp; y=b;<br />&nbsp; &nbsp;}<br />&nbsp; &nbsp;void output()<br />&nbsp; &nbsp;{<br />&nbsp; &nbsp; &nbsp; cout&lt;&lt;x&lt;&lt;endl&lt;&lt;y&lt;&lt;endl;<br />&nbsp; &nbsp;}<br />&nbsp; &nbsp;void input(int x,int y)<br />&nbsp; &nbsp;{<br />&nbsp; &nbsp; &nbsp; this-&gt;x=x;<br />&nbsp; &nbsp; &nbsp; this-&gt;y=y;<br />&nbsp; &nbsp;}<br /><br />}<br /><br />void main()<br />{<br />&nbsp; &nbsp;point pt(5,5);<br />&nbsp; &nbsp;pt.input(10,10);<br />&nbsp; &nbsp;pt.output();<br /><br />}<br />输出结果为10&nbsp;<br />10<br /><br />如果把this指针去掉则为5<br />5<br /><br />在使用构造函数时注意是否需要释放内存。～构造函数名（）利用析构函数解决内存泄漏问题。<br /><img src ="http://www.cppblog.com/lanshengsheng/aggbug/191796.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lanshengsheng/" target="_blank">盛胜</a> 2012-09-24 10:47 <a href="http://www.cppblog.com/lanshengsheng/archive/2012/09/24/191796.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>error C2664: “MessageBoxW”: 不能将参数 2 从“char [20]”转换为“LPCWSTR”</title><link>http://www.cppblog.com/lanshengsheng/archive/2012/09/21/191483.html</link><dc:creator>盛胜</dc:creator><author>盛胜</author><pubDate>Fri, 21 Sep 2012 07:41:00 GMT</pubDate><guid>http://www.cppblog.com/lanshengsheng/archive/2012/09/21/191483.html</guid><wfw:comment>http://www.cppblog.com/lanshengsheng/comments/191483.html</wfw:comment><comments>http://www.cppblog.com/lanshengsheng/archive/2012/09/21/191483.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/lanshengsheng/comments/commentRss/191483.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/lanshengsheng/services/trackbacks/191483.html</trackback:ping><description><![CDATA[<div></div><div><span style="font-size: 12px; "><br /></span></div><div><span style="font-size: 12px;">MessageBox(hwnd,szChar,"char",0);</span></div><div><span style="font-size: 12px;"><br /></span></div><div><span style="font-size: 12px;">MessageBox 在2008中定义为 MessageBoxW W指的是宽字节(也叫UNICODE)，有3种方法可解决&nbsp;</span></div><div><span style="font-size: 12px;">&#9312;用函数MessageBoxA&nbsp;</span></div><div><span style="font-size: 12px;">&#9313;在内容前加上TEXT（对变量无效），如MessageBox(hwnd,szChar,TEXT("char"),0);</span></div><div><span style="font-size: 12px;"><br /></span></div><div><span style="font-size: 12px;">&#9314;在项目属性-&gt;常规中，把Uicode改成多字符段。</span></div><div><span style="font-size: 12px;"><br /></span></div><div><span style="font-size: 12px;">PS:在2008中，很多函数的返回值都是宽字节的，所以不一定要用MessageBoxA&nbsp;</span></div><div><span style="font-size: 12px;">在MSDN上可以查到用宽字节的函数和同样功能普通函数的名称。&nbsp;</span></div><div><span style="font-size: 12px;">在6.0中没用宽字节</span></div><img src ="http://www.cppblog.com/lanshengsheng/aggbug/191483.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/lanshengsheng/" target="_blank">盛胜</a> 2012-09-21 15:41 <a href="http://www.cppblog.com/lanshengsheng/archive/2012/09/21/191483.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>