Introduction to VC++


Introduction

Introduction to VC++
Visual c++ is an extremely powerful tool for window programming. It includes the built-in resources like MFC.MFC, Microsoft Foundation Class, is a package of prewritten ready-to-use code. User has to simply modify the code to customize his window.
MS-DOS:
            MS-DOS offers good functionality, the text interface, which is not easy for a layman to grasp and remember DOS commands.
            Every DOS program had a different user interface which the user was required to get used to before he can start getting workout of the program. DOS offers a crude multitasking called serial multitasking. In this type of multitasking one program is stopped temporarily while another is allowed to execute. At any given time only one task is run.

WINDOWS PROGRAMMING:
            Windows offers a visual interface intuitive and easy to use. Windows could offer multitasking capability where by the user could run several programs simultaneously in memory.
            The original design of windows, one of goals was to provide ‘device independence’, which means that the same program should be able to work using different screens, keyboards & printers without modification to the program.
            Windows programs do not send data directly to the screen. The output data is sent to the device context and then windows takes care of sending it to real hardware. The advantage of using the DC is that the graphics and text commands you send to the device context is always the same.
            User interacts with GUI. You write code to process these interactions. All the basic Code to create the GUI can be generated automatically by vc++.
Interactive Development Environment:
Ø Editor: An interactive environment to create and edit c++ source code.
Example: cut & paste, color pattern.
Ø Compiler: It converts your source code into object code and detect report errors in the compilation process.
Ø Linker: It combines various modules generated from the source code files, adds required code modules from libraries, generates an executable file.
Ø Libraries: It is a collection of pre written routines.
Examples are square roots, trigonometric functions, characters & strings comparison.
PROJECT:

            A project is a container for all the things that make up a program. It is a collection of files that are used to create one working, runnable program. Projects themselves are placed in WORKPLACES.

Parts of a VC++ program:
1)      The Application Object supported in .h and .cpp files, is what windows actually runs first. When this object is started, it places the main window on the screen.

2)      The Main Window Object displays the program itself, and this is where we find the menu bar, title bar and the tool bar of the window.

3)      The View Object handles the client area, where we format and display the data in our program.

4)      The Document Object where we store the data for our program and then the display of the data is handled by the client area of the view object.

Document/View Architecture:
            It is the foundation used to create applications based on the Microsoft Foundation Classes library. It allows you to make distinct the different parts that compose a computer program including what the user sees as part of your application and the document a user would work on. This is done through a combination of separate classes that work as an ensemble.
            The parts that compose the Document/View architecture are a frame, one or more documents, and the view. Put together, these entities make up a usable application.
            A view is the platform the user is working on to do his or her job. For example, while performing word processing, the user works on a series of words that compose the text. If a user is performing calculations on a spreadsheet application, the interface the user is viewing is made of small boxes called cells. Another user may be in front of a graphic document while drawing lines and other geometric figures. The thing the user is starring at and performing changes is called a view. The view also allows the user to print a document.
            To let the user do anything on an application, you must provide a view, which is an object based on the CView class. You can either directly use one of the classes derived from CView or you can derive your own custom class from CView or one of its child classes.
            For a computer application, a document holds the user’s data. For example, after working on a text processor, the user may want to save the file. Such an action creates a document and this document must reside somewhere. In the same way, to use an existing file, the user must locate it, open it, and make it available to, the application. These two jobs and many others are handled behind the scenes as a document.
            To create the document part of this architecture, you must derive an object from the CDocument class.

As its name suggests, a frame is a combination of the building blocks, the structure (in the English sense)., and the borders of an item. A frame gives “physical” presence to a window. A frame defines the location of an object with regards to the windows desktop. A frame provides borders to a window, borders that the user can grab to move, size, and resize the object. The frame is also a type of desk that holds the tools needed on an application.
            An application cannot exist without a frame. As we saw in previous lessons, to provide a frame to an application, you can derive a class from CFrameWnd.

PROCESSING MESSAGES:
            As windows communicate with your application by sending it messages, the processing of messages is at the core of all windows application.
MESSAGES:
Þ    Each message is represented by a unique integer value.
Þ    In the header file WINDOWS.H, there are standard names for these messages.
Þ    Some common windows messages are WM-CHAR, WM-PAINT, WM-MOVE, WM-CLOSE, WM-COMMAND, WM-SIZE.
Þ    A message will be accomplished by other values, that is related information such as a cursor or mouse coordinates, value of key press.
Þ    Each time an event occurs to which your program may need to respond, it is sent a message that identifies that event.
Þ    Window procedure receives each message, inside a window procedure a large SWITCH statement determines what type of msg has been received and then process it is clumsy. But in MFC, responding messages is much easier.
To respond to a message, your program must perform these 3 steps:
1.      The message macro corresponding to the message must be added to your
                                           I.            Programs message map.
2.      The prototype for the message handler must be added to the window class
                                           I.            That will process the message.
3.      You must implement the message handler associated with the message.



No comments:

Post a Comment