Object-Oriented Programming is not something to fear. Once you grasp a few basic concepts you will embrace the huge benefit that it affords in terms of programming ease.

First let’s be clear about what an object is. Examples of objects that you will be familiar with are: windows, buttons, sliders, etc. In an OOP program these objects respond to events. For example, a button can respond to an event (like a user clicking it) by doing something (like making a sound play or a picture appear).

How an object responds to an event depends on what you have programmed it to do and the characteristics of the particular object. A button will play a sound if it is clicked (a button event) only if you have programmed it to do so and it will only respond to a click at all if it is enabled (a button property); i.e. not greyed out.

Sample_Project 4Objects can hold programming code. In this way an object can be self contained. It can “know” how to respond to events by means of the code it contains.

In the example above Popupmenu1 knows what to do if the user selects an item in its menu. The code in the Change event determines what happens when Popupmenu1 receives a Change event.

Objects can usually respond to several different kinds of events. For example, PushButtons can be programmed to respond to MouseDown, MouseUp, Open, Close, GotFocus, and a number of other events.

Objects also have properties (characteristics). For example, a button has, among others, width, height, position (left and top), and caption properties.

An object’s properties can be modified either by entering data into the object’s Properties in the Inspector or by using programming code. For example, to set the caption of Pushbutton1 to “OK” you could use the following code:

PushButton1.caption = “OK”

Basically, then, Object-Oriented Programming (OOP) is done by:

1) putting code into various objects so that they respond to events in desired ways


2) by modifying objects’ properties so that they are appropriate to the objects’ particular jobs in the program.