重温sunxin的VC++深入详解笔记(一)

来源:互联网 发布:python cgi 编辑:程序博客网 时间:2024/06/07 19:35

第一章  Windows机制

重点记住六步窗口处理:

1)RegisterWndClass

2) CreateWndClass

3) ShowWindow

4) UpdateWindow

5) loop 

6) msg


第二章

主要要理解C++与C不同的地方

1)封装权限 类与Struct的区别

2)this 指针

3)重载 注意;同一作用域,参数类型/参数个数不同的函数才能重载

     以下两种情况不能重载

    (1)返回参数不同   void Output();

                                         int Output();

     (2)个数虽然不同,但存在参数默认赋值

                                         void Ouput(int a, int b = 0);

                                         void Output(int a);

4)  覆盖 必须是在父类和子类之间,函数一样

5)多态   注:指针的转换也会引起调用的对象不同,这是我唯一犯的一个错误。

      具体情况为:

               class animal; 有方法: void Output() {cout << "animal output"}

               class fish : public animal; 有同样方法: void Output() {cout << "fish output"}

               void fn(animal *pAn); 内容为 pAn->Output();

               在int main中 fish a;   fn(&a),问最后调用的是animal的Output方法还是fish的Output方法?

               这里虽然内存一样,但指针变了,所以应该调用animal的Output方法。——这里需切记。

               除非在animal的Output方法前加上virtual,这样才会调用fish的方法。

6)引用

7)CALLBACK 为__stdcall ,参数由右到左


第三章 MFC机制

1) WinMain在 vc98/MFC/src目录下的winmodule.cpp文件中,名字为_tWinMain,这里_tWinMain是个宏,实际就是WinMain

2)CMainFrame和CTestView都继承于CWnd类

    theApp全局对象,AfxGetApp()获得该指针

3)消息映射机制 头文件和CPP文件中都有包含


第十章 CDC

1) 线/椭圆/矩形  CFileDialog/CFontDialog/CColorDialog默认对话框

2) clw文件是classwizard生成的,出错可以删除,重新生成

3)图的切割

     三步走:

     (1)CBitmap bitmap; bitmap.LoadImage(IDB_BITMAP1)

      (2)CDC *pDC = new CDC;   CDC dc(&控件ID);   pDC->CreateCompatibleDC(&dc); pDC->SelectObject(&bitmap);

      (3)dc.BitBlt(NULL,0,0, x, y, pDC, 0,0,x,y,SRCCOPY);




原创粉丝点击