面向对象和MFC

面向对象程序设计实验-使用MFC进行可视化编程 一、实验目的及要求 了解在集成开发环境下程序的编辑、编译、连接、运行调试; 二、实验设备平台 实验设备:计算机; 平台:Windows 2000操作系统,Visual C++ 6.0或Microsoft Visual Studio 2005/2008/2010/2012/2013。 三、实验内容步骤 1.用MFC的向导创建编辑框,在编辑框中实现算术“加”、“减”、“乘”及“除”的运算,界面如图13-1所示。 部分代码如下: void CMFCApplication2Dlg::OnClicke 阅读详情

I joined a company last year where most programmers use C as their primary programming language. After some communication with them, I find that it is really very different between C and C++, although it is a well-known fact.As we know, C++ is object-oriented while C is process-oriented.But does we really know what is object-oriented? Can we design and program from the object-oriented perspective? And did we take advantage of the three most important attributes of C++?

Normally, do we keep the object-oriented in mind? It doesn't mean that we just use the class.In general, we develop a program to handle some stuff,for example,calculate.If you design that in a object-oriented manner, you may consider that you produce "a person" who can calculate. That "person" can also save the result for you if you want and you can update him when you want to do more complex calculation. You can only see that person and retrieve the result, but you can't see the details about the process.That's encapsulation.
You can produce another person who can be born with the first guy's ability. That's inheritance. Besides, you can let the different people inherited from the original guy behave differently while you all use them to add in fact. That's polymorphism. On the other hand, you produce a abacus in the process-oriented way.You use the beads on the abacus each time you want to calculate.When you finish calculating, this process ends and you have to put back the beads. It is nearly the same as one C function does.

In my first one or two years when I start to learn to program with C++, I used the wizard to produce a frame, and added functions to it.Although I used the class, what I do was to add as many functions as I can. Its direct result was that the code was hard to be updated and it looked disordered at last.

Now, I begin to program after designing.There are many questions to answer first.What is the program intended to do? How about the environment? How about the potential update appeal?How to abstract the solution in result of several objects? Are those objects' responsibilities clearly? How is the relationship between them? Are the details encapsulated well? And so on. It's also very important to have deep knowledge of design patterns.

MFC is a good example of using C++ capabilities to encapsulate the Win32 API, though it is not perfect. MFC shortens development time indeed. But I think some points should be noted ,otherwise we will make some mistakes when we are not familiar with the MFC's mechanism. The MFC makes use of the encapsulation that it encapsulate the win32 API, so the MFC functions often have one parameter less than the win32 functions. A MFC class often has a member variable which is corresponding to the Windows structures.For example, MFC supplies class CWnd to encapsulate the HWND handle of a window. The CWnd object is a C++ window object, distinct from the HWND that represents a Windows window but containing it. You must make it clear that closing the window doesn't mean that the object doesn't exist either.

And The MFC also supplies classes that encapsulate Windows common controls. You use a class like that in two steps:call the constructor and then call the member function Create to create the control and attach it to that object.So you can't use it if you only construct the object. The window's functions and structures are in charge of the real operation. It's unusable to only have a C++ object without evaluation of its member variable.

Although the wizard can help us set up a frame quickly, it's still very important to know the code that is automatically created for us and the responsibility and the relationship of the classes generated, such as, the InitInstance function of the class app which create the dlg or combine the view and document class. Once, I downloaded an example of splitter view. It creates two objects for the same view object. One is created by CreateView, the other is created by new. Although it has no problems at first, it can't add content to the view when you want to add something.

Well, there are many virtual functions in the MFC classes. If you want to take advantage of MFC at most, it's very important to know the exact time when those functions are called. I have modified a program which saving and loading its content hasn't used serialization. As a result, some behaviors are a little different from the normal program, for example, there is no prompt when closing the program. I overrode some virtual functions,such as OnSaveDocument, DoFileSave. Finally, it has the same behaviors.

