Vous êtes sur la page 1sur 4

B.Sc.CS.

TY
Programming in Visual C++
Chap 1 - Introduction

C++ is one of the powerful language due to its power & portability. It is available for
different operating system such as DOS, OS/2, UNIX, windows & many others.

C++ program when implemented under windows are called Visual C++. There is no any
difference between C++ & VC++ in terms of programming but the difference is in terms
of implementation.

A C++ compiler designed for implementation under windows is known as VC++ & A C+
+ compiler designed for implementation under DOS operating system is known simply as
C++, only environment of implemented is different. It shows in following fig.

C++ Implementation

MS DOS Environment Windows Environment

C++ Visual C++

Visual C++ is an Integrated Development Environment (IDE) introduced by Microsoft


which uses C++ language for developing program for Windows Operating System.

Feature of C++
1. VC++ provides Microsoft Foundation Classes popularly known as MFC, is a C++
class library introduced by Microsoft which contains more than 200 powerful
classes that can be used for writing windows program.
2. Proper use of MFC library, reduces the length of code & development time of an
application.
3. Application Wizard provided by VC++ helps us to define the fundamental
structure of an application.
4. Database Support – You can easily connect to database & you can perform any
kind on operation on database using your program.
5. COM – Component object modeling – it is a technology introduced by Microsoft
through which code written in one language can easily be reused in another
language so you can create component based program that can easily reuse in any
program or any language.
6. Intellisence – is a particular window which help us to automatic completion of
code & also used to display properties & methods related to particular object or
windows control

Prepared by: Somwanshi D.R.


7. Install shield –using this you can create installable package of your program or
setup file of your application than can be installed on any machine of same
platform.
8. Edit & continue debugging – you can now here edit your program while program
is in running mode means you can watch the changes or intermediate results of
the program.
9. Html resources – you can now place html resources like menu bar, toolbar, button,
etc on your window or program.
10. HTML help workshop – you create html help for your application.
11. DHTML viewing –you can now create application that are capable of displaying
dynamic pages.
12. New Common control – you can use number of control like IP address control,
date time picker control etc.

Introduction to Messages.

Message is a notification send by the operating system towords program or application


whenever an event is occurred.
Means whenever user performs any operation on any windows program, that operation
may be click, key press etc to responds to that operation windows operating system send
a message towards program to tell the program that, this operation is performed in this
program & you have to handle it. Whenever a program receives this input or message
from operating system it will call a particular function to responds to this action or
message.
In windows operating system every device is in control of operating system & every
device is shared by program available in windows operating system.
So allocation of device & providing input to program is a responsibility of operating
system.
Windows Operating System uses the event driven programming model in which
Application responds to events, by processing system messages send by the operating
system.
Event driven programming model is a model in which events are drive by application
with the help of operating system. Or the model in which the state of the program
changes according to user input.

An event is an action performed by user, an event could be keystroke, a mouse click etc.
Events are also referred to as message and can either be system defined, user defined or
application defined.
Events or messages are of three types.
1. User Defined – when user performs any action on window those are user defined
messages.
2. System defined – System can also send messages to application for example when
we shut down our system operating system send a message to every running
application for closing that application
3. Application defined – any part of application can send message to any another
part of the same or different application for example in Microsoft excel when we

Prepared by: Somwanshi D.R.


enter a table of data to draw a chart and when we draw chart from the table of
data. Then after Chart will automatically update when we modify data. This is
application defined message to update a part of application when one part of
application changes.
The code executed in response to an event is called an event handler or message
handler.
The application does nothing as long as there is no user event. Even though there is code
associated with the application. The code will get executed only in response to user event.

A Windows Application does not receive the input directly windows operating system is
inter mediatory. Any number of applications can be open simultaneously on windows. In
put from user may be directed at any one of these application.

Any input is directed to a particular window by windows operating system in the form of
message.
Windows operating system organizes or stores messages in queue, so that they can be
processed in an FIFO or orderly manner.
Windows Message queue are as follows.
1. A Main System queue for the message for all the open windows.
2. One message queue for each window that is open.

Windows works in following manner after input is received.

Input

Convert into message & placed into system message queue.

Windows removes the message from the message queue & examines it to determine the
destination window

Windows send the message from the system message queue to the message queue of
destination window.

The Window or application removes a message from its message queue and responds to
it.

Message map is table or method which maps windows message to appropriate message
handler.

Prepared by: Somwanshi D.R.


Windows defines hundreds of different message types. Most messages have names that
begin with the letters "WM" and an underscore, for ex. WM_CREATE, WM_PAINT etc.
These messages can be classified in various ways, but classification is not nearly as
important as realizing the critical role messages play in the operation of an application.
The following table shows 10 of the most common messages. A window receives a
WM_PAINT message, for example, when its interior part needs repainting.

Common Windows Messages

Message 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.

Message is simply a constant or unique value which indicates a particular input.

Prepared by: Somwanshi D.R.

Vous aimerez peut-être aussi