Chapter 1 Hello, MFC.

Slides:



Advertisements
Similar presentations
Prof. Muhammad Saeed. Procedure-Driven Programming Event-Driven Programming Events Messages Event Handlers GUI Windows and Multitasking Queues ( System.
Advertisements

第九章 多媒体计算机 Nanjing University of Information Science & Technology, Dept. Computer Science.
计算机 在分析化学的应用 ( 简介 ) 陈辉宏. 一. 概述 信息时代的来临, 各门学科的研究方法都 有了新的发展. 计算机的介入, 为分析化学的进展提供了 一种更方便的研究方法.
地理信息系统概述. 数据和信息 (Data & Information) 数据 原始事实 如:员工姓名, 数据可以有数值、图形、声音、视觉数据等 信息 以一定规则组织在一起的事实的集合。
什么是 MPI? MPI(Message Passing Interface ) MPI 是一个库,而不是一门语言; MPI 是一个库,而不是一门语言; MPI 是一种标准或规范的代表,而不特 指某一个对它的具体实现; MPI 是一种标准或规范的代表,而不特 指某一个对它的具体实现; MPI 是一种消息传递编程模型,并成为.
Harris Spring 2005 讲座一 “ERP 与企业流程再造 ” 东南大学 自控系 赵霁教授 电话: 一 ERP 是什么? 二企业为什么要引入 ERP 系统? 三企业管理软件的发展与 ERP 的创新之处 四 ERP 与流程再造的关系。 五 企业流程再造规划分析。
协同工作环境研究中心 协同共享 助力科研. 主要内容  认识协同及协同软件  协同科研软件 duckling 介绍.
中国科学技术大学网络学院 第一章 C# 与.NET 概述. 2 本章目标 了解.NET Framework 的结构 理解.NET Framework 的基本概念 CLR JIT CTS MSIL 了解.NET Framework 命名空间 了解 C# 程序的基本结构.
1 第 7 章 专家控制系统 概述 专家系统的起源与发展 专家系统的一般结构 专家系统的知识表示和获取 专家系统的特点及分类.
信息利用与学术论文写作 Library of Jiangsu University, Zhenjiang Sha Zhenjiang
UML 对象设计与编程 主 讲 : 董兰芳 副教授 Dept. of Computer Science,USTC
从 Postscript 格式文献中提取 数学公式的方法. 概述 从 Postscript 格式文献中提取识别数学公式, 是数学公式识别领域的一个研究方向。主要针对 以 Word 和 Latex 为生成源的 Postscript 文档, 提出 基于内容的数学公式提取方法。首先重载 Postscript.
First Windows Program Hello Windows. 2 HELLOWIN.C #include LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; int WINAPI WinMain (HINSTANCE hInstance,
多媒体制作工具 Authorware 在流程线上添加图标 引入素材 编辑图标属性. 标题拦 菜单栏 图标栏 设计 窗口 演示 窗口 工具栏.
Introduction to Microsoft Windows MFC Programming: the Application/Window Approach Lecture 4.
第 3 章 控制流分析 内容概述 – 定义一个函数式编程语言,变量可以指称函数 – 以 dynamic dispatch problem 为例(作为参数的 函数被调用时,究竟执行的是哪个函数) – 规范该控制流分析问题,定义什么是可接受的控 制流分析 – 定义可接受分析在语义模型上的可靠性 – 讨论分析算法.
目录 上页 下页 返回 结束 第八章 第八章 一、空间曲线的一般方程 二、空间曲线的参数方程 三、空间曲线在坐标面上的投影 第四节 空间曲线及其方程.
国家高性能计算中心(合肥) 十五 并行程序设计环境与工具. 国家高性能计算中心(合肥) 并行程序设计环境与工具  15.1 软件工具与环境  15.2 并行编译器  15.3 并行程序调试  15.4 并行程序性能分析  15.5 图形化并行程序集成开发环境.
程序设计是计算机学科的核心和灵魂程序设计是计算机学科的核心和灵魂 程序设计基础 第十一章 面向对象软件构造.
MFC Workshop: Intro to MFC. What is MFC? Microsoft Foundation Classes C++ wrappers to the Windows SDK An application framework A useful set of extensions.
Course Introduction Programming Language(Using Java)
GVE, Hallym University, Song, Chang Geun, Ph.D. 컴퓨터 그래픽스 응용 한림대학교 컴퓨터공학부 송 창근.
Visual C++ Lecture 11 Friday, 29 Aug Windows Graphic User Interface l Event driven programming environment l Windows graphic libraries (X11 on Unix,
College of Computer and Information Science Chapter 14 Programming and Languages.
C++ 程序设计教程 MFC 简介 2. 1.RuntimeClass 执行期类型识别 1) CRuntimeClass struct CRuntimeClass { LPCSTR m_lpszClassName; CRuntimeClass* m_pBaseClass; static CRuntimeClass*
Prepared by Fareeha Lecturer DCS IIUI 1 Windows API.
Overview of Previous Lesson(s) Over View  Visual C++ provides us with 3 basic ways of creating an interactive Windows application  Using the Windows.
常州机电职业技术学院 数控编程与加工技术 精品课程 项目 3 加工中心程序编制 模块 2 方形型腔类零件 上饶职业技术学院 课程负责人:罗根云 2011 年 5 月
Chapter 1: Hello, MFC Windows Programming Model Department of Digital Contents Sang Il Park.
Chapter 1: Hello, MFC Your first MFC Application Department of Digital Contents Sang Il Park.
Overview of Previous Lesson(s) Over View  Microsoft Foundation Classes (MFC)  A set of predefined classes upon which Windows programming with Visual.
Microsoft Foundation Classes. What is MFC? Set of C++ classes written by MS Simplifies writing complex programs Covers many areas: – GUI – I/O – O/S interfaces.
BZUPAGES.COM Visual Programming Lecture – 2 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.
Direct3D Workshop November 17, 2005 Workshop by Geoff Cagle Presented by Players 2 Professionals.
GAM666 – Introduction To Game Programming You must use special libraries (aka APIs – application programming interfaces) to make something other than a.
新一代移动物联系统 MC MOBILE CONTROL 开启办公物联网时代 Product Promotion.
本讲主要内容: 1. 如何登陆网站后台 2. 基础信息修改 3. 网站文章类型资料更新 4. 网站图片类型资料更新 5. 网站链接类型资料更新 本讲主要目的: 在结束本讲内容之后,能够按照客户的需求对网站的资料 进行实时更新操作。
表单自定义 “ 表单自定义 ” 功能是用于制作表单的 工具,用数飞 OA 提供的表单自定义 功能能够快速制作出内容丰富、格 式规范、美观的表单。
Chapter2: Drawing a Window. Review: Introducing MFC.
SIMCOM EAT.
GUI-Based Programming ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University.
Dialog boxes Modal and modeless dialog boxes Displaying about dialog box: case WM_COMMAND : switch (LOWORD (wParam)) { case IDM_APP_ABOUT : DialogBox (hInstance,
Quanta Confidential QUANTA WBU Study Report 1 昭正 2008/08/01.
Programming Input Devices. Getting the device state Schemes for processing input – Polling – Callbacks Ways to intercept messages from input devices –
Java Web 应用开发: J2EE 和 Tomcat 蔡 剑, Ph.D.. 本讲内容 信息系统实施的基本概念 面向对象的程序开发 Java 技术综述.
The WM_NCHITTEST Message  This is an internal message used by Windows for generating all the other mouse messages.  Though it almost never needs to be.
U niversity of S cience and T echnology of C hina VxWorks 及其应用开发 陈香兰 年 7 月.
欢 迎 使 用 《工程流体力学》 多媒体授课系统 燕 山 大 学 《工程流体力学》课程组. 第九章 缝隙流动 概述 9.1 两固定平板间的层流流动 9.2 具有相对运动的两平行平板 间的缝隙流动 9.3 环形缝隙中的层流流动.
1 文件的查找. 2 回收站的管理 3 磁盘管理 格式化软盘 复制文件到软盘 整理磁盘碎片 4 格式化软盘.
Overview of Previous Lesson(s) Over View  Windows Programming  WinMain()  Where execution of the program begins and basic program initialization is.
仅供内部使用! 1 仅供内部使用 2.
SME.USTB Human Factors 人机工程学 By Wei Dong Department of Industry Design, SME, USTB.
Message Handling in MFC
Microsoft Foundation Classes MFC
Windows Programming Lecture 10.
Windows Programming Lecture 09.
Window.
Windows Programming Model
Aspect-Oriented Programming
Windows Programming using Dev C++
Queued and Nonqueued Messages
The program in traditional OS
Windows Programming Lecture 12
Windows Programming Lecture 13
Building a Win32API Application
CS 1253 Visual Programming Unit I Windows Environment
Windows Programming Lecture 15
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/10.
Graphics Laboratory Korea University
GUI Socket Application
Presentation transcript:

Chapter 1 Hello, MFC

Windows Programming SDK and API MFC Based on C-language Software Development Kit软件开发工具箱/包 Application Programming Interface应用程序接口 MFC Microsoft Foundation Class Library微软基础类库 Makes Windows programming simpler Microsoft Developer Network微软开发者网络 Windows API:Windows application programming interface(WIndows应用程序接口) Platform SDK:Platform Software Development Kit(平台软件开发工具包) 在概念上,SDK是一系列文件的组合,包括lib、dll、.h、文档、示例等等;API是对程序而言的,提供用户编程时的接口,即一系列模块化的类和函数。可以认为API是包含在SDK中的。

Windows Programming Model Event-driven事件驱动 programming model Procedural过程化 programming model

Windows Programming Model Event - Keystroke - Mouse click Command WM_QUIT message terminates msg loop

Common Windows Messages Sent When WM_CHAR A character is input from the keyboard WM_COMMAND The user selects an item from a menu, or a control sends a notification to its parent WM_CREATE A window is created WM_DESTROY A window is destroyed WM_LBUTTONDOWN The left mouse button is pressed WM_LBUTTONUP The left mouse button is released WM_MOUSEMOVE The mouse pointer is moved WM_PAINT A window needs repainting WM_QUIT The application is about to terminate WM_SIZE A window is resized

Four Input Parameters of Windows Message Handle of the window 窗口句柄 Message ID 消息编号 wParam 消息参数 lParam 消息参数

Handle of the window 32-bit value Uniquely identifies a window 窗口的唯一标识 References a data structure in which Windows stores relevant information about the window

Message ID A numeric value that identifies the message type WM_CREATE, WM_PAINT, etc.

wParam, lParam wParam lParam Information specific to the message type Example WM_LBUTTONDOWN wParam Holds a series of bit flags identifying the state of the Ctrl and Shift keys and of the mouse buttons lParam Holds two 16-bit values identifying the location of the mouse pointer when the click occurred

Window Program Structure

Windows Programming, SDK-Style int WINAPI WinMain (…) { wc.style = 0; // Class style … wc.lpszClassName = "MyWndClass"; RegisterClass (&wc); hwnd = CreateWindow (…); ShowWindow (hwnd, nCmdShow); UpdateWindow (hwnd); while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg); DispatchMessage (&msg); } return msg.wParam; }

Windows Programming, SDK-Style LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_PAINT: hdc = BeginPaint (hwnd, &ps); Ellipse (hdc, 0, 0, 200, 100); EndPaint (hwnd, &ps); return 0; case WM_DESTROY: PostQuitMessage (0); } return DefWindowProc (hwnd, message, wParam, lParam);

http://nojob.blog.51cto.com/1611772/320218 《Windows程序设计》第三章学习心得(1)|图解消息机制

Introducing MFC An object-oriented面向对象 wrapper around the Windows API Application framework应用程序框架 Encapsulates virtually every aspect of a program's operation Afx

Benefits of Using C++ and MFC Object-oriented面向对象 design methodology Framework uses a lot of tricks to make Windows objects Windows 一般窗口 Dialog boxes 对话框 Controls 控件

The MFC Design Philosophy Object-oriented interface to the Windows Reusability, self-containment, etc. Minimized the overhead

Document/View Architecture CDocument 文档类(data) Cview 视图类(display) To separate processed data and it’s display

The MFC Class Hierarchy CObject Serialization support Run-time class information support Diagnostic and debugging support

AFX Functions Global functions Begin with Afx AfxRegisterWndClass() Registers a custom WNDCLASS for an MFC application AfxMessageBox(…) display a messagebox window

First MFC Application How classes are derived from the MFC How classes are plugged into the application CWinApp class Application CFrameWnd class Main Window CPaintDC class Message mapping

Header File (hello.h) class CMyApp : public CWinApp { public: virtual BOOL InitInstance (); }; class CMainWindow : public CFrameWnd CMainWindow (); protected: afx_msg void OnPaint (); DECLARE_MESSAGE_MAP ()

Source File (hello.cpp) #include <afxwin.h> #include "Hello.h" CMyApp myApp; ////////////////////////////////////////////////////// / // CMyApp member functions BOOL CMyApp::InitInstance () { m_pMainWnd = new CMainWindow; m_pMainWnd->ShowWindow (m_nCmdShow); m_pMainWnd->UpdateWindow (); return TRUE; }

Source File (hello.cpp) // CMainWindow message map and member functions BEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd) ON_WM_PAINT () END_MESSAGE_MAP () CMainWindow::CMainWindow () { Create (NULL, _T ("The Hello Application")); } void CMainWindow::OnPaint () CPaintDC dc (this); CRect rect; GetClientRect (&rect); dc.DrawText (_T ("Hello, MFC"), -1, &rect, DT_SINGLELINE ¦ DT_CENTER ¦ DT_VCENTER);