c++图形界面开发中,QtMFC谁更胜一筹? 在C++语言主导下,有MFCQT俩大平台,很很多读者对于这俩大平台不是很了解,不知道这俩大平台到底需要学习哪一种,有何优势?就这个问题我将我收集的各个观点总结为以下几点: 一、QT 跨平台C++图形用户界面应用程序开发框架。它既可以开发GUI程序,也可用于开发非GUI程序,比如控制台工具服务器。Qt是面向对象的框架,使用特殊的代码生成扩展(称为元对象编译器(Meta Object Compiler, moc))以及一些宏,Qt很容易扩展,并且允许真正地组件编程。其优势如下: 1. 跨平台,可在Wi 阅读详情

相关推荐

Qt vs MFC (QtMFC的战争)

在网上看到的,拿来大家一起讨论下。蓝字均为转载 我曾经使用过QTMFC来开发过软件,我想大家分享我使用他们时所体会的不同之处。 我并非一个职业作家,这篇文章可能看起来不如专业的杂志网站上的那么条理清晰。但是,我在这里是用我自己的语言来表达我自己的经验,希望能你分享。英语比不是我的母语,所以可能会有一些用词古怪,词句错误之处,请发信给我,我可以改正他们。

YuleBall的地盘 957

MFC面向对象设计

MFC面向对象设计,教你如何利用MFC进行面向对象的程序设计

QtMFC的比较

MFC(微软基础类库)是专门为windows设计的一个用于开发图形用户界面的类库。MFC或多或少使用了面向对象的方法包装了Win32的API,正因如此,这些API有时是C++,有时是C,甚至是CC++的混合体。 Qt这个C++的图形库由Trolltech在1994年左右开发。它可以运行在Windows,Mac OS X, Unix,还有像Sharp Zaurus这类嵌入式系统中。Qt是

hanyujianke的专栏 1833

VC++,包括面向过程面向对象mfc等的基础知识

vc++,包括面向过程面向对象mfc等的基础知识C++语言基础用MFC编写Windows程序消息输入

MFC面向对象程序设计

面向对象程序设计》实践任务书 一、基本要求 (1)要求利用面向对象的方法以及c++编程语言来完成系统的设计; (2)要求在设计的过程中,建立清晰的类层次; (3)自行设计文件保存数据,不能使用数据库系统; (4)用VC++6.0及MFC开发系统; (5)设计基于MFC的图形交互界面; (6)程序要自己完成,不可抄袭。 二、评分 评分依据:正确性、设计合理性、认真程度、实现的功能多少等。 (1)正确性——占课程设计满分的45% 要求:所谓“程序正确”,指的是在各层次上正确,经得起检测,对合法的所有数据,要能

程序设计 920

MFC C++ 中面向对象的多线程实现

参加了交通运输学院的一个交通科技大赛,需要硬件沟通,当然也不是什么好高端的玩意儿,就是一个名为sick的一个德国产的激光扫描仪的使用,叫什么LMS-511;也就是基于TCP/IP通讯的罢了;主要是通过扫描仪发回来的数据把模型重新绘制出来;当然使用到了OpenGL来完成绘制的部分,不过个人觉得OpenGL本来就博大精深,自己皮毛都没有学到,就不在这里说啥子了;这里我们主要讨论怎么在MFC中通过面向

GookerLee的专栏 1104

面向对象程序设计课程设计——MFC实现同学通讯录管理系统

先上效果图; 1.设计目的 同学通讯录管理程序是为了更好地管理学生信息而开发的数据管理软件。如今,同学同学、老师同学联系都是通过电话联系。但是,通常这些数据其他人的信息混合在一起,同学信息并不方便被整理。 所以,同学通讯录管理程序为用户提供充足的信息快捷的查询手段,实现学生基本信息的录入,删除,查询,修改,存到文件等几方面的功能,这样能对同学之间的信息进行更好的管理,使老师能更好地管理学...

诶你爱我吗的博客 7213

【编程】【MFC面向对象静态函数静态变量做全局函数

属于原来的基础没打好吧,原来理解静态函数静态类很痛苦。 而且有时候看大家的代码也是在各个类里面用重复的函数,其实完全没有必要。 让大家都可以调用的函数可以用静态函数静态变量来实现,特别是对于面向对象。 例如MFC,在主要的类下面声明一个静态类 比如Sample.h里面 在public中 声明   static  void staticfunction1(); 然后再在Sample.cpp

artemisrj的专栏 1645

时钟的实现(MFC)

