Copyright 1994 by Borland International, Inc. All rights reserved. All
Borland products are trademarks or registered trademarks of Borland
International, Inc. Other brand and product names are trademarks or
registered trademarks of their respective holders. October 1994
PRINTED IN THE USA
PART 1: Introduction
About this guide
We are pleased to present you with this release of Borland C++ 4.5.
Borland C++ 4.5 provides innovative OLE 2.0 capabilities and enhanced
32-bit performance. In Part 2, Introducing Borland C++ 4.5, we'll give
you a brief description of the features and benefits of the new product.
Part 3, Borland C++ 4.5 in Depth, provides greater detail about specific
product features, including important new facilities for building OLE
2.0 applications. Part 4 provides information on hardware and software
requirements, as well as installation and storage requirements. This
guide was written for product evaluators who are familiar with Borland's
line of compiler products for DOS and Windows. If you are not familiar
with Borland C++ products, we would be happy to provide you with more
in-depth information.
About Borland
With headquarters in Scotts Valley, California, Borland International is
the leading provider of comprehensive object-oriented language tools and
class libraries worldwide. Borland has achieved this status by
consistently providing best-of-breed development tools to all
programmersfrom novice to professionalfor the DOS and Windows
environments, and for the OS/2 operating system. Borland is a publicly
held company. Its stock is traded over the counter by NASDAQ under the
symbol BORL.
PART 2: Introducing Borland C++ 4.5
Features and Benefits
Borland C++ 4.5 includes important new capabilities in the following areas:
OLE 2.0 programming
Visual programming
Integrated Development Environment
VBX Integration
Compilation and linking
Online documentation
OLE 2.0 Programming
Simplified programmer interface to OLE 2.0. Borland C++ 4.5 introduces
the ObjectComponents Framework, a class library that makes it easy to
build OLE 2.0 capabilities into new programs and to add such
capabilities easily into existing applications. Technology unique to OCF
makes the processing of OLE requests a natural extension of a program's
event handling structure. OCF technology has been integrated into the
ObjectWindows Library but does not depend upon use of OWL. OCF is
designed to be used with other application frameworks. It can even be
used with C++ applications written directly to the Windows API.
Visual Programming
Enhanced support for building OWL programs. AppExpert now supports
automatic generation of OLE 2.0 applications, including object
containers, object servers and automation servers. ClassExpert can add
OLE automation to new applications as well as applications previously
created with AppExpert. ClassExpert also makes it easy to create
instances of OWL classes or ClassExpert-defined classes in user code.
Integrated Development Environment
Dynamic linking of help files. New OpenHelp technology permits users to
add files to the IDE's help viewer dynamically. This makes it easy for
developers to find help across the full set of technologies they use:
Borland tools and libraries, system interfaces, third party packages and
user-provided libraries.
VBX Integration
VBX controls in 32-bit applications. Developers of 16-bit applications
have long taken advantage of the wide range of visual and non-visual
components written to the Visual Basic Extension (VBX) specification.
Borland C++ 4.5 is unique in permitting 32-bit applications to take
advantage of these same components. VBX32 is a transparent mechanism
which permits standard 16-bit VBX controls to be used within 32-bit
applications without any extra effort on the part of the programmer.
Existing 16-bit programs that use VBX controls can be moved to 32-bits
with no more than a recompilation. (No change is required to the VBX
controls themselves.) New 32-bit programs can take advantage of the wide
variety of controls available, including those in Borland's own Visual
Solutions Pack.
Compilation & Linking
Faster Compiles. Borland C++ 4.5 includes a new high performance
optimizer and code generator for 32-bit applications. This new back end
can generate code 50% faster than before for both unoptimized and
optimized code. Reduced compile time means less time waiting and more
time making your program work.
Faster Code. In addition to compiling faster, the new 32-bit compiler
produces code which runs faster. Unoptimized code produced with this
compiler runs an average of 25% faster than unoptimized code generated
by the previous release. Optimized code averages 7%-10% faster than
optimized code from the earlier compiler, with improvements of as much
as 40% in some specific cases.
Smaller .EXE files. For 16-bit applications, Borland C++ 4.5 includes an
enhanced linker. A new post-link process removes redundant information
in .EXE files, reducing file size an average of 15% and application
startup time an average of 10%.
Online Documentation
New Online Documentation Technology. Borland C++ 4.5 incorporates a
powerful new search and display engine for online documentation. This
new engine provides faster display of documentation, more flexible text
search, copy and paste of text and code samples from manuals into user
files and greater user control over the display format of documents.
PART 3: Borland C++ 4.5 in depth OLE 2.0 Programming
Object Linking and Embedding (OLE) is an enhancement to the Windows
environment that controls interaction among multiple applications. Using
OLE 2.0 a single application can be used to examine and modify data
created by many different programs. OLE achieves this with a set of
interfaces that applications use to communicate with each other. OLE
permits a program to communicate without any requirement for specific
knowledge about the recipient of the communication.
The two major features of OLE 2.0 are compound documents and application
automation. Compound documents permit an application to incorporate data
from other OLE applications into its own documents. This data may be
included directly in the document or it may be stored elsewhere and
linked to the document. Automation permits one application to issue
commands to control the behavior of another application.
ObjectComponents Framework
While OLE can add powerful capabilities to applications, few
applications have been able to take advantage of this power. The
programmer interface for OLE 2.0 is large and complex, with most
operations requiring many interrelated procedure calls. For many
applications the addition of OLE requires writing thousands of lines of
additional code.
In addition to the sheer size of its API, programmers are confronted
with the difficulty of changing their event-based Windows programs to
deal with the Component Object Model (COM) interface used by OLE 2.0.
Supporting the COM interface can require an extensive rearchitecting of
an application's structure.
Borland's architecture provides a dramatic simplification of the
programmer's view of OLE. The ObjectComponents Framework (OCF) is a
class library that describes OLE's capabilities at a higher level of
abstraction, mapping a single programmer request into the many OLE
operations required to satisfy it. In many ways the relationship between
OCF and OLE is like that of a high level language to native machine
instructions.
OCF simplifies the programmer's job in a second way: by permitting
applications to receive OLE automation requests through their Windows
event handlers. OCF translates COM messages used to implement
automation into Windows events. This means that existing Windows
applications can be turned into OLE automation servers without any
change to their structure.
OCF does not depend on the use of OWL, Borland's ObjectWindows Library.
It can be used with other Windows interface frameworks or by
applications coded directly to the Windows API. OWL-based applications
do receive some special benefits from OCF. New OWL classes like
TOleWindow and TOleDocument already encapsulate OCF capabilities, making
adding OLE to an existing OWL application fast and easy.
OCF supports the full range of OLE 2.0 capabilities. Borland is unique
in providing all of the features discussed below, as well as in making
access to these features so simple. Other OLE 2.0 solutions require
direct programmingas well as an in depth understanding of OLE 2.0 -- to
add these capabilities to an application.
Object Container Support
Linking and embedding: To embed data from one application in the
document of another, OCF provides classes to represent the data in the
object and an image of the data for drawing on the screen. The data
must be separable from its graphical representation because OLE
transactions are sometimes handled by different programs. When the
container asks the server for an object to embed, the server must
provide data and a view of the data. The server can also be asked to
edit the object even after it is embedded and to read or write the
object to and from the container's document file. The OCF classes
handle both sides of these negotiations for you.
Clipboard operations: The default handlers for the OCF messages handle
cutting and pasting for you. If you add standard commands like Insert
Object and Paste Link to your menus, OCF will implement them for you.
Drag-and-drop operations: The default handlers for OCF messages help
you here, too. If the user drops an OLE object on your container's
window, OCF inserts it in your document. If the user clicks the
embedded object, OCF activates it. If the user drags the object, OCF
moves it.
Standard OLE 2 user interface: OLE defines standard user interface
features that programmers are expected to provide. Built into OCF are
dialog boxes for commands like Insert Object, Paste Special, and Paste
Link; a pop-up menu that appears whenever the user right-clicks an
embedded object; and an item on the container's Edit menu that shows the
verbs available for the active object. OCF modifies the container's
window when the server takes control of the container's tool bar, status
bar, and menus during in-place editing.
Compound files: OLE introduces a new storage model that gives
consistent structure to the contents of disk files. The inside of an
OLE file is divided into compartments and subcompartments. Each
compartment is called a storage. An OCF class called TOcStorage
encapsulates file input and output commands to compound files. If you
convert an ObjectWindows Doc/View application into an OCF container, the
document writes itself to a compound file automatically, creating
storages and substorages within the file as needed.
Object Server Support
OCF allows developers to create an OLE server as either a stand-alone
executable program (.EXE) or as DLL server. Because a DLL Server runs
in the same process as the container application, information exchange
between the server and the container occurs very quickly. By contrast,
information exchange between a container and an .EXE server requires
marshaling support which can be very time consuming. Marshaling has the
advantage of permitting data exchange between 16- and 32-bit processes.
Automation Support
OCF permits C++ classes to be automated without structural changes to
the classes themselves. OCF uses nested classes that directly access
the existing class members. These nested classes instantiate small
command objects which call the members through standard C++ mechanisms,
avoiding restrictive, non-portable stack manipulations. The command
objects provide hooks for undoing, recording, and filtering automation
commands. A program can even send itself automation commands using
standard C++ code.
These classes expose member functions and data of C++ classes to other
applications via OLE automation. New methods and properties can be
added to application-specific classes that support OLE automation.
Localization support: OLE servers need to speak the language of their
client programs. If an automation server is marketed in several
countries, it needs to recognize commands sent in each different
language. A linking and embedding server registers strings that
describe its objects to the user, and those too should be available in
multiple languages in order to accommodate whatever language the user
may request. If an application provides multiple translations for its
strings, OCF uses the right strings at the right time. Add your
translations to the program's resources and mark the original strings as
localized when you register them. At run time, OCF quickly and
efficiently retrieves translations to match whatever language OLE
requests.
Description field and help context: Borland's automation macros make it
easy to include meaningful descriptions for each of the methods or
properties exposed by the automation server. You can also supply a help
identifier to provide context sensitive help.
Argument validation: When an automation client is controlling an
application, it is easy to crash the server by passing unexpected or
erroneous data. Borland allows a developer to supply functions that
validate the data received by the server. The AUTOVALIDATE macro is
used to supply a validation function.
Type library generation: A type library describes for OLE all the
commands available for controlling an automated application. Once an
automation server has be created, you can ask OCF to build and register
a type library for you.
Visual Programming
Creating a professional Windows application is not an easy task. By
providing visual programming tools in Borland C++ 4.0, the developer can
concentrate on creating unique features rather than the mundane tasks of
setting up a Windows application. There are three main goals of the
Borland visual programming tools: simplify the process for beginners,
make a system that is useful for professionals and enhances OOP design,
and provide a flexible system that does not rely on "black boxes".
There are two visual programming Experts. AppExpert is used to generate
the source code for a new Windows application, and ClassExpert is used
to refine and customize the application.
AppExpert
AppExpert generates all the files needed to create a Windows
application. These include source files, resource files, and rich text
format (RTF) files for use with help files. AppExpert applications can
have multifile editing capabilities, complete with search, replace, and
undo, printing capabilities, a context sensitive help system, and an
about box. These applications can also have a menu system, SpeedBar,
and status line.
The AppExpert options are selected from a Settings Notebook. There are
three main pages in the notebook, entitled Application, Main Window, and
MDI Child/View. These summary pages contain a brief description of
modifications available, followed by the most commonly used options.
The Application page lets the user specify whether the application is to
support the single document interface (SDI) or multiple document
interface (MDI) or whether it should use a dialog as the main window.
The Application page also specifies whether the application should
support features such as a SpeedBar or status line.
The Main Window page lets the user choose the background color of the
application and the window title.
The MDI Child/View page allows the user to set the default MDI child
class and source file names. This page is only valid for MDI
application that use the document/view model.
Once the application options are chosen, pressing the Generate button
creates the application. At this point, AppExpert has created a full
featured Windows application. The application simply needs to be
compiled and run.
AppExpert: Advanced Options
Advanced features are accessed by expanding the options under each
summary page. Selecting an item from this list displays an entry
screen. For example, under the Application section the user can select
from Basic Options, OLE 2 Options, Code Gen Control, or Admin Options.
Selecting Basic Options displays a configuration screen that allows the
user to specify the application startup state and the control style.
OLE 2 Options is the most important new item in the Application section. The user can create an application that is an OLE 2 Container, OLE 2 Server, or both. The user can build either a DLL Server or an EXE Server. The user also has the option of adding automation support to the application.
ClassExpert
Once the basic application has been generated you can invoke the
ClassExpert to customize it. The ClassExpert lets you navigate and
customize the classes in your application, as well as add new ones.
There are three parts to ClassExpert. These include a Class window, an
Events window, and Source windows. You can right click in any of these
windows to display a context sensitive SpeedMenu.
The Class window shows all ObjectWindows-derived classes that are in the
application. This list is updated as new classes are added. Double
clicking on a class displays the constructor for the class. Single
clicking on a class moves to the last edited item for that class. Thus
the class list serves as a very efficient way to navigate through code
for an application. You can readily move back and forth between code in
different classes to compare operations. Among other things, the
SpeedMenu for the Class window allows the user to add a new class to the
project or automate an existing class. When Automate Class is chosen,
an Automation entry is added to the Events window.
The Events window shows a list of events that can be customized for the
selected class. Events are broken up into categories, such as Command
Notifications, Control Notifications, Virtual Functions, and Windows
Messages. Events are subdivided within the categories. This
hierarchical organization makes it far easier to grasp the range of
events that may be customized.
The Source window appears in the bottom of the ClassExpert. This
contains a complete BRIEF-like text editor. You can edit text, search
for expressions, move blocks, and even set break points and step through
the application. Using the SpeedMenu, the constructor call for any OWL
class or ClassExpert created class can be easily added to the source
code. For example, to instantiate a TPen object, select Use Class from
the SpeedMenu to display the Use Class dialog. Select Use OWL base
classes and then scroll the Class to Instantiate list box until TPen is
displayed. Double-click on TPen and the following line is added to the
source file:
// TPen *xTPen = new TPen(HPEN handle, TAutoDelete autoDelete
= NoAutoDelete);
This line shows you the syntax for creating a TPen object, with the
types of data needed by its constructor and their default values. Just
replace the prototype arguments with real values and remove the slash
marks and you have a correct statement for instantiating the object. And
you've done it in less time and with far less likelihood of error.
ClassExpert: Adding Handlers
ClassExpert has a built in database of OWL information. It not only
understands the command notifications that apply to a class and the
control notifications that apply to a control, but the set of virtual
functions relating to a class as well. Therefore, the user can easily
reuse OWL classes and take advantage of OOP inheritance. Base functions
are called automatically as appropriate.
To customize a class, find the particular message or function for which
you want to add code. For example, expand the virtual function list to
find the Create or the Paint method. Then, right click on the method
and select Add Handler.
When you add a handler, a check mark appears next to the event to
indicate that it is customized. A skeleton handler function is added to
the source, the edit window is scrolled to the handler, and you can
begin typing code.
If the class you are customizing has been automated, the Events window
contains an entry titled Automation. This entry allows you to automate
any data, methods, or properties contained in the class. New data,
methods, and properties can be created here as well.
ClassExpert: Adding A New Class
Not only can you customize existing classes, but you can readily add new
classes with ClassExpert. To do so, right click in the Class pane and
select Create new class. A window appears with an extensive list of
classes you can use as the base class for the new class.
Typically only visible classesthose causing something to be drawn on the
screencan be used as the base class. However, when Show All Classes is
selected, a class can be derived from any OWL base class, providing far
more flexibility and ease when creating an application.
ClassExpert: Automating A Class
The ClassExpert allows the user to add automation support to an
AppExpert generated application. Any class can be automated. To
automate a class, select it from the Classes Pane and bring up the
SpeedMenu by pressing the right mouse button. Complete the process by
selecting Automate class from the SpeedMenu. An Automation entry will be
added to the Events Pane.
The data members and methods associated with a class may be automated
from the events window by pressing the right mouse button over the
appropriate entry and selecting Add Data or Add Method from the Speed
Menu. Then fill in the fields of the dialog box. The parameters to an
automated method are listed just as they would be in the actual function
definition. Borland's encapsulation of OLE 2.0 automation supports a
description field and a help context identifier. This provides the user
of the automation controller additional information about the properties
and methods exposed by the server.
In addition to direct use of the data members and methods of a class,
read-only and writeable properties may be defined. It is recommended
that developers automate properties instead of working with data members
and methods directly. This shields automation users from changes in the
implementation of a class. Situations can develop in which a value that
was previously stored in a data member is replaced by a derived value.
Properties can be automated as easily as data members and methods. The
Automate Property dialog accepts the property's name (e.g. Width) its
data type and whether it may be retrieved (get) and/or modified (set).
From this information ClassExpert generates the functions that get and
set the property's value, using the property name as part of the
function name (GetWidth and SetWidth in the example above).
With ClassExpert it is easy to add automation support to any application
generated by AppExpert, including those built with Borland C++ 4.0.
Compilation & Linking
Borland C++ 4.5 contains enhancements for both 16-bit and 32-bit
development. For 16-bit developers there is a new set of linker options
that can reduce the size of program files and their startup times. For
32-bit developers there is a new code optimizer and generator that both
runs faster and produces faster code.
16-bit Linker
The 16-bit linker supports a new set of options for eliminating
redundant data and compacting .EXE and .DLL files. These options are
implemented as part of a post-link process. When these options are
present, the normal link takes place. On completion the .EXE or .DLL
file is reopened, optimizations are done and a new file is written. This
new file is typically 15% smaller than before. With fewer disk blocks to
read, the program loader can start the program an average of 10% faster.
The following link optimizations are supported. Command line switches
for each option follow the name of the option:
Chain Fixups: /Oc. Removes duplicate and/or unnecessary fixup data from
the file. This is done by emitting only one fixup record for each unique
internal fixup, and "remembering" the duplicate fixups by creating a
linked list of the fixup locations within the data segment. Also
eliminates trailing zeroes in data segments.
Iterate Data: /Oi. Scans data segments for patterns of data (e.g., a
block of 128 zero-filled bytes) and replaces them with a compressed
equivalent (a data value and byte count).
Minimize Segment Alignment Value: /Oa. Adjusts the minimum segment
alignment value based on the size of the file. A file of 1 to 64K
results in an alignment value of 1, 64K+1 to 128K results in a value of
2, etc. Produces a smaller file. In some cases this optimization for
size will make programs load more slowly since segments may cross