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.

Slides:



Advertisements
Similar presentations
Chapter 8 Technicalities: Functions, etc. Bjarne Stroustrup
Advertisements

Your First C++ Program Aug 27, /27/08 CS 150 Introduction to Computer Science I C++  Based on the C programming language  One of today’s most.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering 3 October 2007.
Chapter 2: Input, Processing, and Output
SUNY Morrisville-Norwich Campus-Week 12 CITA 130 Advanced Computer Applications II Spring 2005 Prof. Tom Smith.
Introduction to a Programming Environment
Introduction to Microsoft Windows MFC Programming: the Application/Window Approach Lecture 4.
C++ fundamentals.
C++ Functions. 2 Agenda What is a function? What is a function? Types of C++ functions: Types of C++ functions: Standard functions Standard functions.
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.
A First Program Using C#
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
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.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 11 1 Microsoft Office Access 2003 Tutorial 11 – Using and Writing Visual Basic for Applications.
Building an MFC Application Using the Wizard. Terms Solution – A container for related projects – An executable or DLL – May be constructed from multiple.
1 JavaScript. 2 What’s wrong with JavaScript? A very powerful language, yet –Often hated –Browser inconsistencies –Misunderstood –Developers find it painful.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
Visual C++ Lecture 11 Friday, 29 Aug Windows Graphic User Interface l Event driven programming environment l Windows graphic libraries (X11 on Unix,
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
BZUPAGES.COM Visual Programming Lecture – 5 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.
Overview of Previous Lesson(s) Over View  Visual C++ provides us with 3 basic ways of creating an interactive Windows application  Using the Windows.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 6 Functions.
Copyright © 2012 Pearson Education, Inc. Chapter 6: Functions.
MFC Windows Programming: Document/View Approach More detailed notes at: 360/notes-html/class15.htm.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
Introduction to the Windows API n API - Application Programming Interface n an API is the software interface for things such as the OS n an API is the.
Overview of Previous Lesson(s) Over View  Microsoft Foundation Classes (MFC)  A set of predefined classes upon which Windows programming with Visual.
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
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.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
File I/O ifstreams and ofstreams Sections 11.1 &
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
GAM666 – Introduction To Game Programming You must use special libraries (aka APIs – application programming interfaces) to make something other than a.
Current Assignments Homework 2 is available and is due in three days (June 19th). Project 1 due in 6 days (June 23 rd ) Write a binomial root solver using.
C463 / B551 Artificial Intelligence Dana Vrajitoru Python.
File I/O 1 ifstreams and ofstreams Sections 11.1 & 11.2.
CS 376b Introduction to Computer Vision 01 / 23 / 2008 Instructor: Michael Eckmann.
Chapter 4 Introduction to Classes, Objects, Methods and strings
1 CS161 Introduction to Computer Science Topic #9.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 6 Functions.
Objects and Classes Continued Engineering 1D04, Teaching Session 10.
CreatingClasses-SlideShow-part31 Creating Classes part 3 Barb Ericson Georgia Institute of Technology Dec 2009.
1 Printing in Python Every program needs to do some output This is usually to the screen (shell window) Later we’ll see graphics windows and external files.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 6: Functions.
Overview of Previous Lesson(s) Over View 3 Program.
1 Introduction to Object Oriented Programming Chapter 10.
1.1: Objects and Classes msklug.weebly.com. Agenda: Attendance Let’s get started What is Java? Work Time.
Microsoft Foundation Classes
Overview of Previous Lesson(s) Over View  Windows Programming  WinMain()  Where execution of the program begins and basic program initialization is.
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
Part II Document/View Architecture. Chapter 9 Documents, Views, and the Single Document Interface.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
Java and C# - Some Commonalities Compile into machine-independent, language- independent code which runs in a managed execution environment Garbage Collection.
Chapter 15 - C++ As A "Better C"
Building an MFC Application
Chapter 14 Windows Programming with the Microsoft Foundation Classes
MULTIPLE DOCUMENTS AND MULTIPLE VIEWS Prosise - Chapter 11
Document/View Architecture
Message Handling in MFC
Microsoft Foundation Classes MFC
User-Written Functions
Windows Programming Lecture 09.
Introduction to Computer Programming
Chapter 4 void Functions
Chapter 12 Windows Programming with the Microsoft Foundation Classes
SPL – PS3 C++ Classes.
Presentation transcript:

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 programs. They had to use Win32, which made it possible only to use C to create programs With this approach, everything was done manually, including the design and code writing, which was an increasing demanding task, wasting a good deal of time.

MFC LIBRARY Win32 was written in C and had no native support for C++. Therefore, Microsoft created a library, named Microsoft Foundation Classes Library, and abbreviated MFC This library was originally an “adaptation” or customization of Win32, adding object-orientation (classes and inheritance) to it The MFC is a library and can be used to manually develop programs The Microsoft Foundation Class (MFC) library is a set of data types, functions, classes, and constants used to create applications

MICROSOFT VISUAL C++ To make the use of MFC friendlier, Microsoft developed Microsoft Visual C++ This is a graphical programming environment that allows designing Windows objects and writing code to implement their behavior As its name indicates, this environment takes C++ as its base language

The first thing you should do to start a program is to create an application. In Win32, an application is created by a call to the WinMain() function and building a WNDCLASS or WNDCLASSEX structures.Win32 In MFC, this process has been resumed in a class called CWinApp (Class-For-A-Windows- Application). Based on this, to create an application, you must derive your own class from CWinApp

An application by itself is an empty thing that only lets the operating system know that you are creating a program that will execute on the computer. It doesn't display anything on the screen. If you want to display something, the CWinApp class provides the InitApplication() method InitApplication() is a Boolean method. If it succeeds in creating the application, it returns TRUE. If something went wrong when trying to create the application, it would return FALSE.

The minimum skeleton of an application would appear as follows: class CExerciseApp : public CWinApp { public: virtual BOOL InitInstance(); }; BOOL CExerciseApp::InitInstance() { return TRUE; }

After creating the application, to make it available to other parts of the program, you must declare a global variable of your class. It is usually called theApp but you can call it anything you want The fundamental classes of MFC are declared in the afxwin.h header file. Therefore, this is the primary header you may have to add to each one of your applications.

Based on this, a basic application can be created as follows: #include class CExerciseApp : public CWinApp { public: virtual BOOL InitInstance(); }; BOOL CExerciseApp::InitInstance() { return TRUE; } CExerciseApp theApp;

As its name implies, a frame of a window includes the borders, the location, and the dimensions of a window. There are two types of MFC applications: those that use a frame and those that don't. A frame-based application uses a concept known as the Document/View Architecture. This allows the frame to serve as a place holder for other parts of an application (such as the document and the view).

To create a frame, the MFC library provides various classes. One of these is called CFrameWnd and it is the most commonly used frame class. To use a frame, you can derive your own class from CFrameWnd as follows: class CApplicationFrame : public CFrameWnd { };

The skeleton of this frame only serves as a foundation for your class. You must actually create a window frame that would display to the user. To create a window frame, the CFrameWnd class provides the Create() method. Its syntax is: BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle = WS_OVERLAPPEDWINDOW, const RECT& rect = rectDefault, CWnd* pParentWnd = NULL, LPCTSTR lpszMenuName = NULL, DWORD dwExStyle = 0, CCreateContext* pContext = NULL );

As you can see, the only two required arguments are the class name and the window name. We will come back to all these arguments when we study window classes in more details. For now, a minimum frame can be created by simply passing the class name as NULL and the window name with a null- terminated string. Here is an example class CMainFrame : public CFrameWnd { public: CMainFrame(); }; CMainFrame::CMainFrame() { Create(NULL, "MFC Fundamentals"); }

In order to provide a window to the application, you must create a thread. This would be done using the CWinThread class. To make this a little easy, CWinThread is equipped with a public member variable called m_pMainWnd. This variable can be used to create a thread for the main window of the application. One of its advantages is that it makes sure that your application terminates smoothly when the user decides to close it.

CWinThread is the base class of CWinApp and therefore makes m_pMainWnd available to any CWinThread derived class such as CFrameWnd. Based on this, to create a thread for the main window to display, you can assign a pointer of your frame class to m_pMainWnd. After this assignment, m_pMainWnd can be used as the window object to display the frame, which is usually done by calling the ShowWindow() method.

BOOL CExerciseApp::InitInstance() { m_pMainWnd = new CMainFrame; m_pMainWnd->ShowWindow(SW_NORMAL); return TRUE; }