﻿<?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>IT博客-Every Day's Gain-随笔分类-Windows App Programing</title><link>http://www.cnitblog.com/Larry.Zhao/category/337.html</link><description>Larry.Zhao's Coding Diary</description><language>zh-cn</language><lastBuildDate>Fri, 07 Oct 2011 17:59:53 GMT</lastBuildDate><pubDate>Fri, 07 Oct 2011 17:59:53 GMT</pubDate><ttl>60</ttl><item><title>Windows程序设计课程笔记一--回顾C++</title><link>http://www.cnitblog.com/Larry.Zhao/archive/2005/09/16/2682.html</link><dc:creator>Larry.Zhao's Coding Diary</dc:creator><author>Larry.Zhao's Coding Diary</author><pubDate>Fri, 16 Sep 2005 00:40:00 GMT</pubDate><guid>http://www.cnitblog.com/Larry.Zhao/archive/2005/09/16/2682.html</guid><wfw:comment>http://www.cnitblog.com/Larry.Zhao/comments/2682.html</wfw:comment><comments>http://www.cnitblog.com/Larry.Zhao/archive/2005/09/16/2682.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Larry.Zhao/comments/commentRss/2682.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Larry.Zhao/services/trackbacks/2682.html</trackback:ping><description><![CDATA[<UL>
<LI><FONT color=#ff1493>面向对象的三大特征(以重要性排序)：</FONT>封装、继承、多态。 
<LI><FONT color=#ff1493>一个对象的构造过程：</FONT>class A、class C、class B : public A{private: C c;}这样的三个类，当作如下声明：B b时，构造函数调用的顺序依次是: A C B，先构造class C这样可以保证在class B中对成员数据c的操作是安全的。 
<LI><FONT color=#ff1493>构造函数：</FONT>有class A，A a, 有函数F(A a)，当调用F(a)时由于是船传值调用，在这次函数调用时会调用A的拷贝构造函数。 
<LI><FONT color=#ff1493>析构函数什么时候应该为虚函数：</FONT>有class&nbsp;A; class B : public A; 有各自的构造、析构函数，A* pA = new B; delete pA;&nbsp;构造函数和析构函数调用的顺序为：A(), B(), ~A()。这样就没有析构B。所以把析构函数写为虚函数virtual&nbsp;~A()，就会得到我们想要的结果：A(), B(), ~B(),&nbsp;~A()。
<LI><FONT color=#ff1493>多态性的实现原理：</FONT>虚函数表机制。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</LI></UL><img src ="http://www.cnitblog.com/Larry.Zhao/aggbug/2682.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Larry.Zhao/" target="_blank">Larry.Zhao's Coding Diary</a> 2005-09-16 08:40 <a href="http://www.cnitblog.com/Larry.Zhao/archive/2005/09/16/2682.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>获得窗体的实例句柄</title><link>http://www.cnitblog.com/Larry.Zhao/archive/2005/07/18/1058.html</link><dc:creator>Larry.Zhao's Coding Diary</dc:creator><author>Larry.Zhao's Coding Diary</author><pubDate>Mon, 18 Jul 2005 15:57:00 GMT</pubDate><guid>http://www.cnitblog.com/Larry.Zhao/archive/2005/07/18/1058.html</guid><wfw:comment>http://www.cnitblog.com/Larry.Zhao/comments/1058.html</wfw:comment><comments>http://www.cnitblog.com/Larry.Zhao/archive/2005/07/18/1058.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Larry.Zhao/comments/commentRss/1058.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Larry.Zhao/services/trackbacks/1058.html</trackback:ping><description><![CDATA[共有三种方式：<BR>1、声明一个全局的hInst变量，在WinMain里面hInst = hInstance<BR>2、((LPCREATESTRUCT)lParam)-&gt;hInstance，通过CREATESTRUCT结构获得<BR>3、hInst = GetWindowLong (hwnd, GWL_HINSTANCE);<BR><BR>ps: CREATESTRUCT结构包含了窗体创建初始化时的各种信息：<BR><BR><FONT color=#ff1493>typedef struct tagCREATESTRUCT {&nbsp;<BR>&nbsp;&nbsp;&nbsp; LPVOID&nbsp;&nbsp;&nbsp; lpCreateParams; <BR>&nbsp;&nbsp;&nbsp; HINSTANCE hInstance; <BR>&nbsp;&nbsp;&nbsp; HMENU&nbsp;&nbsp;&nbsp;&nbsp; hMenu; <BR>&nbsp;&nbsp;&nbsp; HWND&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hwndParent; <BR>&nbsp;&nbsp;&nbsp; int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cy; <BR>&nbsp;&nbsp;&nbsp; int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cx; <BR>&nbsp;&nbsp;&nbsp; int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; y; <BR>&nbsp;&nbsp;&nbsp; int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x; <BR>&nbsp;&nbsp;&nbsp; LONG&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; style; <BR>&nbsp;&nbsp;&nbsp; LPCTSTR&nbsp;&nbsp; lpszName; <BR>&nbsp;&nbsp;&nbsp; LPCTSTR&nbsp;&nbsp; lpszClass; <BR>&nbsp;&nbsp;&nbsp; DWORD&nbsp;&nbsp;&nbsp;&nbsp; dwExStyle; <BR>} CREATESTRUCT;</FONT> <BR><img src ="http://www.cnitblog.com/Larry.Zhao/aggbug/1058.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Larry.Zhao/" target="_blank">Larry.Zhao's Coding Diary</a> 2005-07-18 23:57 <a href="http://www.cnitblog.com/Larry.Zhao/archive/2005/07/18/1058.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>InvalidateRect和UpdateWindow的区别</title><link>http://www.cnitblog.com/Larry.Zhao/archive/2005/07/17/1037.html</link><dc:creator>Larry.Zhao's Coding Diary</dc:creator><author>Larry.Zhao's Coding Diary</author><pubDate>Sun, 17 Jul 2005 06:57:00 GMT</pubDate><guid>http://www.cnitblog.com/Larry.Zhao/archive/2005/07/17/1037.html</guid><wfw:comment>http://www.cnitblog.com/Larry.Zhao/comments/1037.html</wfw:comment><comments>http://www.cnitblog.com/Larry.Zhao/archive/2005/07/17/1037.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Larry.Zhao/comments/commentRss/1037.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Larry.Zhao/services/trackbacks/1037.html</trackback:ping><description><![CDATA[InvalidateRect是将客户区标记为无效，并产生WM_PAINT消息，Windows会将WM_PAINT消息放入队列，等待窗口过程的处理，然后操作系统将WM_PAINT当作是低优先级消息，如果后面有其他的动作要处理，则可能会出现空白的区域需要等待一段时间才被刷新。<BR><BR>UpdateWindow则将导致操作系统<FONT color=#ff1493>立即用WM_PAINT调用窗口过程，而不进入队列，使窗口得到立即的刷新。</FONT>窗口过程完成刷新后立即退出，Windows将控制返回给UpdateWindow之后的语句。<img src ="http://www.cnitblog.com/Larry.Zhao/aggbug/1037.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Larry.Zhao/" target="_blank">Larry.Zhao's Coding Diary</a> 2005-07-17 14:57 <a href="http://www.cnitblog.com/Larry.Zhao/archive/2005/07/17/1037.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>内存设备描述表</title><link>http://www.cnitblog.com/Larry.Zhao/archive/2005/07/17/1036.html</link><dc:creator>Larry.Zhao's Coding Diary</dc:creator><author>Larry.Zhao's Coding Diary</author><pubDate>Sun, 17 Jul 2005 06:22:00 GMT</pubDate><guid>http://www.cnitblog.com/Larry.Zhao/archive/2005/07/17/1036.html</guid><wfw:comment>http://www.cnitblog.com/Larry.Zhao/comments/1036.html</wfw:comment><comments>http://www.cnitblog.com/Larry.Zhao/archive/2005/07/17/1036.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Larry.Zhao/comments/commentRss/1036.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Larry.Zhao/services/trackbacks/1036.html</trackback:ping><description><![CDATA[<P>把写好的类添加到了DrawPad里面, 还是在被滚动条郁闷. 昨天在实验一下在一张已有位图上画线, 也画不出来, 今天花了15分钟从头写了一个小程序测试一下, 终于发现了, 用于接受位图对象的内存设备描述表hdcMem, 每次使用之后必须要释放, 否则就画不上去, 也就是说下面的两句语句应该也要成对出现:<BR><BR>hdcMem = CreateCompatible (hdc);<BR><BR>DeleteDC(hdcMem);<BR></P><img src ="http://www.cnitblog.com/Larry.Zhao/aggbug/1036.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Larry.Zhao/" target="_blank">Larry.Zhao's Coding Diary</a> 2005-07-17 14:22 <a href="http://www.cnitblog.com/Larry.Zhao/archive/2005/07/17/1036.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>无题</title><link>http://www.cnitblog.com/Larry.Zhao/archive/2005/07/14/941.html</link><dc:creator>Larry.Zhao's Coding Diary</dc:creator><author>Larry.Zhao's Coding Diary</author><pubDate>Wed, 13 Jul 2005 16:25:00 GMT</pubDate><guid>http://www.cnitblog.com/Larry.Zhao/archive/2005/07/14/941.html</guid><wfw:comment>http://www.cnitblog.com/Larry.Zhao/comments/941.html</wfw:comment><comments>http://www.cnitblog.com/Larry.Zhao/archive/2005/07/14/941.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Larry.Zhao/comments/commentRss/941.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Larry.Zhao/services/trackbacks/941.html</trackback:ping><description><![CDATA[今天成果不大，主要还是在完善位图类，并且做滚动条。为滚动条我又写了两个成员函数，用来移动SetDIBitsToDevice里面的坐标标记的，一开始都很顺利，我还很高兴呢，能这么简单的完成一项，可是到后面不对了。每点一下滚动条的箭头，我移动一行像素，可是后来发现一次移动超过一行像素就不对了，在滚动出来的图像上的部分图像缩小了，x和y方向上都缩小了，我仅仅写了x方向上的滚动，真是百思不得其解，一点头绪也没有。放到明天解决吧，不管怎样，明天我要在主要的工程上工作了，这个类已经完善enough了，可以移过去了。<img src ="http://www.cnitblog.com/Larry.Zhao/aggbug/941.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Larry.Zhao/" target="_blank">Larry.Zhao's Coding Diary</a> 2005-07-14 00:25 <a href="http://www.cnitblog.com/Larry.Zhao/archive/2005/07/14/941.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>窗体消息处理函数的局部变量</title><link>http://www.cnitblog.com/Larry.Zhao/archive/2005/07/13/923.html</link><dc:creator>Larry.Zhao's Coding Diary</dc:creator><author>Larry.Zhao's Coding Diary</author><pubDate>Wed, 13 Jul 2005 02:28:00 GMT</pubDate><guid>http://www.cnitblog.com/Larry.Zhao/archive/2005/07/13/923.html</guid><wfw:comment>http://www.cnitblog.com/Larry.Zhao/comments/923.html</wfw:comment><comments>http://www.cnitblog.com/Larry.Zhao/archive/2005/07/13/923.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Larry.Zhao/comments/commentRss/923.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Larry.Zhao/services/trackbacks/923.html</trackback:ping><description><![CDATA[总是不注意细节!终于把位图显示出来了,昨天困扰了我1个多小时的问题,今天用了20分钟终于查出来了,还是细节的问题.<BR>测试我写的类,在窗体消息处理函数WndProc里面定义:<BR>bool flag＝false;<BR>CMyBitMapFile&nbsp;&nbsp;&nbsp;file1;<BR>然后响应加速键弹出通用对话框选择要打开的文件，然后把flag=true,再调用 InvalidRect来呼叫WM_PAINT，然后响应PAINT里面if(flag){//显示位图}，一开始什么反应都没有，我广设MessagBox发现没有进入if(flag)块，这个就让我想了很长时间，最后才想到，每发一次消息就调用一次WndProc，InvalidRect呼叫了WM_PAINT后，flag又被设置成false了，改正之后，又发现我类里的数据成员的指针变成NULL了，一开始我还觉得很奇怪，还好有了flag的警示，很快就想到了我的file1也是局部变量．<BR>唉，当时看书的时候就很奇怪WndProc里很多变量都声明成static，不得其解，现在教训让我明白了这个道理．<img src ="http://www.cnitblog.com/Larry.Zhao/aggbug/923.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Larry.Zhao/" target="_blank">Larry.Zhao's Coding Diary</a> 2005-07-13 10:28 <a href="http://www.cnitblog.com/Larry.Zhao/archive/2005/07/13/923.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>注意指针运算</title><link>http://www.cnitblog.com/Larry.Zhao/archive/2005/07/13/900.html</link><dc:creator>Larry.Zhao's Coding Diary</dc:creator><author>Larry.Zhao's Coding Diary</author><pubDate>Tue, 12 Jul 2005 16:07:00 GMT</pubDate><guid>http://www.cnitblog.com/Larry.Zhao/archive/2005/07/13/900.html</guid><wfw:comment>http://www.cnitblog.com/Larry.Zhao/comments/900.html</wfw:comment><comments>http://www.cnitblog.com/Larry.Zhao/archive/2005/07/13/900.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/Larry.Zhao/comments/commentRss/900.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/Larry.Zhao/services/trackbacks/900.html</trackback:ping><description><![CDATA[<DIV class=postbody>今天这个问题困扰了我很久。取一个位图函数头，书上的方法是：<BR>PBYTE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pFile;<BR>BITMAPFILEHEADER *&nbsp;&nbsp;&nbsp; pmbfh;<BR>BITMAPV5HEADER&nbsp;&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp; pmbih;<BR>pFile=malloc(dwFileSize);<BR>ReadFile(hFile, pFile,.....);<BR>pmbfh=(BITMAPFILEHEADER *)pFile;<BR>pmbih=(BITMAPV5HEADER&nbsp; *)(pFile&nbsp; + sizeof(BITMAPFILEHEADER));<BR><BR>我写类的时候为了方便就直接往文件头里面读：<BR>pmbfh=(BITMAPFILEHEADER *&nbsp;)malloc(dwFileSize);<BR>ReadFile(hFile, pmbfh,.....);<BR>pmbih=(BITMAPV5HEADER&nbsp; *)(pmbfh&nbsp; + sizeof(BITMAPFILEHEADER));<BR><BR><BR>读数据一切正常，可是在从pmbih结构体里读取位图信息的时候报错，我最后没有办法，把读出的数据用二进制显示来看哪里的问题。最终问题是出在这里：<FONT color=#ff1493>pmbih=(BITMAPV5HEADER&nbsp; *)(pmbfh&nbsp; + sizeof(BITMAPFILEHEADER));</FONT><BR>pmbfh是位图文件头类型的指针，加上一个整数，按照指针运算，会依照自己指向类型的大小移动，而sizeof返回的是后面位图文件头结构体的字节单位大小，所以移动的偏移量不对了。而pFile本身就是字节型的指针，所以是正确的。以后要注意指针运算。 </DIV><img src ="http://www.cnitblog.com/Larry.Zhao/aggbug/900.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/Larry.Zhao/" target="_blank">Larry.Zhao's Coding Diary</a> 2005-07-13 00:07 <a href="http://www.cnitblog.com/Larry.Zhao/archive/2005/07/13/900.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>