Overview of Previous Lesson(s) Over View  Windows Programming  WinMain()  Where execution of the program begins and basic program initialization is.

Slides:



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

MFC Workshop: Intro to the Document/View Architecture.
Introduction to Windows Programming. First Windows Program This program simply displays a blank window. The following code is the minimum necessary to.
Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#
Object Oriented Programming Chapter 7 Programming Languages by Ravi Sethi.
Introduction to Microsoft Windows MFC Programming: the Application/Window Approach Lecture 4.
1 Introduction to C++ Programming Concept Basic C++ C++ Extension from C.
Chapter 13: Object-Oriented Programming
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
C++ fundamentals.
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.
INTRODUCTION TO VC++ As the Microsoft Windows 3.X and then 5.5 operating system was becoming popular, many programmers were interested in creating graphical.
Overview of Previous Lesson(s) Over View  OOP  A class is a data type that you define to suit customized application requirements.  A class can be.
Microsoft Visual Basic 2005: Reloaded Second Edition
Building an MFC Application Using the Wizard. Terms Solution – A container for related projects – An executable or DLL – May be constructed from multiple.
Visual C++ Lecture 11 Friday, 29 Aug Windows Graphic User Interface l Event driven programming environment l Windows graphic libraries (X11 on Unix,
CMSC 202 Exceptions. Aug 7, Error Handling In the ideal world, all errors would occur when your code is compiled. That won’t happen. Errors which.
Prepared by Fareeha Lecturer DCS IIUI 1 Windows API.
BZUPAGES.COM Visual Programming Lecture – 5 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.
Getting Started The structure of a simple wxWidgets program, Look at where and how a wxWidgets application starts and ends, how to show the main window,
Overview of Previous Lesson(s) Over View  Visual C++ provides us with 3 basic ways of creating an interactive Windows application  Using the Windows.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
ICONICS ActiveX ToolWorX V 6.1.
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.
MFC Windows Programming: Document/View Approach More detailed notes at: 360/notes-html/class15.htm.
Overview of Previous Lesson(s) Over View  Microsoft Foundation Classes (MFC)  A set of predefined classes upon which Windows programming with Visual.
C H A P T E R T E N Event-Driven Programming Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
1 Pointer A pointer is a variable that stores an address of another variable of a particular type. A pointer has a variable name just like any other variable.
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.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
Systems Analysis and Design in a Changing World, 3rd Edition
GAM666 – Introduction To Game Programming You must use special libraries (aka APIs – application programming interfaces) to make something other than a.
1 Programming Paradigms Object Orientated Programming Paradigm (OOP)
Presentation Outline Introduction Painting and Repainting GDI.
Registering a window class Windows allows many styles of window to be created. To tell Windows to create a window as you want it you need to define a class.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
CS451 - Lecture 2 1 CS451 Lecture 2: Introduction to Object Orientation Yugi Lee STB #555 (816) * Acknowledgement:
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
ISBN Object-Oriented Programming Chapter Chapter
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
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.
Overview of Previous Lesson(s) Over View 3 Program.
1 Introduction to Object Oriented Programming Chapter 10.
LC++ programming in Windows environment Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 10./0. lThe Visual Component Library.
Part II Document/View Architecture. Chapter 9 Documents, Views, and the Single Document Interface.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Chapter 14 Windows Programming with the Microsoft Foundation Classes
Document/View Architecture
Message Handling in MFC
Microsoft Foundation Classes MFC
7.1 What Is An Object Object-oriented program - Description or simulation of application Object-oriented programming is done by adopting or extending an.
Advanced Object-Oriented Programming
Windows Programming Lecture 09.
Window.
Windows Programming Model
Table of Contents Class Objects.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
The program in traditional OS
CIS16 Application Development Programming with Visual Basic
C++ programming in Windows environment The Borland C++ Builder
COP 3330 Object-oriented Programming in C++
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/10.
Midterm Exam (2).
Chapter 12 Windows Programming with the Microsoft Foundation Classes
CMSC 202 Exceptions.
Presentation transcript:

Overview of Previous Lesson(s)

Over View  Windows Programming  WinMain()  Where execution of the program begins and basic program initialization is carried out.  WndProc()  Called by Windows to process messages for the application.  Contains the larger portion of code deals in responding to messages caused by user input of one kind or another. 3

Over View..  1 st we have to define the type of window we want to create.  Windows defines a special struct type WNDCLASSEX  It contains the data specified by a window. 4

WNDCLASSEX struct WNDCLASSEX {UINT cbSize; // Size of this object in bytes UINT style; // Window style WNDPROC lpfnWndProc; // Pointer to message processing function int cbClsExtra; // Extra bytes after the window class int cbWndExtra; // Extra bytes after the window instance HINSTANCE hInstance; // The application instance handle HICON hIcon; // The application icon HCURSOR hCursor; // The window cursor HBRUSH hbrBackground; // The brush defining the background color LPCTSTR lpszMenuName; // A pointer to the name of the menu LPCTSTR lpszClassName; // A pointer to the class name HICON hIconSm; // A small icon associated with the window }; 5

Over View…  2 nd step is to tell Windows about our defined structure.  This is done using the Windows API function RegisterClassEx() RegisterClassEx(&WindowClass); 6

Over View…  Each instance of the application must make sure that it registers the window classes that it needs.  CreateWindow() function is now used for creating a window whom characteristics are already known. 7

Over View…  The last task that WinMain() needs to do is dealing with the messages that Windows may have queued for our application.  2 kinds of Win messages  Queued Messages  Windows places in a queue and WinMain() function extract these messages from the queue for processing.  The code in WinMain() that does this is called the message loop. 8

Over View…  Non - Queued Messages  There are non - queued messages that result in the WndProc() function being called directly by Windows.  A lot of the non - queued messages arise as a consequence of processing queued messages. 9

Over View…  Message Processing  WinMain() contained nothing that was application - specific beyond the general appearance of the application window.  WndProc()  Windows calls this function each time a message for your main application window is dispatched. 10

Over View… 11 Program

Contents  MFC  Notation  Program Structure  Windows Forms 13

MS Foundation Classes  The Microsoft Foundation Classes (MFC) are a set of predefined classes upon which Windows programming with Visual C++ is built.  Represent an oo approach to Windows programming that encapsulates the Windows API.  MFC does not adhere strictly to the object – oriented principles of encapsulation and data hiding. 14

MS Foundation Classes..  The process of writing a Windows program involves creating and using MFC objects or objects of classes derived from MFC.  In the main part, we derive our own classes from MFC.  Assistance from the specialized tools in Visual C++. 15

MS Foundation Classes..  The objects of these MFC class types incorporate member functions  For communicating with Windows,  For processing Windows messages  For sending messages to each other. 16

MS Foundation Classes..  These derived classes, inherit all of the members of their base classes.  So we simply need to do is  Add data members  Function members to customize the classes to provide the application - specific functionality. 17

MFC Notation  All the classes in MFC have names beginning with C.  Ex. CDocument or Cview  So we will use this notation in our customized classes as well.  Data members of an MFC class are prefixed with m_. 18

Program Structure #include // For the class library  It contains the definitions for many MFC classes.  Allows to derive our own classes from MFC.  We only need to derive two classes from MFC:  Application class  Window class 19

Program Structure..  Application class  The class CWinApp is fundamental to any Windows program written using MFC.  An object of this class includes everything necessary for starting, initializing, running, and closing the application.  We need to produce the application to derive our own application class from CWinApp 20

Program Structure... class COurApp: public CWinApp { public: virtual BOOL InitInstance(); };  This function is defined as a virtual function in the base class.  Simply redefining it.  All the other data and function members inherited from CWinApp unchanged. 21

Program Structure...  Window class  Frame Window  MFC application needs a window as the interface to the user.  So we derive a window class from the MFC class CFrameWnd  CFrameWnd class provides everything for creating and managing a window. 22

Program Structure... class COurWnd: public CFrameWnd { public: // Constructor COurWnd() { Create(0, L"Our Dumb MFC Application"); } };  The Create() function that in the constructor is inherited from the base class.  It creates the window and attaches it to the COurWnd object that is being created. 23

Program Structure...  The 1st argument value for the Create() function, 0, specifies the base class default attributes.  The 2nd argument specifies the window name that is used in the window title bar. 24

Completing Program  Having defined a window class for the application, InitInstance() function in COurApp class BOOL COurApp::InitInstance(void) { // Construct a window object in the free store m_pMainWnd = new COurWnd; m_pMainWnd- > ShowWindow(m_nCmdShow); //...and display it return TRUE; } 25

Completing Program..  The InitInstance() function constructs a main window object for the application by using the operator new.  Stores the address that is returned in the variable m_pMainWnd, which is an inherited member of class COurApp  An instance of our application class COurApp must exist before Main() is executed COurApp AnApplication; // Define an application object 26

Program  Lets check the code.. 27

Window Forms  A Windows form is an entity that represents a window of some kind.  A Windows form is encapsulated by a subclass of the System::Windows::Forms::Form class.  To see just how easy it’s going to be, we create a basic window using Windows Forms that has a standard menu. 28

Program  Lets check the code.. 29

Thank You 30