MFC中,用CTime类表示绝对的时间日期,用CTimeSpan类表示时间间隔。它们都没有基类,是不可派生的。因为没有虚函数,CTimeCTimeSpan对象的大小都正好是4个字节。其大多数成员函数都是内联的。CTimeCTimeSpan类引入了数据类型以及其相关的运行时函数,其中包括向或自一个Gregorian日期24小时时间的转换功能。这些函数将秒转换为日、时、分秒的各种组合。CTime值是基于世界标准时间(UCT)的,UCT时间等于格林威治(Greenwich)时间(GMT)。

m0_61219098的博客 2393

QTMFC的优缺点比较

文章目录Document/View model伪对象 vs 真对象创建界面Unicode国际化resources问题价格发布 (MFC效率较高,但大量的Windows API消息机制使得其较难理解,不易用;QT封装较好,易用且跨平台,但效率较低) MFC(微软基础类库)是专门为windows设计的一个用于开发图形用户界面的类库。MFC或多或少使用了面向对象的方法包装了Win32的- API,正因如此,这些API有时是C++,有时是C,甚至是CC++的混合体。 - Qt这个C++的图形库由Trollte

正在自我救赎的菜鸟。本人所有内容均不收费,可随意转发,复制 8445

MFC学习记录—— MFC入门

概念:Microsoft 基础类 (MFC) 库针对大部分 Win32 COM API 提供面向对象的包装器。虽然此包装器可用于创建极为简单的桌面应用程序,但当你需要开发具有多个控件的更复杂的用户界面时,此包装器将最为有用。可以使用 MFC 创建带有 Office 样式用户界面的应用程序。如上图所示, 其中CobjectMFC中提供了绝大数类的基类。该类完成动态控件的分配回收,支持一般的诊断、出错信息文档序列化等。

m0_58844000的博客 2740

基于MFC面向对象大作业

很简单实用,应付老师妥妥的。深入学习者就不用考虑了

mfc设计简单的计算器,能进行加减乘除运算

mfc的导向创建基于对话框的应用程序,添加按钮、编辑框等控件。实现算数的“加、减、乘、除”运算

基于MFC的学生信息管理系统程序

这是一个基于MFC的学生信息管理系统,在数据库中建立对应的表以后,就可以对学生信息进行添加,删除,修改,查询

C++MFC 面向对象程序设计 小型通讯录管理程序设计

深入理解面向对象技术的封装性、继承性多态性,掌握面向对象程序设计方法。 综合应用C++基础知识实现小型应用程序开发。 掌握使用C++流类库实现数据文件访问的操作方法。 熟悉基于对话框的MFC应用程序创建过程,掌握ClassWizard工具常用控件的使用方法。

shaozheng0503的博客 5559

C,C++,VC++,MFC之间有什么区别联系

转载:http://blog.163.com/jackie_howe/blog/static/199491347201242011203225/ C语言是一种古老而又经久不衰的计算机程序设计语言,大约诞生于上个世纪60年代。由于它的设计有很多优点,多年以来深受广大程序设计人员的喜爱,并逐渐淘汰了很多其它程序设计语言。我们平时使用的大多数软件都是用C语言开发的。很多后来出现的一些语言也沿用了很多它

努力努力... 1万+

MFC面向对象编程基本方式

不多说 直接上代码 #pragma once class Shape { public: Shape(void) { } virtual ~Shape(void) { } virtual void Draw(CDC *pDC) = 0; void SetRect(int left, int top, int right, int bottom) { m_rc.Se

laoye_laoye的专栏 1271

MFC中的面向对象编程(1)

一、Win32 API MFC API:应用程序接口。  MFC:微软基本类库。 win32 API 有大量的C函数,分为若干组如图像处理,网络通信,数据库操作,进程间通信等等,用户可以使用WIN32 API操作系统进行交互。 MFC是微软公司提供的一个C++类库,里面封装了大量的win32 C函数,进一步方便用户的使用(隐藏了许多细节)。      MFC(Microsoft Fo

database_zbye的专栏 1074
上一篇: 一个创建服务的类
下一篇: 解决编程中的乱码问题
dulinbo
博客等级 码龄22年 16粉丝 30原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值