Beruflich Dokumente
Kultur Dokumente
®
Turbo C ++ for Windows
I n t r o d u c t i o n
Copyright
Agreement
Turbo C++ is a powerful, professional programming tool for creating and maintaining
16-bit Windows applications. Turbo C++ supports both the C and C++ languages with
its integrated development environment.
This manual is divided into two parts. Part I introduces you to the integrated
development environment (commonly known as the IDE). Part II teaches you how to
use Resource Workshop to build resources for your Windows applications. In addition,
this manual contains three appendixes which describe EasyWin (a library that converts
your DOS programs to Windows programs), the Turbo C++ precompiled header files,
and the error messages that can be generated by the Turbo C++ programming tools.
Introduction 1
The following is a list of new features in version 4.5. This list is provided for those who
are upgrading from a version prior to Turbo C++ 4.5:
• The IDE has a graphical integrated debugger for debugging 16-bit Windows
applications.
• The IDE has an enhanced editor that lets you record keystroke macros, work in
multiple panes in one editor window, and search for text using regular expressions.
You can configure the editor to use Brief or Epsilon keystrokes or you can create your
own keystroke configurations.
• The right mouse button brings up SpeedMenus in the IDE that list commands specific
to the object you click. For example, some common editing commands are on the
SpeedMenu of all editor windows. (To access old functions of the right mouse button,
press Ctrl+click right mouse button.)
• The IDE has a new multiple-target Project Manager that visually shows file
dependencies and lets you manage more than one program.
• The IDE has a new multiple-window Browser that displays class relationships.
• The IDE has AppExpert and ClassExpert, which let you quickly generate
ObjectWindows 2.5 programs. Turbo C++ helps you modify and organize your
application.
2 User’s Guide
Manual conventions
This manual uses the following special fonts:
Monospace This type represents text that you type or text as it appears onscreen.
Italics These are used to emphasize and introduce words, and to indicate
variable names (identifiers), function names, class names, and structure
names.
Bold This type indicates reserved keywords, format specifiers, and command-
line options.
Keycap This type represents a particular key you should press on your keyboard.
For example, “Press Del to erase the character.”
Key1+Key2 This indicates a command that requires you to press Key1 with Key2. For
example, Shift+a (although not a command) indicates the uppercase letter
“A.”
ALL CAPS This type represents disk directories, file names, and application names.
(However, header file names are presented in lowercase to be consistent
with how these files are usually written in source code.)
Menu|Choice This represents menu commands. Rather than use the phrase “choose the
Save command from the File menu,” Borland manuals use the convention
“choose File|Save.”
Getting help
The Help system gives you online access to detailed information about Turbo C++. You
can find most product information in both the online manuals and online Help.
However, the following topics are covered only in online Help:
Introduction 3
• IDE menu commands
• Editor KEYMAPPER
• Example run-time library code
• Windows API
To display online Help
• In the IDE, choose Help from the menu or press F1.
• In dialog boxes, click the Help button or press F1.
• For menu commands, select the menu command and then press F1.
4 User’s Guide
Part
I
Using the integrated development
Part I
environment
Part I of this manual describes how to use the components of the Turbo C++ integrated
development environment (IDE).
The IDE integrates development of 16-bit Windows applications. Using the Project
Manager, you can easily build several application types from a single project file.
AppExpert and ClassExpert let you take advantage of ObjectWindows 2.5. The
integrated debugger and browser let you debug your source code and browse class
objects and hierarchies without leaving the IDE.
The following chapters cover the tools available through the IDE:
• Chapter 1, “Getting started,” introduces you to the Turbo C++ IDE and takes you
though the creation of simple Windows programs.
• Chapter 2, “Creating and managing projects,” describes the Project Manager, and
shows you how to use the TargetExpert and Source Pools to create the projects for
your applications.
• Chapter 3, “Specifying project options and compiling,” shows you how to use Style
Sheets and local overrides to set your project options, and how to compile from the
IDE. In addition, Chapter 3 contains a complete reference to the options available for
both the IDE and the command line tools.
• Chapter 4, “Building applications with AppExpert,” describes AppExpert and
shows you how to create the source-code foundation for your ObjectWindows 2.5
applications.
• Chapter 5, “Modifying applications with ClassExpert,” describes how to modify the
applications you create using AppExpert.
6 User’s Guide
Chapter
Getting started
Chapter 1
1
Turbo C++ is a development package that contains the compilers, tools, and utilities you
need for developing 16-bit Windows applications. You’ll find that you can accomplish
most of your application development using the integrated development environment
(IDE).
To help you get familiar with the IDE, this chapter offers an overview of the following
IDE features:
• Starting the Turbo C++ IDE
• Using SpeedMenus in the IDE
• Using the Edit window
• Working with simple projects
• Customizing the IDE
• Running other programs from the IDE
Menu Bar
SpeedBar
Edit
window
Message
window
Project
window
Status Bar
8 User’s Guide
The IDE SpeedBar
The SpeedBar (located under the main menu) has buttons that give quick access to
menu commands which relate to the area of the IDE you’re working in. For example, if
you’re editing code, the SpeedBar contains cut and paste commands, file save
commands, and so on. When the Project window has focus, the SpeedBar has buttons
that pertain to projects, such as commands for adding project nodes and browsing
option settings.
The Status Bar at the bottom of the IDE contains “flyby” help hints; when the cursor is
over a button, the Status Bar describes the button command. You can configure the flyby
hints and other SpeedBar options, as described in “Customizing the SpeedBars” on
page 16.
10 User’s Guide
Creating an EasyWin Program
You can become familiar with the Project Manager and the C++ compiler by following
these steps to create a simple EasyWin program:
1 From the IDE, choose Project|New Project, then set the following options in the New
Target dialog box:
• Type the path and name for your new project into the Project Path And Name
input box. In this case, type:
\mysource\ezw_test.ide
Note If the directory doesn’t exist, the IDE creates the directory for you.
• In the Target Type list box, click EasyWin [.EXE]. This selection creates a Windows
program from a program that uses character-mode input and output. (For more
information on EasyWin, refer to Appendix A, “Using EasyWin.”)
The New Target dialog box should now resemble the one shown in Figure 1.2.
Figure 1.2 The New Target dialog box
2 Choose OK to close the New Target dialog box. The Project window opens and
displays the target and dependencies of the project you just created.
Notice that one of the nodes in the project points to the file EZW_TEST.CPP, the file
you created earlier in the chapter (if you haven’t already done so, create this file by
following the instructions listed in the previous section “Creating a new file”).
3 Because the .DEF and .RD files are unnecessary for this project, you must delete the
.DEF and .RC nodes created by the Project Manager:
1 Select the EZW_TEST [.DEF], then press Ctrl and select EZW_TEST [.RC].
2 From the Project Manager SpeedMenu (press the right mouse button), choose
Delete Node, then choose Yes to confirm your request to delete 2 project nodes.
12 User’s Guide
#include <windows.h>
int PASCAL WinMain(HINSTANCE hCurInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
MessageBox(NULL, "Welcome to the World of Windows!", "A Windows Program",
MB_OK | MB_ICONEXCLAMATION );
return(0);
}
6 Choose Project|Build All to compile this program, then choose OK after the
compilation is finished. If you followed the steps correctly, you can arrange the
windows so the IDE resembles the screen shown in Figure 1.1 on page 8.
When you build this project, the compiler produces several warnings, but it still
creates an .EXE file in the \MYSOURCE directory. Even though a program that
compiles with warnings can still be executed, it’s not a good idea to ignore the
warnings without first understanding why the compiler complained.
The first warnings that appear indicate that the parameters in WinMain are never
used in the program. In this small program, it is safe to ignore these warnings. The
last warning indicates that the default module-definition settings are being used; this
is expected since we didn’t create a module-definition (.DEF) file.
7 To run the program from the IDE, choose Debug|Run.
When you run this program, a small dialog box with the text “Welcome to the World of
Windows!” appears. To terminate the program and return to the IDE, choose OK.
14 User’s Guide
Configuring the IDE editor
You can configure the editor so that it looks and behaves like other editors such as Brief
and Epsilon. The IDE editor uses keyboard mapping files (.CKB files) that set the
keyboard shortcuts for the editor and the other windows in the IDE. A complete
reference to the keyboard mapping files is available in the online Help (choose Help|
Keyboard).
You can use one of the four .CKB files provided with Turbo C++ by choosing Options|
Environment|Editor, then clicking a SpeedSetting (Default keymapping, IDE classic,
BRIEF emulation, or Epsilon emulation). To learn how to edit or create your own .CKB
file, refer to the online Help and search on “Keymapper.” You can also customize the
editor script files (.KB files), which are found in the directory \TCWIN45\SOURCE\
KEYBOARD.
Note All keymappings shown in this manual reflect the default Turbo C++ keymappings. If
you install a different keyboard mapping (such as BRIEF.CBK), the shortcuts shown in
this manual will not be the same as those installed on your system.
Syntax highlighting
Syntax highlighting lets you define a color and font attribute (such as bold) for certain
elements of code. For example, you could display comments in blue and strings in red.
Syntax highlighting is on by default.
Syntax highlighting works on files whose extensions are listed in the Syntax Extensions
list (by default, these files are .CPP, .C, .H, .HPP, .RH and .RC). You can add or delete
any extension from this list, but be sure to separate extensions with semicolons.
The Syntax Highlighting section displays the default color scheme and four predefined
color settings. To use a predefined color scheme,
1 Choose Options|Environment|Syntax Highlighting.
2 Choose one of the four color predefined schemes (Defaults, Classic, Twilight, or
Ocean) by choosing the Color SpeedSetting; the sample code changes to the color
scheme you select.
To customize the syntax highlighting colors,
1 Choose Options|Environment, then select the Syntax Highlighting topic.
2 Select a predefined color scheme to use as a base for your customized colors.
3 Choose the Customize topic listed under the Syntax Highlighting topic. Elements
and sample code appear on the right of the Environment Options dialog box.
4 Select an element you want to modify from the list of elements (for example, choose
Comment), or click the element in the sample code (this selects the name in the
Element list). You might need to scroll the sample code to view more elements.
5 Select a color for the element. The element color in the sample code reflects your
selection. Use the left mouse button to select a foreground color for the element (FG
appears in the color). Use the right mouse button to select a background color (BG
16 User’s Guide
• To reorder the button positions for a SpeedBar, select a button in the Active Buttons
list, and use the up and down arrows to move the button within the list (the top
button in the list appears on the left side of the SpeedBar; the last button in the list
appears on the right side of the SpeedBar).
• To put separator spaces between buttons on the SpeedBar, select a button from the
Active Buttons list then click the Separator button. The separator is added before
the selected button.
You can also make all SpeedBars identical by selecting a SpeedBar in the Window list,
then pressing the Copy Layout button. A dialog box appears in which you check all the
SpeedBars you want to make identical to the selected SpeedBar. For example, if you first
choose the Editor SpeedBar, then click Copy Layout, the dialog box appears with Editor
dimmed. If you then check Project and Message, those SpeedBars will be exactly the
same as the Editor SpeedBar.
You can restore any SpeedBar to its original defaults by selecting the SpeedBar in the
Window list then clicking the Restore Layout button.
18 User’s Guide
Chapter
Run-time nodes
The Project Manager uses the following types of nodes to distinguish the different types
of files in your project:
• The project node, located at the top of the Project Tree, represents the entire project. All
the files used to build that project appear under the project node. By default, the
project node is not displayed in the Project Tree. To display the project node, choose
Options|Environment and select Project View from the list of Topics, then check
Show Project Node.
• A target node represents a file that is created when its dependent nodes are built (a
target is usually an .EXE, .DLL, or .LIB file that you’re creating from source code). A
project can contain many target nodes. For example, in a single project, you might
build an executable file and two separate DLL files, making three targets in all.
• Source nodes refer to the files that are used to build a target. Files such as .C, .CPP, and
.RC are typical source nodes.
• A run-time node refers to files that the Project Manager uses during the linking stage of
your project, such as startup code and .LIB files. The Project Manager adds different
run-time nodes, depending on the options you specify in TargetExpert. By default,
run-time nodes are not displayed by the Project Manager. To view run-time nodes,
choose Options|Environment|Project View, then check Show Runtime Nodes.
• Autodependency nodes are the files that your program automatically references, such as
included header files. By viewing autodependency nodes, you can see the files that
source nodes are dependent upon, and you can easily navigate to these files from the
Project Manager. By default, autodependency nodes are not displayed in the Project
Manager. To view autodependency nodes, choose Options|Project|Make, then
check Autodependencies: Cache & Display. Note that you must build the project
before the Project Manager can display autodependency information.
The Project Manager uses the following color scheme for its nodes:
20 User’s Guide
• Blue nodes are those that were added by the programmer.
• White nodes indicate project targets.
• Yellow nodes are those that were added programmatically by the compiler (when it
posts dependencies and Autodependencies), by AppExpert or ClassExpert (when
they add .CPP nodes), or by TargetExpert (when it adds nodes based on the target
type).
The Project Manager uses special glyphs in the left margin to indicate the build attributes
of project nodes. To apply build attributes to a node (and for a reference on the different
Project Manager glyphs), choose Edit Local Options from the Project Manager
SpeedMenu, then select the Build Attributes topic.
In addition to helping you organize your project files, you can use the Project Manager
to access source files and build targets.
• To bring a source file into an Edit window, double-click the node in the Project Tree,
or highlight the node and either press Enter or choose View|Text Edit from the
Project Manager SpeedMenu.
• Using the Project Manager to make a project is very effective because you can use the
Project Manager to translate only the files that have changed since the last project
build; computer resources are not wasted on unnecessary file updates. (The term
“translate” refers to using one file type to create another. For example, the C++
compiler is a translator because it generates .OBJ files from .CPP files. For more
information on translators, see page 30.)
There are several ways to customize the build options of the nodes in your project.
Maintaining project options and compiling project targets is described in detail in the
next chapter, “Specifying project options and compiling.”
Creating a project
When you begin to write a new application, the first step is to create a new project to
organize your application’s files. The command Project|New Project opens the New
Target dialog box, which is shown in Figure 1.2 on page 11.
3 Choose the type of target you want to build using the Target Type list. For
information on the target types, see the online Help for the IDE. Information on using
the Help compiler can be found in the online Help file CWH.HLP.
4 Choose a platform for your target using the Platform drop-down list. Information for
the individual platform types can be found in online Help.
5 Select the memory model of the target from the Target Model options.
• Small uses different code and data segments, giving you near code and near data.
• Medium gives you near data and far code.
• Compact is the inverse of the Medium model, giving you near code and far data.
• Large gives you far code and far data.
The entries in the Target Model list adjust according to the Platform type you’ve
selected.
6 Using the Standard Libraries group, choose the types of libraries to use with your
application (depending on your platform and target choices, some of these libraries
might not be shown):
• OWL uses the ObjectWindows libraries. See the ObjectWindows Programmer’s
Guide for more information.
• OCF uses the ObjectComponents OCOLE.DLL support library (a framework that
encapsulates OLE 2). See the ObjectWindows Programmer’s Guide for information.
• Class Library uses the Turbo C++ container class libraries discussed in the
Programmer’s Guide and the Library Reference.
• Runtime uses the standard C/C++ function libraries listed in the Library Reference.
• BWCC uses the Borland Windows Custom Control libraries. See Chapter 10 for
details.
• OLE 2 links the libraries that support OLE 2.
22 User’s Guide
For Windows applications, you can choose the following type of linking methods:
• Dynamic causes your application to bind to the standard libraries at runtime—
the functions in the standard libraries are located in a separate .DLL rather than
directly attached to your application. This greatly reduces the size of an
application, but the target is then dependent on the presence of the .DLLs at
runtime.
• Static binds the standard library functions directly to your executable file, creating
a larger, standalone executable. If you’re building many DLLs with statically
bound RTLs, each DLL gets its own copy of the routines it uses.
The following library choice applies to a very specific build situation:
• Diagnostic uses a diagnostic version of the libraries, which have debug and
diagnostic information added to the files. This option is available for only Class
Libraries and ObjectWindows.
Note Some libraries are automatically checked when you choose a target type (you can’t
uncheck some of these because they are required for the type of target you’re
creating). If dynamic and static libraries exist, you can choose which type of library
you want to use (in this case Dynamic is usually the default library type).
7 If needed, click the Advanced button to specify the types of source nodes created
with your new target (this procedure is described in the following section).
8 Click OK to accept the settings and close the New Target dialog box. The Project
Manager creates the project file, which is denoted with an .IDE extension.
When you close the New Target dialog box, the Project Manager draws a graphical
representation of your project in the Project window. The Project Manager creates a
target node with one or more source nodes below with the project node. After creating
the initial target for a project, you can add, delete, or modify the nodes in your project, as
described in the following sections.
24 User’s Guide
• Style Sheet is the name of the Style Sheet the Project Manager uses when it
translates that node. If <<None>> is specified, the Project Manager uses the option
settings in the parent’s Style Sheet. For more information on Style Sheets, see the
next chapter, “Specifying project options and compiling.”
• Translator names the translator used on that node. The IDE assigns a default
translator for the node type (for example, CppCompile for a .CPP node), which
can be overridden using this field. See “Translators, viewers, and tools” on page 30
for more information on translators.
• Node type defines the node extension, which in turn defines the available
translators for that node.
26 User’s Guide
1 Select the node or nodes you want to copy (press Shift or Ctrl and click to select
multiple nodes). You don’t need to select the node’s dependents because they are
copied automatically.
2 Hold down the Ctrl key and drag the selected nodes to where you want to place the
complete copies.
3 When you release the mouse button, the copied nodes appear. At this point, you can
edit either the original or the copied nodes without changing other nodes in the
project.
To copy a node by reference,
1 Select the node you want to copy by reference. You don’t need to select the node’s
dependents because they are automatically copied by reference.
2 Hold down the Alt key and drag the selected node to where you want to place the
reference copy.
3 When you release the mouse button, the reference-copied node appears and is
displayed in a lighter font. This helps you remember that the node is copied by
reference rather than by value. If you edit the original node (such as adding or
deleting dependents), all referenced copies are updated.
Warning! You cannot add to, delete, or modify nodes that have been copied by reference; to
modify nodes copied by reference, you must edit the master copy. If you delete an
original node, all reference copies to that node are also deleted. You cannot undo this
deletion.
2 Check or uncheck the options you want. A sample node called WHELLO changes as
you select or deselect options. This sample shows you how all nodes appear in the
Project window.
• Build translator displays the translator used on the node.
• Code size displays the total size of code segments in bytes. This information
appears only after the node has been compiled.
• Data size displays the size of the data segment in bytes. This information appears
only after the node has been compiled.
• Description displays an optional description of the node in the Project Tree. Type
the description using the Edit Node Attributes dialog box available from the
Project Manager SpeedMenu.
28 User’s Guide
• Location lists the path to the source file associated with the node.
• Name displays the name of the node.
• Number of lines displays the number of lines of code in the file associated with
the node (note that this appears only after you compile the code).
• Node type describes the type of node (for example, .cpp or .c).
• Style Sheet names the Style Sheet attached with the node.
• Output names the path and file name that’s created when the node is translated.
For example, a .CPP node creates an .OBJ file.
• Show runtime nodes displays the nodes the Project Manager uses when the
project is built. For example, it lists startup code and libraries.
• Show project node displays the project node, of which all targets are dependents.
3 Click OK to close the Environment Options dialog box.
4 To save your project customizations, choose Options|Save, then check Project. Note
that you can save different option sets with the different projects you work on.
30 User’s Guide
1 Choose Options|Tools to open the Tools dialog box.
Figure 2.4 The Tools dialog box
2 Select the item you want to inspect from the Tools list.
3 Choose Edit to access the Tools Options dialog box.
4 Choose Advanced to access the Tool Advanced Options dialog box, then inspect the
Default For text box.
When you right-click a node, you’ll find that some source nodes have a Special
command on the SpeedMenu. This command lists the alternative translators that are
available for the node type selected. For example, the commands C To Assembler, C++
To Assembler, and Preprocess appear on the Special menu of a .CPP node. The
command Implib appears if you selected a .DLL node. Using the Special command, you
can invoke any translator that is available for a selected node type. Also, by selecting a
source node in the Project Tree and choosing Edit Node Attributes from the
SpeedMenu, you can reassign the default translator for the selected node.
32 User’s Guide
files. If you have a source node with a .C extension, CppCompile appears on the
Special menu when you right-click the node and choose Special.
Figure 2.5 The Tool Advanced Options dialog box
• Translate To defines the extension of the file that the translator generates. For
example, HC31.EXE converts .HPJ files to .HLP, so HC31.EXE holds .hlp in this
field.
• Applies To is similar to the Translate From field, except that it’s used for Viewers
instead of translators.
• Default For changes the IDE’s default translator or viewer for the file types you
specify. Type the file extensions (separating each with a semicolon) for the file
types whose default you want to override.
5 Choose OK twice to confirm your settings, then close the Tools dialog box.
Your new tool has now been added to the Tool list of the associated project, and to the
Tool menu or SpeedMenu, depending on where you chose to add the item. If you added
the item to the Tool menu, you can check the addition by choosing Tool from the main
menu; the new program name appears on the Tool list.
Note Although the Project Manager lets you define your own Tool items, these items apply
only to the project that you add them to; they aren’t added as permanent parts of the
IDE.
To see an example of how Style Sheets are used in a project, open the STYLESHT.IDE
project file located in the EXAMPLES\IDE\STYLESHT directory of your Turbo C++
directory tree. This file uses a different Style Sheet for each of its two versions of
WHELLO. The project also contains a text file that explains the use of Style Sheets.
36 User’s Guide
Figure 3.2 Style Sheets dialog box
Warning! Be careful when you use the Options|Project command to modify option settings; if
your project contains more than a single target node, the changes you make always
modify the project’s Default Project Options (regardless of the node you have selected
when you choose the command). Because of this, all targets in your project inherit the
changes you make when you use the Options|Project command. In addition, if you
modify project options when you don’t have a project loaded, your modifications
update the Default Project Options Style Sheet; the projects you later create will inherit
these new default settings. If you need to revert to the IDE’s factory default settings,
delete the file TCWDEF.TCW (located in the \TCWIN45\BIN directory), then open and
close the IDE to create a new file.
38 User’s Guide
;To have new projects inherit settings from currently open project:
inherit=1
2 When you select a node in the Project Options At list, its settings appear to the right
in the Options list.
40 User’s Guide
The Options list displays components of the project in square brackets. At the top of
the list, you’ll see the name of the project followed by its Default Project Options.
Below this is the name of the target associated with the node you’ve selected. If the
node has a Style Sheet associated with it, it’s displayed beneath the node (also in
brackets), along with the settings of the Style Sheet. If you’ve overridden any settings,
these are displayed beneath the [Node overrides] listing. The Options list displays the
settings for all the ancestors of the node selected in the Project Tree.
3 If you want to edit an option, double-click the option in the Option list, or select it and
click Edit. Whenever you edit options in this manner, the modifications become local
overrides.
4 When you finish viewing your project’s option settings, choose Close.
Compiling projects
There are two basic ways to compile projects: build and make. Build compiles and links
all the nodes in a project, regardless of file dates. Make compares the time stamp of the
target with the time stamps of all the files used to build the target. Make then compiles
and links only those nodes necessary to bring the target up to date.
To compile a project, open the project using the Project|Open command, then choose
one Compile, Make All, or Build All from the Project menu (note that the SpeedBar has
three similar looking buttons that correspond to these Project Menu commands).
• Compile (Alt+F9) builds the code in the currently active Edit window. If a Project
window is selected, all the selected nodes in the project are translated; child nodes
aren’t translated unless they’re selected.
• Make All (F9) translates all the out-of-date nodes in a project. If a project is not open,
the file contained in the active Edit window buffer is built.
When you choose Make All, the Project Manager moves down the Project Tree until
it finds a node with no dependents. The Project Manager then compares that node’s
date and time against the date and time of the node’s parent. The Project Manager
translates the node only if the child node is newer than the parent node. The Project
Manager then moves up the Project Tree and checks the next node’s date and time. In
this way, the Project Manager recurses through the Project Tree, translating only
those nodes that have been updated since the last compile.
• Build All translates all nodes in a project—even if they are up-to-date. Build All
always starts at the project node and builds each successive target down the project.
Choose Cancel to stop a build.
When you choose Build All, the Project Manager starts at the first target and works
down the Project Tree until it comes to a node with no dependents. The Project
Manager compiles that node first (and other nodes on the same level), then works
back up the Project Tree, compiling and linking all the nodes needed to create the
target. This process is then repeated down the Project Tree, until all the targets have
been updated.
42 User’s Guide
or warning it encountered. By choosing Options|Environment|Preferences, you can
specify if old messages should be preserved or deleted between calls to different
programming tools (such as a compiler, GREP, or the resource compiler). Check Save
Old Messages if you want the Message window to retain its current listing of messages
when you run a tool.
To clear the Message window, choose Remove All Messages from the Message window
SpeedMenu.
Viewing errors
To view the code that caused a compiler error or warning, select the message in the
Message window; the IDE updates the Edit window so that it displays the location in
your code where the error or warning occurred (this is called Automatic Error
Tracking). If the file containing the error isn’t loaded in an Edit window, press Spacebar
to load the file (you can also load the file by pressing Alt+F10, then choosing View Source
from the SpeedMenu). When you view errors in this manner, the Message window
remains selected so you can navigate from message to message. To open or view the
Message window, click the button on the SpeedMenu, or choose View|Message.
Fixing errors
To edit the code associated with an error or warning, either
• Double-click the message in the Message window
• Select the message in the Message window and press Enter
• Press Alt+F10 and choose Edit Source from the SpeedMenu
The Edit window gains focus with the insertion point placed on the line and column in
your source code where the compiler detected the error. From here, edit your code to fix
the error. After fixing the error, press Alt+F7 to move to the next error message in the list
or press Alt+F8 to go back to the previous message.
Directories
Include searches the path (the drive specifier or path name of a subdirectory) for include
files. A drive specifier is a single letter, either uppercase or lowercase, followed by a
colon (:). A directory is any valid directory or directory path. You can specify multiple
drives and paths by separating the different entries with a semicolon (;). See “File-search
algorithms” for more information on searching.
File-search algorithms
Turbo C++ searches for files included in your source code with the #include directive in
the following ways:
• If you put an #include <somefile.h> statement in your source code, Turbo C++
searches for somefile.h only in the directories specified in the include path.
• If you put an #include "somefile.h" statement in your code, Turbo C++ first searches
for somefile.h in the current directory; if it doesn’t find the file there, it then searches
the directories specified in the include path.
However, if you specify a path and/or a directory, Turbo C++ searches only the
location specified. For example, the path C:\TCWIN45\INCLUDE indicates that the
included file #include <owl\owl.h> resides in the directory
\TCWIN45\INCLUDE\OWL, and not in \TCWIN45\INCLUDE or C:\OWL.
Library file search algorithms are similar to those for include files:
• Turbo C++ searches for implicit libraries in only the specified library directories; this
search algorithm is similar to the one used for #include <file.h> statements. Implicit
library files are the libraries that are automatically linked and the startup object file
C0x.OBJ. To see these files in the Project Manager, turn on run-time nodes (choose
Options|Environment|Project View then check Show Runtime Nodes).
• How Turbo C++ searches for explicit libraries depends in part on how you list the
library file (explicit library files are the .LIB files you list in your project file):
• If you list an explicit library without listing a drive or directory (like this:
mylib.lib), Turbo C++ first searches for the file in the directory containing the
project file. If it’s not found there, the search continues in the specified library
directories. This is similar to the search algorithm for #include “somefile.h”.
• If you list a drive and/or directory name with an explicit library (such as
c:\my_libs\mylib1.lib), Turbo C++ searches only the location specified with the
library file name; other directories are not searched.
Compiler
The compiler topic contains general compiler options, such as the debugging options,
the code generation options, and so on.
44 User’s Guide
Defines
The macro definition capability of Turbo C++ lets you define and undefine macros (also
called manifest or symbolic constants). The macros you define override those defined in
your source files. To define macros, type their definitions in the Defines input box under
the Defines page of the Compiler topic. To enter multiple define statements, separate
each entry with a semicolon (;). For example,
Switch1;Switch2;Switch3=OFF
Code generation
Allocate enums As ints allocates a two-byte int (16-bit) or four-byte int (32 bit) for
enumeration types. This option is on by default. Unchecked, this option allocates the
smallest variable size that can hold the enumeration values: the compiler allocates an
unsigned or signed char if the values of the enumeration are within the range of 0 to 255
(minimum) or –128 to 127 (maximum), or an unsigned or signed short if the values of
the enumeration are within 0 to 65,535 (minimum) or –32,768 to 32,767 (maximum).
The compiler allocates a two-byte int (16-bit) or a four-byte int (32-bit) to represent the
enumeration values if any value is out of range.
Unsigned Characters treats all char declarations as if they were unsigned char, which
provides compatibility with other compilers. Turbo C++ defaults char declarations to
signed.
Duplicate Strings Merged merges literal strings when one string matches another,
producing smaller programs but slightly longer compilation times. This option can
cause errors if one string is modified. This option is unchecked by default.
fastthis uses the _ _fastthis calling convention for passing the this pointer in a register
to member functions.
With fastthis enabled, the compiler expects member functions to pass their this pointer
in a register (or a register pair in large data models). Likewise, calls to member functions
will load the register (or register pair) with the this pointer.
You can enable fastthis using the fastthis option on the Compiler|Code Generation
topic. You can also use the language-specifier keyword _ _fastthis.
In the small data models, the this pointer is supplied in the SI register; large data models
use DS:SI. If necessary, the compiler saves and restores DS. All references in the member
function to member data are done via the SI register.
The names of member functions compiled with fastthis are mangled differently from
non-fastthis member functions, to prevent mixing the two. It’s easiest to compile all
classes with fastthis, but you can compile some classes with fastthis and some without.
None turns off the use of register variables.
Register Keyword specifies that Turbo C++ uses register variables only if you use the
register keyword and a register is available. You can use –rd in #pragma options. Use
this option to optimize the use of registers.
Floating Point
No Floating Point, when checked, specifies that the program contains no floating-point
calculations, so no floating-point libraries are linked. Unchecked, this option emulates
80x87 calls at run time.
Fast Floating Point optimizes floating-point operations without regard to explicit or
implicit type conversions. This option can provide answers faster than under the ANSI
operating mode. When this options is unchecked, it turns off the fast floating-point
option. When unchecked, the compiler follows strict ANSI rules regarding floating-
point conversions.
Compiler Output
Autodependency Information generates autodependency information. Modules
compiled with this option on can use MAKE’s autodependency feature. By default,
autodependency is turned on.
Generate Underscores automatically puts an underscore in front of identifiers before
saving them in the object module. Underscores for C and C++ identifiers are optional,
but are on by default. You can set them off; however, setting underscores off might
cause link errors when linking with the standard libraries.
Generate COMDEFs (C only) generates communal variables (COMDEFs) for global C
variables that are not initialized and not declared as static or extern. Use this option
when header files included in several source files contain declarations of global
variables. As long as a given variable doesn’t need to be initialized to a nonzero value,
you don’t need to include a definition for it in any of the source files. This option is
useful when you’re porting code that uses a similar feature with another
implementation.
Source
Nested Comments lets you nest comments in your source code. The default is off.
Identifier Length causes the compiler to recognize only the first n characters of
identifier names. All identifiers, whether variables, preprocessor macros, or structure
members, are treated as distinct when their first n characters are unique. Specifying n to
be 0 or greater than 249, or not specifying the option at all, sets the identifier length to
the default value.
By default, Turbo C++ uses 32 characters per identifier. Other systems, including some
UNIX compilers, ignore characters beyond the first eight. If you are porting to other
environments, you might want to compile your code with a smaller number of
significant characters; this helps you locate name conflicts in long identifiers that have
been truncated.
Borland Extensions uses Turbo C++ keywords. See the Programmer’s Guide for a
complete list of the Turbo C++ keywords.
46 User’s Guide
ANSI compiles ANSI-compatible code. Any non-ANSI keyword is ignored and can be
used as a normal identifier.
UNIX V uses only UNIX language-extension compliance.
Kernighan and Ritchie uses only Kernighan and Ritchie language compliance.
Debugging
These debugging options include debugging information in your generated .OBJ files.
In general, these options increase the size and compilation time of the files, but they
don’t affect the speed of the executable program. However, to link larger .OBJ files, turn
these options off. For information on debugging your applications, see Chapter 7; for
information on browsing, see Chapter 6.
Standard Stack Frame (on by default) generates a standard stack frame, which is useful
when using a debugger to trace through the stack of called subroutines. When turned
off, any function that doesn’t use local variables and has no parameters is compiled with
abbreviated entry and return code, which makes your code smaller and faster.
Test Stack Overflow generates stack overflow logic at the entry of each function. It
causes a stack overflow message to appear when a stack overflow is detected at run
time. This is costly in terms of both program size and speed but is provided as an option
because stack overflows can be very difficult to detect. If an overflow is detected, the
message Stack overflow! is printed and the program exits with an exit code of 1.
Out-of-line Inline Functions expands C++ inline functions inline. To control the
expansion of inline functions, this option acts slightly differently for C++ code: when
inline function expansion isn’t enabled, the function is generated and called like any
other function. Because debugging with inline expansion can be difficult, the command-
line compilers provide the following options:
• –v turns debugging on and inline expansion off.
• –v– turns debugging off and inline expansion on.
• –vi turns inline expansion off (no inline substitution will occur).
• –vi– turns inline expansion on.
For example, if you want to turn both debugging and inline expansion on, you must use
–v –vi–.
Line Numbers includes line number information in your .OBJ files for the integrated
debugger. Line numbers are a subset of debugging information. Although the Debug
Info In OBJs option automatically generates line number information, you can turn off
this option and turn on Line Numbers to reduce the size of the debug information
generated. With this setup, you can still step and trace, but you will not be able to watch
or inspect data items.
Debug Information In OBJs includes debugging information in .OBJ files so that you
can debug your programs with the integrated debugger. The compiler passes this
option to the linker so it can include the debugging information in the .EXE file. For
debugging, this option treats C++ inline functions as normal functions.
Browser Reference Information In OBJs generates additional Browse- specific
information such as definition location information and reference information.
Advanced Compiler
The following sections describe advanced compiler options.
Processor
80386 generates 16-bit 80386 protected-mode compatible instructions.
i486 generates 16-bit 80486 protected-mode compatible instructions.
Data Alignment Byte/Word align to n: 1 = Byte, 2 = Word (2-bytes). Word forces
integer-size and larger items to be aligned on a machine-word boundary. Extra bytes are
inserted in a structure to ensure member alignment. Automatic and global variables are
aligned properly. char and unsigned char variables and fields can be placed at any
address; all others are placed at an even-numbered address. Byte allows byte-wise
alignment. Word alignment increases the speed with which 80x86 processors fetch and
store data.
Calling Convention
C generates all subroutine and function calls using the C calling convention, which is
equivalent to declaring all subroutines and functions with the _ _cdecl keyword. The C
calling convention allows a function to accept a variable number of arguments from its
call. To specify that a function or subroutine should use another calling convention,
declare the function using either a _ _stdcall, _ _pascal, or _ _fastcall keyword.
Pascal generates all subroutine and function calls using the Pascal calling convention,
which is equivalent to declaring all subroutines and functions with the _ _pascal
keyword. The Pascal calling convention pushes arguments for left to right. The resulting
function calls are usually smaller and faster than they would be if compiled with the C
calling convention. The Pascal calling convention requires that functions pass the correct
number and type of arguments. Use the _ _cdecl, _ _stdcall, or _ _fastcall keywords to
specifically declare a different calling convention for a function or subroutine.
48 User’s Guide
Register generates all subroutine and function calls using the Register calling
convention, which is equivalent to declaring all subroutines and functions with the
_ _fastcall keyword. You can use the _ _stdcall, _ _pascal, or _ _cdecl keywords to
specifically declare a different calling convention for a function or subroutine.
Memory Model
Memory model options let you specify what memory model the compiler should use
when compiling applications. See the Programmer’s Guide, the DOS Reference, and Library
Reference for information on models.
Small compiles using the small memory model (the default).
Medium compiles using the medium memory model.
Compact compiles using the compact memory model.
Large compiles using the large memory model.
Default uses the model to determine if the stack segment is equal to the data segment.
Never assumes that the data segment is never equal to the stack segment, regardless of
the memory model.
The net effect of the Never option is actually very small. If you take the address of a
stack variable (parameter or auto), the default (when DS == SS) is to make the resulting
pointer a near (DS relative) pointer. This way, you can assign the address to a default-
sized pointer in those models without problems. When DS != SS, the pointer type
created when you take the address of a stack variable is an _ss pointer. This means that
the pointer can be freely assigned or passed to a far pointer or to a _ss pointer. But for
the memory models affected, assigning the address to a near or default-sized pointer
produces a “Suspicious pointer conversion” warning. Such warnings are usually errors,
and the warning defaults to on.
Always assumes that DS is equal to SS in all memory models; you can use it when
porting code originally written for an implementation that makes the stack part of the
data segment.
Put Constant Strings In Code Segments moves all string literals from the data segment
to the code segment of the generated object file, making the data type const. Using this
option saves data segment space. In large programs, especially those with a large
number of literal strings, this option shifts the burden from the data segment to the code
segment. This options works only with compact and large memory-model programs.
Far Virtual Tables causes virtual tables to be created in the code segment instead of the
data segment (unless changed using the Far Virtual Tables Segment and Far Virtual
Tables Class options), and makes virtual table pointers into full 32-bit pointers (the latter
is done automatically if you are using the huge memory model).
There are two primary reasons for using this option: to remove the virtual tables from
the data segment, which might be getting full, and to be able to share objects (of classes
with virtual functions) between modules that use different data segments (for example,
a DLL and an executable using that DLL). For all modules that can share objects, you
must compile either entirely with or entirely without this option. You can get the same
effect by using the huge or _export modifiers on a class-by-class basis.
50 User’s Guide
Far Data Group causes _ _far objects to be put into group name. By default, _ _far objects
aren’t put into a group. A name beginning with an asterisk (*) indicates that the default
string should be used.
Far Data Class changes the name of the class for _ _far objects to name. By default, the
name is FAR_DATA. A name beginning with an asterisk (*) indicates that the default
string should be used.
Far Virtual Tables Segment sets the name of the far virtual table segment to name. By
default, far virtual tables are generated in the code segment.
Far Virtual Tables Class sets the name of the far virtual table class segment to name. By
default, far virtual table classes are generated in the CODE segment.
Entry/Exit Code
Entry/Exit code options specify what type of application the compiler creates.
Windows All Functions Exportable creates a Windows object module with all far
functions exportable. This option creates the most general kind of Windows executable,
although not necessarily the most efficient. The default for this options is off. This option
generates the necessary overhead information for every far function, whether the
function needs it or not. It assumes that all functions are capable of being called by the
Windows kernel or by other modules.
This option creates a Windows .EXE function prolog/epilog for all far functions, then
sets up those functions to be called from another module. To actually export the
function address from the .EXE to a .DLL, the code includes a call to MakeProcInstance,
passing the resulting pointer to the .DLL requesting the address of the function. To
actually export the function address from the .DLL, function names need to be included
in the .DEF file of the executable.
Windows Explicit Functions Exported creates a Windows object module in which only
far functions declared as _export functions are exportable. Use this option if you have
functions that aren’t called by the Windows kernel. Windows Explicit Functions
Exported operates the same as Windows All Functions Exportable except that only
those functions marked with the _export keyword (and methods of classes marked as
_export) are given the extra prolog/epilog.
This option is far more efficient than Windows All Functions Exportable, because only
those functions called from outside the module get the overhead of the prolog. This
option does, however, require determining in advance which functions/classes need to
be exported. MakeProcInstance is still used, but no .DEF file manipulation is needed; if
C++ Options
The C++ options let you control the compiler’s interpretation of the C++ language.
Member Pointer
Honor Precision Of Member Pointers uses the declared precision for member pointer
types. Use this option when a pointer to a derived class is explicitly cast as a pointer-to-
member of a simpler base class (when the pointer is actually pointing to a derived class
member).
Support All Cases lets member pointers point to any members. Member pointers use
the most general (but not always the most efficient) representation.
Support Multiple Inheritance lets member pointers point to members of multiple
inheritance classes except members of virtual base classes.
52 User’s Guide
Support Single Inheritance lets member pointers point to members of single
inheritance classes only.
Smallest For Class uses the smallest representation that lets member pointers point to
all members of their class. If the class isn’t fully defined at the point where the member
pointer type is declared, the most general representation is chosen by the compiler (a
warning is issued).
C++ Compatibility
Do Not Treat ‘char’ As Distinct Type treats char as signed. Compatible with Turbo C++
3.1 and earlier.
Treat ‘far’ Classes As ‘huge’, causes classes that are declared __far to be treated as if
they were declared __huge. When enabled, it allows the following code to compile:
struct __huge A
{
virtual void f();
};
struct __far B : public A
{};
If this option is disabled, the compiler generates the error “Attempting to derive a far
class from the huge base ‘A.’
Virtual Tables
The Virtual Tables option controls the C++ virtual tables. It has the following settings:
Smart generates common C++ virtual tables and out-of-line inline functions across
modules within your application. As a result, only one instance of a given virtual table
or out-of-line inline function is included in the program. This produces the smallest and
most efficient executables, but produces .OBJ and .ASM files compatible with Turbo
C++ and TASM.
Local generates local virtual tables and out-of-line inline functions. As a result, each
module gets its own private copy of each virtual table and out-of-line inline function it
uses. This setting produces larger executable files than the Smart setting.
External creates external references to virtual tables. If you don’t want to use the Smart
or Local options, use the External and Public options to produce and reference global
virtual tables (see the Public option description that follows).
Public produces public definitions for virtual tables. When using the External or Public
options, at least one of the modules in the program must be compiled with the Public
option to supply the definitions for the virtual tables. All other modules should be
compiled with the External option to refer to that Public copy of the virtual tables.
Templates
For more information about templates, see the Programmer’s Guide.
Smart generates public definitions of all template instances. If more than one module
generates the same template instance, the linker merges them to produce a single copy
Exception handling/RTTI
Enable Exceptions enables C++ exception handling. If you implement C++ exception
handling in your code and compile with this option disabled, you’ll get an error.
Note that turning off this option turns off only the compilation of exception handling
code. Your application can still include exception code if it includes .OBJ and library
files that were built with exceptions enabled (such as the Borland standard libraries).
Enable Exception Location Information makes available run-time identification of
exceptions by providing the line numbers in the source code where the exception
occurred. This lets the program query the file and line number from where a C++
exception occurred.
Enable Destructor Cleanup calls destructors for all automatically declared objects
between the scope of the catch and throw statements when an exception is thrown. Note
that destructors aren’t automatically called for dynamic objects and dynamic objects
aren’t automatically freed.
Enable Fast Exception Prologs expands inline code for every exception handling
function. This option improves performance, but it increases the .EXE file size. Note that
if you select both this option and Enable Compatible Exceptions, fast prologs will not be
generated.
Enable Compatible Exceptions allows .EXEs and .DLLs built with Turbo C++ to be
compatible with .EXEs built with other products. When this option is enabled, some
exception handling information is included in the executible files (even if Enable
Exceptions is turned off), which could cause compatibility issues.
Enable Runtime Type Information generates code that allows run-time type
identification. In general, when Destructor Cleanup is enabled, Enable Runtime Type
Information must be enabled as well.
Messages
You can control the error and warning messages that are generated by the compiler
with the options listed under the Messages topic. Setting a message option causes the
compiler to generate the associated message or warning when the specific condition
arises. For information on the individual error messages, refer to the online Help from
the specific Message topic in the Project Options dialog box, and to Appendix C.
54 User’s Guide
All displays all warning messages.
Selected enables the aaa warning message typed at the command line or checked in the
IDE. Using the pragma warn in your source code overrides message options set either at
the command line or in the IDE. See the Programmer’s Guide for more information on
pragmas.
None represses the display warning messages. Errors are still displayed.
Stop After n Warnings stops compiling after n warnings occur in your project.
Stop After n Errors stops compiling after n errors occur in your project.
Linker
The IDE automatically links the files necessary to create the executable targets in your
project. The next few sections describe the linker options that are available from the
Project Options dialog box.
General
Case Sensitive Link makes the case significant in public and external symbols.
Case Sensitive Exports And Imports makes the case significant in the EXPORTS and
IMPORTS sections in module-definition files.
Include Debug Information selectively enables or disables debugging information on a
module-by-module basis.
Default Libraries ignores default libraries specified by some compilers. Use this option
when linking modules that are written in another language.
Pack Code Segments combines as many code segments as possible in one physical
segment up to (and never greater than) the code-segment packing limit. The linker starts
a new segment if it needs to. The default code-segment packing limit is 8,192 bytes (8K).
Code Pack Size. Use this setting to change the code-segment size, where n specifies the
number of bytes between 1 and 65,536. You would probably want the limit to be a
multiple of 4K under 386 enhanced mode because of the paging granularity of the
system.
Although the optimum segment size in 386 enhanced mode is 4K, the default code-
segment packing size is 8K because typical code segments are from 4K to 8K, and 8K
might pack more efficiently.
Because each maintained segment has some system overhead, code-segment packing
typically increases performance. Turn off code-segment packing if you’ve turned it on in
the configuration file and want to disable it for a particular link.
Warn Duplicate Symbol In .LIB warns you if a symbol appears in more than one object
or library file. If the symbol must be included in the program, the linker uses the symbol
definition from the first file containing the symbol that it encounters during the link.
With the Segments option, public symbols with no references are flagged “idle.” An idle
symbol is a publicly-defined symbol in a module that wasn’t referenced by an EXTDEF
record by any other module included in the link. For example, this fragment from the
public symbol section of a map file indicates that symbols Symbol1 and Symbol3 aren’t
referenced by the image being linked:
Publics tells the linker to create the same map file that the Segments option produces,
but the linker adds a list of public symbols at the end of the file; which is sorted
alphabetically as well as in increasing address order. This type of map file is helpful
when debugging.
Detailed creates a more complete map than the linker normally does by adding a list of
sorted public symbols to the map file. This kind of map file is useful in debugging.
Many debuggers can use the list of public symbols, which lets you refer to symbolic
addresses when you’re debugging.
Print Mangled Names In Map File puts mangled names in the map file; this can help
you identify how names are mangled. This option is provided because some utilities
require mangled names as input.
56 User’s Guide
Include Source Line Numbers creates a section in the .MAP file for source-code line
numbers. Linked .OBJ files must be compiled with debug information using the Line
Numbers of Include Debug Information options. If you use set the Map File option to
Off, this option has no effect.
Advanced Linker
Initialize Segments outputs uninitialized trailing segments into the executable file even
if the segments don’t contain data records. This option is normally not needed, and will
increase the size of your .EXE files.
Inhibit Optimizing Far Call To Near inhibits the optimization of far calls to near data.
When the linker packs two code segments together, and far calls are made from one to
the other, the linker optimizes the code by converting the far calls to near calls. This
option inhibits this optimization. This option is useful if you experience run-time
crashes that appear to be related to the corruption of the virtual tables. Because virtual
tables reside in the code segment, their contents can sometimes be interpreted by the
linker as one of these far calls.
Enable 32-bit Processing lets you link 32-bit modules produced by TASM or a
compatible assembler. This option requires more memory and slows down linking.
Segment Alignment specifies alignment for code and data within the executable file.
Use this option to change the current byte value on which to align segments. Valid
number values are the range of 2 to 65,535. The value entered is rounded up to the
nearest power of two (note that this is different than the File Alignment option). For
example, if you enter 650, it is rounded up to 1,024. The operating system seeks pages
for loading based on this alignment value. The default value is 512.
Discard Nonresident Name Table causes the linker to not emit the nonresident names
table. The resultant image will contain only the module description in the nonresident
names table (see the following note for usage).
Transfer Resident Names To Nonresident Names Table causes the linker to copy all
names in the resident names table which have not been specified as RESIDENTNAME
in the .DEF file to the nonresident names table. The resultant image contains only the
module name and the symbol names those exported symbols that were specified as
RESIDENTNAME in the .DEF file.
When specifying this switch, you must also specify the WEP entry point as a
RESIDENTNAME in the EXPORTS section of the .DEF file—Windows obtains the WEP
entry point for this symbol by looking it up in the resident names table.
Note When building .DLLs that contain many exports, it’s possible to exceed the 64K header
file limitation. Because the .DLL contains the resident names table its the header,
moving the exports out of the header using the Transfer Resident Names to Nonresident
Names Table option usually remedies this problem. Names in the nonresident names
table are assigned ordinal numbers, which your .EXE file uses when referencing the
entry points in the .DLL. There are two ways to create input files for the linker:
• Run IMPLIB on the .DLL to create an import library for linking purposes.
• Run IMPDEF on the .DLL to create a .DEF file for linking purposes.
Option defaults
When you create a new project, the Project Manager assigns the project the Default Style
Options Style Sheet. The following table shows the default IDE options:
Table 3.1 Default Project Option settings
Option
Compiler | Defines
Compiler | Code Generation | Allocate enums As ints
Compiler | Code Generation | Register Variables: Automatic
Compiler | Floating Point | Fast Floating Point
Compiler | Compiler Output | Autodependency Information
Compiler | Compiler Output | Generate Underscores
Compiler | Source | Borland Extensions
Compiler | Debugging | Standard Stack Frame
Compiler | Debugging |Debug Information In OBJs
Compiler | Debugging |Browser Reference Information In OBJs
Compiler | Precompiled Headers | Generate And Use
58 User’s Guide
Table 3.1 Default Project Option settings (continued)
Option
Advanced Compiler | Processor | Instruction Set: 80386
Advanced Compiler | Processor | Data Alignment: Byte
Advanced Compiler | Calling Convention | C
Advanced Compiler | Memory Model | Large
Advanced Compiler | Entry/Exit Code | Windows smart callbacks, All Functions Exportable
C++ Options | Member Pointer | Member Pointer Representation: Support All Cases
C++ Options | C++ Compatibility | Virtual Base Pointers: Always Near
C++ Options | Virtual Tables | Linkage: Smart
C++ Options | Templates | Instance Generation: Smart
C++ Options | Exception Handling/RTTI | Enable Exceptions
C++ Options | Exception Handling/RTTI | Enable Destructor Cleanup
C++ Options | Exception Handling/RTTI | Enable Runtime Type Information
Messages (see “Messages” on page 54 for default Message information)
Linker | General | Case Sensitive Link
Linker | General | Case Sensitive Exports And Imports
Linker | General | Include Debug Information
Linker | General | Default Libraries
Linker | General | Pack Code Segments (Code Pack Size 8192)
Linker | Map File | Off
Linker | Map File | Include Source Line Numbers
Make | Break Make On: Errors
Make | Autodependencies: Cache
62 User’s Guide
commands to expand and contract the list of topics. For online help on any of the
options or topics, choose Help.
Figure 4.1 AppExpert Application Generation Options dialog box
4 Select the Application topic, then make the following settings in the Summary
options:
• Set the Window Model to SDI (Single Document Interface).
• Uncheck Document/View.
• Uncheck all Features To Include (Toolbar, Status Line, Drag/Drop, and Printing).
These options settings specify a very simple application. For more information on the
available application settings, see “AppExpert options reference” on page 68.
5 Select the Application|Basic Options topic, then capitalize the Target Name so it
reads “Draw.”
6 Select the Application|Admin Options topic, then change the Description setting to
read “Sample ObjectWindows Program.”
7 Complete the Author and Company text fields.
8 Select the Main Window topic, and set the Window Title to “Sample ObjectWindows
Program.”
9 Select the Main Window|SDI Client topic, then set the Client/View Class to TWindow
(choose this selection from the drop-down list).
10 Choose Generate to have AppExpert create the application.
A dialog box appears asking you to confirm your command. Choose Yes to have
AppExpert generate the files for your application. (Choose No if you need to modify
you option settings.)
A message box displays as AppExpert generates the source modules, header files,
resource files and the project file for your application. AppExpert places the files in
the directory that you specified in the Base Directory setting of Application|Basic
Options.
64 User’s Guide
Figure 4.2 DRAW.IDE loaded into the Project Manager
//{{..._BEGIN}}
ƒ
//{{..._END}}
These two types of comments are ClassExpert comment records which are used by
Rescan. These comments must be left in place if you plan to use ClassExpert to help you
modify your project source code. While you cannot modify lines of code that begin with
\\{{, you can add lines of code between the _BEGIN and _END comment records as long as
you duplicate the format of the generated code that’s in between these comment records.
In the header files listed at the top of DRAWAPP.CPP, you’ll notice a line of code that
includes the file drawapp.h. In this header file, AppExpert defines a class for the main
window, SDIDecFrame. Also in drawapp.h is the class declaration for your application
object:
ƒ
//{{TApplication = DrawApp}}
class DrawApp : public TApplication {
private:
ƒ
//
// Build a response table for all messages/commands handled
// by the application.
//
DEFINE_RESPONSE_TABLE1(DrawApp, TApplication)
//{{DrawAppRSP_TBL_BEGIN}}
EV_COMMAND(CM_FILENEW, CmFileNew),
EV_COMMAND(CM_FILEOPEN, CmFileOpen),
EV_COMMAND(CM_FILECLOSE, CmFileClose),
EV_COMMAND(CM_HELPABOUT, CmHelpAbout),
//{{DrawAppRSP_TBL_END}}
END_RESPONSE_TABLE;
ƒ
Next is the definition of the DrawApp constructor. This constructor initializes a data
structure that’s used in all file-based dialog boxes (for example, dialog boxes that open
or save files).
ƒ
//////////////////////////////////////////////////////////
// DrawApp
// =====
//
DrawApp::DrawApp () : TApplication("Sample ObjectWindows Program")
{
// Common file file flags and filters for Open/Save As dialogs. Filename and
// directory are computed in the member functions CmFileOpen, and CmFileSaveAs.
FileData.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
FileData.SetFilter("All Files (*.*)|*.*|");
}
ƒ
Notice the comment regarding the placement of user-added code. AppExpert places
similar comments in many of the functions it defines. In general, you should add code at
these comment locations to complete the functionality of your application. If the need
arises, you can add code outside of these predescribed areas; however, you should
avoid modifying any of the code generated by the IDE Experts.
The DrawApp destructor is simply a place holder. The next code of interest is the
InitMainWindow function definition. Primarily, this function instantiates the
66 User’s Guide
SDIDecFrame class and sets the instance to be the application’s main window. The call to
the constructor for SDIDecFrame passes a zero as the client window pointer.
ƒ
DrawApp::~DrawApp ()
{
// INSERT>> Your destructor code here.
}
//////////////////////////////////////////////////////////
// DrawApp
// =====
// Application intialization.
//
void DrawApp::InitMainWindow ()
{
SDIDecFrame::~SDIDecFrame ()
{
// INSERT>> Your destructor code here.
}
ƒ
Application
The options under this topic control the general look and feel of your application.
MDI (Multiple Document Interface) sets the style of your application to the multiple-
document interface model, which lets you have a number of objects open at the same
time. In this model, a single object can be simultaneously presented by different views,
different objects can be presented by the same view class, or different objects can be
presented by entirely different views. The Turbo C++ IDE is an example of an MDI
application.
SDI (Single Document Interface) sets the style of your application to the single
document-interface model. This model lets you open only one object at a time. If you
open a new object while another is already open, the document manager attempts to
close the first object before opening the new one. The Notepad is an example if an SDI
application.
Dialog Client generates an application that uses a dialog box as the main user interface.
In this model, the client window is a dialog box. The Turbo Debugger TDWINI.EXE
utility is an example of a Dialog Client application.
Document/View check box determines whether your application supports the
Document/View model for handling application objects. The “document” is the data
and the “view” is the user interface to the data. In a Document/View model, these two
are separate (see the ObjectWindows Programmer’s Guide for more information on
Document/View). You can use this option with either MDI, SDI, or Dialog Client
applications.
Toolbar places a toolbar at the top of the main window of your application.
Status Line places a status bar at the bottom of the main window of your application
and generates code to display help hints in the status line when menu and toolbar items
are highlighted.
Drag/Drop supports Windows standard drag-and-drop actions.
Printing supports printing-related activities, and creates the File menu commands Print
Setup, Print Preview, and Print.
Basic Options
The Basic Options settings let you specify where generated code is stored, whether to
include online Help support, the startup state of your application, and the type of
controls you want to use.
68 User’s Guide
Target Name defines the name of the project and sets the base name for the other files in
your project (header files, class database, application class, and source files names are
based on the name in this field).
Base Directory sets the base directory path for your project. All paths in the project are
relative to this directory. You can choose a directory by typing it yourself, or by selecting
one with Browse. The name of this directory is passed to the Project Manager for the
new AppExpert target. The default value for this field is taken from your entry in the
New AppExpert Project dialog box. If you add an AppExpert target to an existing
project, the default value for Base Directory is taken from the existing project. If you
specify a new directory in this field, AppExpert creates the directory.
Include Help File Support, when checked, causes AppExpert to generate Help source
files (.RTF) and a Help project file (.HPJ). The Help project file is added to the Project
Manager project and automatically built with the target application. The Help source
file contains placeholder text for the menu items in the application.
Help File Name names the help files (.HLP and .HPJ) associated with your application.
The Application Startup State radio buttons specify the initial state of the application’s
main window, as follows:
• Normal (Sizeable) (default) specifies that the program starts in the default size
defined by WS_NORMAL.
• Minimized (Iconic) starts your application as an icon on the Windows desktop.
• Maximized (Entire Screen) starts your program filling the entire Windows desktop.
The Control Style radio buttons specify which type of controls the application uses:
• Standard Windows (default) uses standard Windows controls.
• Borland BWCC uses the Borland Windows Custom Controls.
• MS Control 3D uses the three-dimensional Windows controls.
OLE 2 Options
The OLE 2 Options specify the level of OLE 2 support you want with your application.
Use the following OLE 2 Container options to specify whether you want to generate an
OLE 2 container application:
Application Is Not An OLE 2 Container (default) specifies that your application is not
an OLE 2 container.
Application Is An OLE 2 Container specifies that your application is an OLE 2
container.
Use the following OLE 2 Server Options to specify the type of OLE 2 server application
you want to generate:
Application Is Not An OLE 2 Server (default) specifies that the application is not an
OLE 2 server.
Application Is An OLE 2 Server DLL specifies a .DLL OLE 2 server.
Admin Options
Admin Options define general information about the application. Some of this
information is placed in a comment block at the beginning of the files generated by
AppExpert. In addition, AppExpert uses some of the information in the application’s
Help|About dialog box.
Version Number sets the project version number that displays in the Help|About
dialog box (the default version number is “1.0”). This information is stored in the .RC
file for your project.
Copyright defines the copyright information that displays in the Help|About dialog
box.
70 User’s Guide
Description describes the application and displays the text in the application’s Help|
About dialog box. The default value is the project name.
Author names the programmer(s) who generate the source code and is used to
comment the generated code.
Company names the programmers’ company and is used to comment the generated
code.
Main Window
Main Window options control the features and type of your application’s main
window.
Window Title names the text for the title bar of the application’s main window.
Background Color sets the background color of the application’s main window; click
Set Background Color to select a color.
Basic Options
Basic Options control the general appearance of the application’s main window. The
Window Styles check boxes control the appearance of the non-client areas of your
application’s main window. See CreateWindow in the API online Help for more
information.
Caption creates a single, thin border and a title bar where a caption can be displayed.
Border puts a single, thin border without a title bar around the main window.
Max Box adds a maximize box to the right of the main window title bar. This option is
relevant only if the Caption option is on.
Min Box adds a minimize box to the right of the main window title bar. This option is
relevant only if the Caption option is on.
Vertical Scroll adds a vertical scroll bar to the right of the main window.
Horizontal Scroll adds a horizontal scroll bar at the bottom of the main window.
System Menu adds a control-menu box to the left of the main window title bar. This
option is relevant only if the Caption option is on.
Visible makes the main window visible at startup. When Visible is off, the WS_VISIBLE
style is changed to NOT WS_VISIBLE.
Disabled disables the main window at startup (the application displays as an icon when
started).
Thick Frame puts a double border on the main window and makes the main window
resizable.
Clip Siblings protects the siblings of the child windows. Painting is restricted to that
window (see WS_CLIPSIBLINGS in the API online Help).
Clip Children protects child windows from being painted over by the application’s
main window (see WS_CLIPCHILDREN in the API online Help).
Document Class (TFileDocument by default) names the class of the default document
(available only if Document/View is on).
Description describes the class of files associated with the Document/View. The default
value is All Files (*.*).
Filters (*.* by default) lets you specify the file specifications of the files you want the
application to recognize. You can specify multiple files (separate the entries with
semicolons) and use wildcards for file masks. These values are passed to the Windows
common-file dialog boxes, and define the file filters they display.
Default Extension is the default file-name extension that is passed to Windows
common-file dialog boxes where it is added to file names when no extension is given. It
is also used as the default extension in the File|Open and File|Save dialog boxes.
Note The Description, Filters, and Default Extension settings affect only the File|Open and
File|Save dialog boxes of the application.
Class Name is the name that AppExpert uses for the class that represents the client area
of the SDI frame window. By default, AppExpert names this class
<TargetName><ClientClass>. AppExpert derives this class from the class specified in the
Client/View Class text box.
Source File is the name of the source file that implements the class named in the Client/
View Class text box. AppExpert names this file <TargetName><ClientClass>.CPP by
default (if needed, AppExpert shortens the project name to limit the file name to eight
characters).
Header File is the name of the header file that defines the class named in the Client/
View Class text box. AppExpert names this file <TargetName><ClientClass>.h by default
(if needed, AppExpert shortens the project name to limit the file name to eight
characters).
MDI Client
The MDI Client settings define the client window class of a multiple-document interface
frame. (An MDI application displays most of its data in the client windows of the MDI
72 User’s Guide
child. See the following section “MDI Child/View” for more information.) These
options are relevant only if you choose the MDI setting of the Application|Basic
Options topic.
Client Class specifies the name that AppExpert uses for the class derived from
TMDIClient, which represents the client area of the MDI frame window. By default,
AppExpert names this class <TargetName>MDIClient.
Source File names the source file that stores the implementation of the class named in
Client Class. The default value is <ClientClass>. CPP. If needed, AppExpert shortens the
file name to eight characters.
Header File names the header file that stores the definition of the class named in Client
Class. The default value is <ClientClass>.h. If needed, AppExpert shortens the file name
to eight characters.
Dialog Client
Dialog Client options describe the class that defines the client window of the main
dialog box of your application.
Client Class specifies the name that AppExpert uses for the class derived from
TMDIClient that represents the client area of the dialog frame window. The default
value is <TargetName>TDLGClient.
Source File names the source file that stores the implementation of the class named in
Client Class. The default value is <ClientClass>TDLGC.CPP. If needed, AppExpert
shortens the file name to eight characters.
Header File names the header file that stores the definition of the class named in Client
Class. The default value is <ClientClass>tdlgc.h. If needed, AppExpert shortens the file
name to eight characters.
Dialog ID specifies the identifier of the dialog box that functions as the main window of
your application.
Include A Menu Bar specifies if you want a menu bar on the main window of your
application.
MDI Child/View
MDI Child/View options define the class for child window or Document/View
(available if MDI and Document/View from Application Model settings are selected).
MDI Child Class names the class derived from TMDIChild that represents the frame of
the default MDI child windows. The default name is <TargetName>MDIChild.
Source File is the source file that stores the implementation of the class named in MDI
Child Class. The default value is <MDIChild>1.CPP. If needed, AppExpert shortens the
file name to eight characters.
Header File is the header file that stores the definition of the class named in MDI Child
Class. The default value is <MDIChild>1.h. If needed, AppExpert shortens the file name
to eight characters.
74 User’s Guide
Chapter
Starting ClassExpert
To start ClassExpert, choose Project|Open Project, then open a project that was
generated by AppExpert. Then, double-click the target node of your AppExpert project
(ClassExpert is the default viewer for AppExpert targets) or choose View|ClassExpert.
ClassExpert appears, listing the classes and their implementation for your application.
Figure 5.1 ClassExpert
Events pane
Classes pane
Edit pane
Classes pane
The Classes pane lists the set of classes that ClassExpert manages for the currently
selected AppExpert target in the Project Manager. ClassExpert manages all classes
generated by AppExpert, and any classes that you have been added with ClassExpert.
Information displayed in the Events and Edit panes depends on the class you select in
the Classes pane. To display the class constructor source code in the Edit pane, double-
click a class in the Classes pane.
Use the Classes pane SpeedMenu (right-click the Classes pane) to add classes, automate
a class, view class options, associate document classes with view classes, view and
modify the class source code or header file, and start Resource Workshop (by choosing
Edit Dialog or Edit Menu). See online Help for details on the Classes pane SpeedMenu
commands.
Events pane
The Events pane lists Windows messages, command and control notifications, virtual
functions, and automations of the class selected in the Classes pane. The actual list
depends upon the derivation (the base class) of the selected class.
Use the Events pane SpeedMenu (right-click the Events pane) to add or delete event
handlers, virtual functions, and instance variables. You can also start Resource
Workshop with the Edit Menu and Edit Dialog commands. See online Help for details
on the Events pane SpeedMenu commands.
Edit pane
The Edit pane is an editor that displays the source file associated with the class that you
select in the Classes pane. The Edit pane works the same as the IDE editor, except you
can’t split panes or open other files in the Edit pane. If you customize the IDE editor,
those changes are also reflected in the Edit pane.
Use the Edit pane SpeedMenu (right-click the Edit pane) to access frequently used
ClassExpert commands, such as opening source files, browsing object, setting
breakpoints, and so on. A special Edit Pane SpeedMenu command, Use Class, causes
ClassExpert to generate the code that instantiates a new class that you’ve added to your
application. See online Help for details on the Edit pane SpeedMenu commands. You
can also use the IDEs Edit menu to access additional edit commands.
Adding a class
ClassExpert lets you add ObjectWindows-based classes and supports one level of
inheritance. If you need to add more derivations, you must do so manually.
76 User’s Guide
To add a class,
1 Open the Classes SpeedMenu by right-clicking the pane.
2 Choose Add New Class, or click the SpeedBar button. The Add New Class dialog box
appears.
Figure 5.2 Add New Class dialog box
78 User’s Guide
• dtReadOnly checks the read-only check box when the dialog box is created.
• dtOverWritePrompt asks users if it’s OK to overwrite an existing file when they use
the Save As dialog box.
• dtHideReadOnly hides the read-only check box.
• dtPathMustExist lets the user type only existing paths.
• dtFileMustExist lets the user type only existing file names.
• dtCreatePrompt prompts the user before creating a new document.
• dtNoReadOnly returns the specified file as writable.
8 Click Add to add the document type to your application (this updates a data
structure in the main source file that describes all available document types). The
Document/View appears in the list of existing types.
9 Repeat steps 1–8 for any additional document types you want to add. When you’re
finished, choose Close to return to ClassExpert.
80 User’s Guide
Jumping to class source code
To view the source code for a class, select the class in the Classes pane (click the class
name once). The code appears in the Edit pane. If you move the insertion point in the
Edit pane, ClassExpert remembers the position the next time you select the class.
To move the insertion point to the class constructor code, double-click the class name in
the Classes pane. To jump to a handled event, double-click the event in the Events pane.
You can also view the source file or its header file in an IDE editor:
1 Right-click a class in the Classes pane to open the SpeedMenu.
2 Choose Edit Source to view the source .CPP file for the class constructor, or choose
Edit Header to view the header file where the class is defined.
Using Rescan
Rescan is a special project tool that examines the source code listed in the .IDE file of
your AppExpert project and updates or rebuilds the project database (the .APX file)
according to what it finds in the source code. Rescan looks for special markers in the
source code to reconstruct the .APX database file and then starts Resource Workshop to
reconstruct information about project resources. If Rescan is successful, the original
project database file is renamed to *.~AP and a new database file is created; otherwise,
the original database is left as *.APX.
You can use Rescan to
• Delete a class
• Move a class from one source file to another
• Rename a class, handler, instance variable, or dialog ID
• Import a class from another project
• Rebuild a lost or damaged project database (*.APX) file
Deleting a class
To delete a class,
1 Remove the class source node from the project by right-clicking the node in the
Project Manager, then choosing Delete Node. If the class shares a source file with
other classes, delete the code related to the class from the source file, then delete
references to the class from the other source files.
2 Right-click the AppExpert target in the Project Manager, then choose Special|Rescan.
Rescan scans the source files listed as dependencies for the AppExpert target.
Resource Workshop scans and updates the resource files. When Rescan is complete,
you’ll return to the updated project file where you can either build your application
or use. You can add the deleted class to the project by adding the class source file as a
dependent of the target, then rescanning.
Moving a class
To move a class from one source file to another,
1 Move (cut and paste) the source code of the class to the new file. If the new file isn’t in
the project as a node under the target, add the node to the project. If the moved class
was its own source file, you can delete that empty source file from the project.
2 Right-click the target in the Project Manager, then select Special|Rescan. When
Rescan finishes, it returns you to the Project window in the IDE.
82 User’s Guide
Renaming an element
To rename a class, an event handler, an instance variable, or a dialog ID,
1 Use the IDE editor to search and replace all occurrences of the original name with the
new name. Be sure to check all source files associated with the project (.CPP, .h, .RC,
and .RH files).
2 From the Project Manager, right-click the target node, then choose Special|Rescan.
When Rescan completes, it returns you to the Project Manager.
Note After renaming an element, verify that the #include, #ifdef, and #define statements
generated by AppExpert are still valid. These statements can become corrupted as
ClassExpert searches and replaces the class names within your source files.
Importing a class
To import a class from one project to another,
1 Move or copy the source and header file that defines the class to the source and
header directory of the new project. All source files for a project must be in the
project’s source directory (.CPP files) or header directory (.h files). These directories
were created when you first generated the AppExpert project.
2 Add the class source file as a dependent node under the target in the IDE project (use
Add node from the SpeedMenu).
3 Add the header file that contains the class definition as a dependent node under the
class source file in the AppExpert project (use Add Node from the SpeedMenu).
4 In the Project window, right-click the AppExpert target, then choose Special|Rescan.
To see more information on a particular object, double-click it. If you aren’t using a
mouse, select the object by using your arrow keys and press Enter.
86 User’s Guide
Figure 6.2 Symbol declaration window
You can also browse any symbol in your code without viewing object hierarchies or lists
of symbols first. Choose from these methods:
• Highlight the symbol in your code and choose Search|Browse Symbol.
• Click the right mouse button or press Alt+F10 when an Edit window is selected to
display the SpeedMenu, then choose Browse Symbol.
The Filters matrix has a column for each letter. Click the top or bottom row to turn on
and off the display of that particular item (a letter in the top row means the browser
shows symbols with that identification; a letter on the bottom means the browser
excludes symbols with that identification). For example, to remove all the variables
displayed in the currently selected object, click the bottom cell in the V column to move
the V to the bottom of the Filters matrix.
88 User’s Guide
Chapter
Types of bugs
The integrated debugger can help find two basic types of programming errors: run-time
errors and logic errors.
Run-time errors
If your program successfully compiles, but fails when you run it, you’ve encountered a
run-time error. Your program contains valid statements, but the statements cause errors
when they’re executed. For example, your program might be trying to open a
nonexistent file, or it might be trying to divide a number by zero. The operating system
detects run-time errors and stops your program execution if such an error is
encountered.
Without a debugger, run-time errors can be difficult to locate because the compiler
doesn’t tell you where the error is located in your source code. Often, the only clue you
have to work with is where your program failed and the error message generated by the
run-time error.
Logic errors
Logic errors are errors in design and implementation of your program. Your program
statements are valid (they do something), but the actions they perform are not the actions
you had in mind when you wrote the code. For instance, logic errors can occur when
variables contain incorrect values, when graphic images don’t look right, or when the
output of your program is incorrect.
Logic errors are often the most difficult type of errors to find because they can show up
in places you might not expect. To be sure your program works as designed, you must
thoroughly test all of its aspects. Only by scrutinizing each portion of the user interface
and output of your program can you be sure that its behavior corresponds to its design.
As with run-time errors, the integrated debugger helps you locate logic errors by letting
you monitor the values of your program variables and data objects as your program
executes.
90 User’s Guide
Compiling with debug information
Before you can begin a debugging session, you must compile your project with symbolic
debug information. Symbolic debug information, contained in a symbol table, enables the
debugger to make connections between your program’s source code and the machine
code that’s generated by the compiler. This lets you view the actual source code of your
program while running the program through the debugger.
To generate symbolic debug information for your project,
1 In the Project window, select the project node.
2 Choose Options|Project to open the Project Options dialog box.
3 From the Compiler|Debugging topic, check Debug Information In OBJs to include
debug information in your project .OBJ files. (This option is checked by default.)
4 From the Linker|General topic, check Include Debug Information. This option
transfers the symbolic debug information contained in your .OBJ files to the final
.EXE file (this option is checked by default).
Adding debug information to your files increases their file size. Because of this, you’ll
want to include debug information in your files only during the development stage of
your project. Once your program is fully debugged, compile your program without
debug information to reduce the final .EXE file size.
Note Not all of the .OBJ files in your project need symbolic debug information—only those
modules you need to debug must contain a symbol table. However, since you can’t step
into a module that doesn’t contain debug information, it’s best to compile all your
modules with a minimum of line number debug information during the development
stages of your project (see page 47 for information on debugging options).
92 User’s Guide
When you run to the cursor, your program executes at full speed until the execution
reaches the location marked by the text cursor in the Edit window. When the execution
encounters the code marked by the text cursor, the debugger regains control and places
the execution point on that line of code.
Trace Into
The Trace Into command executes a single program statement at a time. If the execution
point is located on a call to a function that was compiled with debugging information,
Trace Into causes the debugger to step into that function by placing the execution point
on the function’s first statement. However, if the execution point is located on a function
call that doesn’t contain debugging information (a library function, for example), then
Trace Into runs that function at full speed, after which the execution point is positioned
on the statement following the function call.
If the execution point is located on the last statement of a function, Trace Into causes the
debugger to return from the function, placing the execution point on the line of code
that follows the function call.
The term single stepping refers to using Trace Into to successively run though the
statements in your program code. To choose Trace Into, either
• Click the Trace Into SpeedBar button.
• Choose Debug|Trace Into.
• Press F7.
Step Over
The Step Over command, like Trace Into, lets you execute program statements one at a
time. However, if you issue the Step Over command when the execution point is located
on a function call, the debugger runs that function at full speed (instead of tracing into
it), then positions the execution point on the statement that follows the function call.
You can choose Step Over in the following ways,
• Click the Step Over button on the SpeedBar.
• Choose Debug|Step Over.
94 User’s Guide
• Press F8.
For example, in the previous bubble sort code, choosing Debug|Step Over while the
execution point highlights the function call order causes the debugger run order at full
speed. The debugger then places the execution point on the statement following the
function call, which in this case is the second for statement in bubble.
As you debug, you can choose to trace into some functions and step over others. If you
know a function performs as it was designed, you can step over calls to that function
with confidence that the function call will not cause an error. If, on the other hand, you
aren’t sure that a function is well behaved, you can choose to trace into the function to
verify that it works as designed.
Running to a breakpoint
You set breakpoints on lines of source code where you want the program execution to
pause during a run. Running to a breakpoint is similar to running to a cursor position, in
that the program runs at full speed until it reaches a certain source-code location.
However, unlike Run To Cursor, you can have multiple breakpoints in your code and
you can customize each one so it pauses the program’s execution only when a specified
condition is met. For more information on breakpoints, see “Using breakpoints” on
page 96.
Using breakpoints
You use breakpoints to pause your program execution at designated source code
locations during a debugging session. By setting breakpoints in potential problem areas
of your source code, you can run your program at full speed, knowing that its execution
will pause at a location you want to debug. When your program execution encounters a
breakpoint, the program pauses (before executing the line containing the breakpoint)
and the debugger displays the breakpoint line in the Edit window. You can then use the
debugger to view the state of your program.
Setting breakpoints
Breakpoints are flexible in that they can be set before you begin to run a program, or at
any time that the integrated debugger has control. For a breakpoint to be valid, it must
be set on an executable line of code (see “Invalid breakpoints” later in this section for
details).
To set a breakpoint, select the line of code in the Edit window where you want the
breakpoint set, then do one of the following:
• Click the Set Or Clear An Unconditional Breakpoint SpeedBar button.
• Press F5.
• Choose Toggle Breakpoint from the SpeedMenu.
• Choose Debug|Add Breakpoint, then choose OK in the Breakpoint Properties dialog
box to confirm the breakpoint setting.
Alternately, if you know the line of code where you want the breakpoint set, choose
Debug|Add Breakpoint and type the source-code file name and line number into the
Breakpoint Properties dialog box. When the settings in the Breakpoint Properties dialog
box are correct, choose OK to complete the breakpoint entry.
When the breakpoint is set, the line it is set on becomes highlighted.
96 User’s Guide
Invalid breakpoints
If a breakpoint is not placed on an executable line of code, the debugger considers it
invalid. For example, a breakpoint set on a comment, a blank line, or declaration is
invalid. If you set an invalid breakpoint, the debugger displays the Invalid Breakpoint
error box when you attempt to run the program. To fix the situation, close the error box
and delete the invalid breakpoint from the Breakpoints window. You can then reset the
breakpoint in the intended location. However, you can also ignore invalid breakpoints;
the IDE disables any invalid breakpoints when you run your program.
The Breakpoints window lets you view and maintain all your breakpoints; you don’t
need to search through your source files to find the breakpoints you’ve set. Also, using
the commands on the Breakpoints window SpeedMenu, you can view the code at any
breakpoint location.
Deleting breakpoints
When you no longer need to examine the code at a breakpoint location, you can delete
the breakpoint from the debugging session. You can delete breakpoints using either the
Edit window or the Breakpoints window:
• From the Edit window, place the insertion bar on the line containing the breakpoint,
the press F5 (or choose Toggle Breakpoint from the SpeedMenu).
• From the Breakpoints window, highlight the breakpoint you want removed, and
choose the Delete Breakpoint command from the SpeedMenu. You can also delete all
current breakpoints by choosing Delete All Breakpoints from the SpeedMenu.
98 User’s Guide
Creating conditional breakpoints
When you first set a breakpoint, by default the debugger pauses the program execution
each time the breakpoint is encountered. However, using the Breakpoint Properties
dialog box, you can customize your breakpoints so that they activate only when a
specified set of conditions is met.
The integrated debugger lets you add two types of conditions to your breakpoints:
• Boolean expressions
• Pass counts
Logging expressions
You can choose to have the value of a specified expression written to the Event Log
window each time a breakpoint is reached:
1 Select Log Expression in the Breakpoint Properties dialog box.
2 In the Expression To Log text box, type the expression you want evaluated.
For example, if you type my_array[y] into the Expression To Log text box, the debugger
writes the value of that expression to the Event Log window when the breakpoint
activates (in this case, the value contained in the array element y is written to the log).
For more information about the Event Log window, see “Sending messages to the Event
Log window” on page 108.
Watching expressions
You use watches to monitor the changing values of variables or expressions during your
program run. After you enter a watch expression, the Watch window displays the
current value of the expression. Each time your program pauses (such as when it
encounters a breakpoint), the value of the watch changes to reflect the current value of
the expression according to the values of the variables in your program.
To open the Watch window, choose View|Watch.
Figure 7.3 The Watch window
If the execution point moves to a location where any of the variables in the watch
expression are undefined, then the entire watch expression becomes undefined. If the
execution point returns to a location where the watch expression can be evaluated, then
the Watch window again displays the current value of the watch expression.
The easiest way to set a watch is from the Edit window. Highlight the expression you
want to monitor, then choose Set Watch from the Edit window SpeedMenu to add the
expression to the Watch window.
You can also create a watch using the following method:
1 Open the Watch Properties dialog box using one of these commands:
• Debug|Add Watch
• Set Watch on the Edit window SpeedMenu
• Ctrl+F5
Note You can also open the Watch Properties dialog box by double-clicking a watch in the
Watch window, or by selecting a watch in the Watch window and choosing the
SpeedMenu Edit command.
Disabling a watch
If you prefer not to watch an expression that you’ve entered in the Watch window, but
you don’t want to delete it because you might need to use it later, you can disable the
watch. Disabling watches will speed up the response of the debugger because it won’t
have to monitor the watch as you step or run through your program.
Deleting a watch
To delete a watch expression, select the expression in the Watch window and choose
Delete Watch from the SpeedMenu.You can also delete all the watches by choosing
Delete All Watches from the SpeedMenu.
Note These commands cannot be reversed.
Evaluating expressions
Choose Debug|Evaluate/Modify to open the Expression Evaluator dialog box. By
default, the token at the cursor position in the current Edit window is placed in the
Expression text box. You can accept or modify this expression, enter another one, or
choose an expression from the history list of expressions you’ve previously evaluated.
Figure 7.5 The Expression Evaluator dialog box
To evaluate the expression, click the Eval button. Using this dialog box, you can
evaluate any valid language expression, except ones that contain
• Local or static variables that are not accessible from the current execution point
For example, to display a result in hexadecimal, type ,H after the expression. To see a
floating-point number to 3 decimal places, type ,F3 after the expression.
You can also use a repeat count to reference a specific number of data items in arrays and
structures. To specify a repeat count, follow the expression with a comma and the
number of data items you want to reference. For example, suppose you declared the
following array in your program:
int my_array[10];
The following expression evaluates the first 5 elements of this array and displays the
result in hexadecimal:
my_array,5h
If you’re inspecting a compound data item, such as an array or a structure, you can view
the details of the data item by opening another Inspect window on the element you
want to inspect. To inspect an element of a compound data item,
1 In the Inspect window, select the item you want to inspect.
2 Choose Inspect on the Inspect window SpeedMenu, or press Enter.
You can also use Inspector windows to change the value of a single data item:
1 Select the data item whose value you want to modify.
2 Choose Change on the Inspect window SpeedMenu.
3 Type the new value into the Change Value dialog box and click OK.
If you’re inspecting a data structure, it’s possible the number of items displayed might
be so great that you’ll have to scroll in the Inspector window to see data you’re
interested in. For easier viewing, you can narrow the display to a range of data items:
1 Left-click in the Inspect window and choose Set Range from the SpeedMenu.
2 In the Starting Index text box, enter the index of the first item you want to view.
3 In the Count text box, enter the number of items you want to see in the Inspect
window.
In the Call Stack window, the function that’s currently executing is listed on top, with all
previously called functions listed in sequence below. The bottom of the list always
shows the first function in the calling sequence. However, only functions in the
currently loaded module are listed in this window. To view functions located in a
different module, change symbol tables, as described in “Debugging dynamic-link
libraries” on page 109.
The Call Stack window is particularly useful if you accidentally trace into code you
wanted to step over. Using the Call Stack window, you can return to the point where the
current function was called from, and then resume debugging from there:
1 In the Call Stack window, double-click the function that called the function you
accidently traced into (it will be the second function listed in the Call Stack window).
The Edit window becomes active with the cursor positioned at the location of the
function call.
2 In the Edit window, move the cursor to the statement following the function call.
3 Choose Run to Cursor on the Edit window SpeedMenu (or press F4).
Locating functions
You can locate a particular function quickly with the Locate Function command on the
Search menu. Choosing Search|Locate Function opens a dialog box that prompts you
for the name of a function. Enter a function name and choose OK to navigate to the
function definition in the Edit window. You must be debugging (stepping or tracing
through code) before you can use this command.
WinSight
WinSight is a debugging tool that gives you information about windows, window
classes, and window messages. You can use it to study a Windows application, to see
how windows and window classes are created and used, and to see what messages the
windows receive.
You can configure WinSight to trace and display messages by
• Window
• Message type
• Window class
• A combination of these
WinSight is a passive observer: it intercepts and displays information about messages,
but it doesn’t prevent messages from getting to applications.
To start WinSight, double-click the WinSight icon. The WinSight window appears in its
default configuration; it displays the Window Tree view that lists all the windows
Choosing a view
WinSight has three views that can appear within its main window: Class List, Window
Tree, and Message Trace. You can choose to look at any or all of the views. WinSight
automatically tiles the views within the main window.
You can hide or display views at any time, using the View menu. Information and
selections are not lost when a view is hidden.
• The Class List view shows all the currently registered window classes.
• The Window Tree view displays the hierarchy of all the windows on the desktop.
Window Tree displays by default when you start WinSight.
• The Message Trace view displays information about messages received by selected
windows or window classes.
To get more detail about an item in Window Tree or Class List,
• Select a window or a class, then choose Spy|Open Detail.
• Double-click the window or class.
Spying on classes
To trace messages for one or more classes, select the classes in Class List (Shift+Click or
Ctrl+Click), then choose Messages|Selected Classes. If the Message Trace view is hidden,
it becomes visible when you choose Messages|Selected Classes.
Note that tracing messages to a class lets you see all messages to windows of that class,
including creation messages, which would otherwise not be accessible.
To change which classes are traced, change the selection in the Class List. Choose
Messages|Trace Off to turn off all message tracing to the Message view.
Finding a window
WinSight has a special mode for locating windows. It can work in two ways: either
identifying the line in the Window Tree that corresponds to a window you point at with
the mouse, or highlighting a window you select in the Window Tree.
Important All other applications are suspended while you’re in Find Window mode. Enter Find
Window mode by choosing Spy|Find Window. In this mode, whenever the mouse
passes into the boundaries of a window, a thick border appears around that window,
and the window is selected in the Window Tree view.
Spying on windows
To spy on one or more windows, select the windows (using the mouse and the Shift or
Ctrl key), then choose Messages|Selected Windows. To change which windows are
traced, change the selected window in Window Tree.
To spy on all windows, regardless of what is selected in the Class List or the Window
Tree, choose Messages|All Windows.
Message Trace becomes visible when you choose Messages|Selected Windows or
Windows|All Windows.
Choose Messages|Trace Off to disable message tracing without hiding Message Trace.
WinSpector
WinSpector and its utilities help you perform a postmortem examination of
Unrecoverable Application Errors (UAEs) and General Protection Faults (GPFs). When
a UAE or GPF occurs, WinSpector writes a log file to your disk that shows you helpful
information about the cause of the exception, including
• The call stack that was active when an exception occurred
• Function and procedure names in the call stack
Configuring WINSPCTR.LOG
There are two ways you can set the WinSpector options that control the output to
WINSPCTR.LOG:
• To use the WinSpector Preferences dialog box, start WinSpector, click the WinSpector
icon and choose Preferences from the pop-up menu.
• To edit commands in WINSPCTR.INI, load the file into any text editor, edit or add
commands, then save the file and restart WinSpector.
The following sections describe each option in the Preferences dialog box.
WINSPCTR.INI options are listed in bold.
LogDir=[directory]: Directory is the location of WINSPCTR.LOG. Type the path where
you want the file (C:WINDOWS is the default).
LogViewer=[viewername]: Viewer is the program WinSpector uses to display the log
file. Type the path and file name of the viewer you want to use (NOTEPAD.EXE is the
default). For example, C:WIN31WRITE.EXE. If WinSpector can’t find the editor, it
displays the message Error: Unable to execute: [option], where option is the editor file
name. Check to make sure the editor you indicated exists in the specified directory.
CreateNewLog= 0 (append) or 1 (overwrite): Append New Reports and Overwrite
Previous Reports lets you control whether WinSpector appends reports to the existing
log file or overwrites the old log file when a new report is generated.
WINSPCTR.LOG reference
Each report in WINSPCTR.LOG has several sections that help you determine what
caused the exception in your program. The first line of a report in WINSPCTR.LOG
gives the date and time when the exception occurred; for example,
WinSpector failure report - 6/18/1992 11:04:25
The second line lists
• What type of exception occurred ( lists frequent exceptions)
• The module name
• The logical address
• The physical address
• The currently active task at the time of the exception.
A second line might look like this:
Exception 13 at USER 002A:0429 (079F:0429) (TASK=BAD)
Exception 13 errors include, but are not limited to, the following errors:
• Invalid selector loaded into a segment register.
• Segment limit exceeded. Although the selector is valid, the offset value is greater than
the segment limit (for example, an array index out of bounds error in DS, ES, or other
segments).
• Execution is transferred to a nonexecutable segment, such as a bad function pointer.
• Accessing DS, ES, FS, or GS registers containing a null selector. (This error can cause a
0 to appear in the segment register of the log file.)
A log file lists both the physical and logical addresses where the exception occurred.
These two types of addresses are important to Windows programs for the following
reasons:
• When a program is loaded, Windows allocates space for each logical segment and
assigns each segment a unique selector. The selector and its offset are combined to
form a physical address.
• When a Windows .EXE file is linked, each segment is placed in a different section of
the file, and a segment table is created.
• A logical address, which is actually a segment’s position in the Windows segment
table, consists of a module name, a logical segment, and an offset. You can run
TDUMP on the file to find out segment size and other information, or you can
generate a .MAP file that contains the same kind of information.
If the stack pointer is too small at the time of exception, TOOLHELP.DLL automatically
switches the stack and appends the message Stack Switched to the end of the second line
of the log.
Disassembly section
The Disassembly section in WINSPCTR.LOG begins with the assembly language
instruction that caused the exception that is followed by the next few instructions in the
program, which provide a point of reference for finding the task that caused the
exception.
For example, given the following code, where ES is the segment register that contains a
selector and BX is the offset into the segment, an exception 13 occurred because the
value in BX was greater than the segment limit referenced by ES:
079F:0429 CMP BYTE PTR ES:[BX],FF
079F:042D JNE 043A
079F:042F CMP WORD PTR [BP+06],03
079F:0435 MOV DI, 0001
Register section
The Register section in WINSPCTR.LOG lists the values stored in the standard registers
when the exception occurred, as the following example shows:
Registers:
AX 0037
BX 0000
CX 0008
DX 10EE
SI 0037
DI 0028
Limits and access rights are given for the CS, DS, ES, and SS registers.
Tasks section
The Tasks section in WINSPCTR.LOG lists the programs running when the exception
occurred, including the
• Complete path to the executable file
• Module name
• Windows module handle
• Task handle
• Data segment value for the task (the instance handle)
Some of the tasks running when the BAD application caused an exception include
C:WIN31SYSTEMNWPOPUP.EXE
Module: NWPOPUP hModule: 142F hTask: 141F hInstance: 13F6
C:BINWINSPCTR.EXE
Module: WINSPCTR hModule: 1397 hTask: 1387 hInstance: 135E
C:BINBAD.EXE
Module: BAD hModule: 1467 hTask: 1127 hInstance: 10FE
Modules section
The Modules section in WINSPCTR.LOG lists the modules that were running at the
time of the exception, including the
• Path to the executable file
• Date stamp of the executable file
• File size
• Module name
• Module handle
• Reference count indicating how many times the module is in use
Three of the modules running when the BAD application caused an exception include
C:WIN31SYSTEMKRNL386.EXE Date: 03/02/1992 Size: 116132
Module: KERNEL hModule: 010F reference count: 21
C:WIN31SYSTEMSYSTEM.DRV Date: 03/01/1992 Size: 2304
DFA output
DFA writes a file only if Turbo Debugger information exists for the file in the stack
frame. The DFA output file (DFA.OUT) has a stack trace similar to the one in the
WinSpector log file, except that it contains
• Function names
• Line numbers
• Local and global variables
• Data segments and their values (including the stack segment)
Using EXEMAP.EXE
EXEMAP creates .MAP files for Windows executables. A .MAP file can be used to create
a .SYM file, which can then be used by WinSpector to expand its error reporting. If you
are using .DLLs or other programs for which you don’t have the source code, this
information can be especially useful.
To create a .MAP file from an .EXE, type EXEMAP filename.EXE newname.MAP. If you don’t
type a new name, EXEMAP creates a .MAP file with the same name as the .EXE.
Although the resulting .MAP file isn’t as complete as one generated by the link phase of
the compile process, it does include addresses for exported public functions.
Using TMAPSYM.EXE
TMAPSYM creates .SYM files from existing .MAP files (created either by the compiler or
by the EXEMAP utility). The resulting .SYM files make available to WinSpector the
public functions, variable names, and functions in the entry table of the executable.
Using BUILDSYM.EXE
BUILDSYM creates .SYM files from .EXE files. It has the same output as using both
EXEMAP and TMAPSYM, since it automatically runs them, but it deletes the .MAP files
from your directory. BUILDSYM supports wildcards, so you can create .SYM files for
part or all of a directory by entering a single command.
To run BUILDSYM, both EXEMAP and TMAPSYM must be in the same directory as
BUILDSYM or in your search path. BUILDSYM places the .SYM files it creates in the
current directory. For WinSpector to find a .SYM file, the file must be in the same
directory as the executable that caused the exception.
BUILDSYM performs the following tasks:
• Verifies that the files are Windows files, and if not, leaves them alone.
• Calls EXEMAP to create .MAP files.
• Verifies that .MAP files were created.
• Calls TMAPSYM and passes the names of the new .MAP files so TMAPSYM can
create .SYM files.
• Deletes the .MAP files because they are no longer needed.
To create a .SYM file from an .EXE, type BUILDSYM filename.EXE.
II
Using Resource Workshop
Part II
Part II of this manual describes how to create, compile, and link resources to
applications running under Microsoft Windows versions 3.0 and later. You will learn to
• Work with resources in either text or binary format.
• Manage hundreds of resources stored in dozens of files.
• Use multilevel Undo and Redo to step back through changes you’ve made.
• Compile your resources only when you need to.
• Change a program’s resources even if you don’t have access to the source code.
• Automatically check for errors, such as incorrect syntax and duplicate resource IDs.
The following chapters constitute Part II:
• Chapter 9, “An overview of working with resources,” describes resources and
shows how to create and edit resources by working with resource script, binary, and
graphic files.
• Chapter 10, “Working with dialog boxes,” describes how to work with dialog boxes.
• Chapter 11, “Working with menus and accelerator tables,” describes how to work
with menus and accelerators.
• Chapter 12, “Working with string tables,” describes how to work with strings.
• Chapter 13, “Working with graphics,” describes how to work with graphics.
• Chapter 14, “Working with version information and custom data types,” describes
how to work with version information and custom data types.
An overview of working
Chapter 9
9
with resources
Resource Workshop provides the tools you need to create and edit the resources of an
application without using code. The tools include editors for dialog boxes, menus,
accelerators, graphics, and strings. Resource Workshop also has a built-in script (text)
editor, which you can use to create and edit non-graphical resources, such as version
information and custom data types.
In general, you use Resource Workshop to perform the following tasks:
• Create and edit resource script (.RC) files. A resource script file contains the ASCII
data from which you can generate one or more binary resources. Then you can link
the resources to an application, and refer to the resources in the application’s code.
• Edit resources in binary files. Resources are linked to an executable (.EXE), dynamic-
link library (.DLL), or other binary file. When you open a binary file in Resource
Workshop, the resources linked to the file are automatically decompiled so that you
can edit them. When you’re done making changes, you can recompile and relink the
resources to the original binary file.
• Create and edit graphic files. Resource Workshop’s Graphic editor is similar to the
Windows Paintbrush. However, with the Graphic editor, you’re not restricted to
bitmap (.BMP) files; you can create icon (.ICO), cursor (.CUR), and font (.FNT) files as
well.
This chapter describes resources and shows how to create and edit resources by
working with resource script, binary, and graphic files. This chapter also shows how to
customize Resource Workshop.
To See
Create or edit a resource script file “Working with resource script files” on page 135
Edit resources in a binary file “Working with binary files” on page 142
Create or edit a graphic file “Working with graphic files” on page 143
Option Description
Loaded on call The resource is loaded into memory when needed for the first time. If a resource is
not loaded on call, it is loaded when the application starts. If an application doesn’t
need the resource immediately, you should select this option so that the application
is launched more quickly.
Moveable The resource can be moved in memory. By allowing a resource to be moved in
memory, you can increase the efficiency with which the application uses memory;
however, it’s harder to track the exact location of the resource in memory.
Discardable The resource can be removed from memory. (If no longer in memory when needed,
the resource is automatically reloaded.) By allowing a resource to be discarded from
memory, you can decrease the amount of memory an application needs at one time;
however, if a system runs low on memory, the application will run more slowly
when reloading resources.
Pure The resource can’t be changed in memory.
4 Choose OK.
Adding an identifier
If you’re not generating identifiers automatically or if you want to create identifiers for
resources that don’t exist yet, you need to add identifiers manually.
To add an identifier to a resource header or resource script file,
1 Choose Resource|Identifiers.
2 Choose New.
3 In the Name box, type a name for the identifier. You can use alphanumeric characters
and the underscore character. The identifier name can’t begin with a number, and
any characters past the 31st character are ignored.
4 In the Value box, type a value for the identifier. You can choose any value that is not
already used.
5 Choose a resource script or header file in which to store the identifier.
6 Choose OK.
7 Choose Done.
You can also add an existing identifier by moving it from one resource script or resource
header file to another. To move an identifier, choose Resource|Identifiers and use the
Move button.
Note You can control which information appears in the Identifiers dialog box by setting the
View and Sort options. For more information about these options, choose Resource|
Identifiers, and then choose Help.
Editing an identifier
You can edit a resource identifier by changing its value or name. You may want to
change the value of an identifier to keep related resources together; you might want to
change the name of an identifier to more accurately reflect the resource to which it
refers.
To edit a resource identifier,
1 Choose Resource|Identifiers.
2 Select the identifier.
3 Choose Change or Rename.
4 Type a new value or name for the resource identifier.
5 Choose OK.
6 Choose Done.
Note You can control which information appears in the Identifiers dialog box by setting the
View and Sort options. For more information about these options, choose Resource|
Identifiers and then choose Help.
Removing an identifier
If you remove a resource script from a resource script file, you should also remove its
identifier.
To remove a resource identifier,
1 Choose Resource|Identifiers.
2 Select the identifier.
3 Choose Delete.
4 If the identifier is assigned to a resource, a warning box appears. Choose Yes to delete
the identifier.
5 Choose Done.
Option Settings
Undo Levels 1–99. The maximum number of Undo levels may be limited by available
memory.
Text Editor The full path and file name of a text editor. You will be given the option of
editing the resource script file in the text editor if an error occurs during
the resource compilation process. By default, the text editor is the
Windows Notepad.
Include Path The path(s) where Resource Workshop looks for resource files. You can
specify the include path only when there are no open files.
Multi-Save Whether or not the current resource file is saved automatically in an
additional compiled resource script (.RES), binary file, or backup file.
(Backup files have a tilde (~) as the first character in the file name
extension.)
Automatic Identifier Whether or not identifiers are automatically created when you add new
Management resource scripts. If you turn on this feature, you won’t have to manually
create identifiers for new resource scripts.
Target Windows Version Whether new resource script files are for Windows 3.0, Windows 3.1, or
Win32 applications. You can specify the Windows version only when
there are no open files. Win32 resource script files work with Borland C++,
but not with Turbo C++.
Language for Win32 The default major and minor languages for new resource scripts. You can
specify the default languages only after targeting Win32. For more
information, see the section “Specifying a language version” on page 139.
Win32 resource script files work with Borland C++, but not with Turbo
C++.
3 Choose OK.
Alignment palette
Tools palette
Tab Set Horizontal Scroll Bar Vertical Scroll Bar Horizontal Line
After you start the Dialog editor, you can edit a dialog box resource script by
• Setting dialog box properties
• Moving and resizing the dialog box
• Adding controls to the dialog box
• Moving, resizing, aligning, and grouping controls
Class property
You can specify bordlg, BorDlg_Gray, or your own custom window class. If you don’t
specify a class, the dialog box uses the standard Windows class.
The bordlg class improves the appearance of your dialog box by painting the
background with a brush that varies according to the target display device. For screens
of VGA and higher resolution, the background is a fine grid of perpendicular white
lines, giving the effect of chiseled steel. For EGA and monochrome screens, the
background is white. The bordlg class also optimizes the drawing of your dialog box by
calling the custom control drawing routines directly instead of waiting for Windows to
paint the controls.
The BorDlg_Gray class gives the dialog box a gray background in addition to the
features of the bordlg class.
For information about creating Window classes, search Win32 Online Help
(WIN32.HLP) for “Windows Classes.”
Menu property
Like other windows, a dialog box can have menus. Menus are particularly useful for
dialog boxes that serve as the main window of an application.
To add menus to your dialog box, specify the identifier or unique number of a menu
resource. For information about menu resources, see “Working with menus and
accelerator tables” on page 171.
Type property
You can set the Type property to one of the following values:
Value Description
Popup A pop-up window. Because most dialog boxes are pop-ups, this is the default.
Child A child of the current window.
Overlapped An window that can be covered by another window. You’ll want to set the Type property
to overlapped only for the main window in an application.
Property Description
System Menu Includes a System menu box to the left of the title bar (appears only if you’ve also
chosen Caption for the Frame Style property). If the dialog box is a child window, a
Close box appears instead of a Control menu.
Thick Frame Places a thick frame around the dialog box. This option defines what the user will see
when the dialog box appears within an application. If you want the dialog box to be
resizable, use this option. (Don’t confuse this option with the Thick Frame option in
the Dialog editor Preferences command. That option defines what the dialog box
looks like when you select it in the Dialog editor.)
Vertical Scroll Adds a vertical scroll bar to the dialog box frame.
Horizontal Scroll Adds a horizontal scroll bar to the dialog box frame.
Minimize Box Adds a Minimize button on the right side of the title bar. The Minimize button
appears only if you’ve also chosen Caption for the dialog box frame style.
Maximize Box Adds a Maximize button on the right side of the title bar. The Maximize button
appears only if you’ve also chosen Caption for the dialog box frame style.
Absolute Align Makes the dialog box coordinates relative to the display screen rather than the parent
or owner window.
System Modal Makes the dialog box system modal, meaning that the user can’t do anything else
until the dialog box is closed.
Local Edit Allocates any edit text controls included in this dialog box to the application’s local
heap. Choose Local Edit if your application needs to use EM_SETHANDLE and
EM_GETHANDLE messages.
Modal Frame Frames the dialog box with a combination of the dialog box frame and caption styles
(default).
No Idle Messages Suppresses sending WM_ENTERIDLE messages to the application’s main dialog
box. The dialog box must be modal for this option to take effect.
Clip Children Protects the client area of child dialog boxes from being drawn on by the Parent
dialog box.
Clip Siblings Protects the siblings of this window. Drawing is restricted to this window. This
option is not required for dialog boxes, but can be useful for child dialog windows.
Visible Makes a modeless window visible before the return from CreateDialog. This option
has no effect on modal windows (the usual kind of dialog box). By default, this option
is not checked (NOT WS_VISIBLE).
Value Description
Dialog frame A double border without a title bar
Border A single, thin border without a title bar
Caption A single, thin border and a title bar where a caption can be displayed (default)
No border No border or title bar
Font properties
You can set the Font Name and Font Size properties by choosing the Font button,
selecting a font name and size, and then choosing OK.
Value Description
WS_ES_ACCEPTFILES This dialog box accepts drag and drop files.
WS_EX_DLGMODALFRAME This dialog box has a double border that can (optionally) be created with
a title bar by specifying the WS_CAPTION style flag in the c-style
parameter.
WS_EX_NOPARENTNOTIFY A child window created by using this style will not send the
WM_PARENTNOTIFY message to its parent window when the child
window is created or destroyed.
WS_EX_TOPMOST A window created with this style should be placed above all non-
topmost windows and stay above them even when the window is
deactivated. An application can use the SetWindowPos function to add or
remove this attribute.
WS_EX_TRANSPARENT A window created with this style is transparent, so that any windows
beneath it are not obscured by the window. A window created with this
style receives WM_PAINT messages only after all sibling windows
beneath it have been updated.
Common properties
In addition, you can set any of the common properties for the dialog box, which are
described page 160.
Control Description
Push button A rectangular button the user “presses” to select an action. You can create a standard or
Borland push button. Unlike a standard push button, a Borland push button has a
minimum size of 26x14 dialog units. You can more easily add bitmaps to a Borland push
button.
Radio button A button that is used in groups to represent mutually exclusive options. You can create a
standard or Borland radio button. A standard radio button is circular. A Borland radio
button is a three-dimensional diamond. For information about grouping radio buttons,
see the section “Grouping and ungrouping controls” on page 157.
Check box A square box that represents an option that can be turned on or off. You can create a
standard or Borland check box. When a standard check box is selected, an X appears in
the square. When a Borland check box is selected, a check mark appears in the square.
When a check box is not selected, the square is empty.
Static text A fixed text string. You can create a standard or Borland static text control. Unlike a
standard static text control, a Borland static text control is shaded.
Group box A box that is used to group controls visually. You can create a standard or Borland
group box. Unlike a standard group box, a Borland group box is shaded and has a three-
dimensional effect.
Scroll bar A rectangle with direction arrows at each end. Between the arrows, a square icon, called
the scroll box or thumb, indicates the approximate position of the display relative to the
full range of information. You can create a horizontal or vertical scroll bar.
List box A box that contains a list of items from which the user can choose.
Icon An icon.
Frame A rectangular frame with the same color as the dialog box frame.
Rectangle A rectangle with the same color as the dialog box frame.
Line A line used to separate items in a dialog box. You can create a horizontal or vertical line.
Message Description
BBN_SETFOCUS Indicates that the Borland control has gained keyboard focus through an
action other than a mouse-click.
BBN_SETFOCUSMOUSE Indicates that the Borland control has gained keyboard focus through a
mouse-click.
BBN_GOTATAB Indicates that the user pressed Tab while the Borland control had the
keyboard focus. The parent window can intervene in the processing of the
keystroke by returning a nonzero value.
BBN_GOTABTAB Indicates that the user pressed Shift+Tab while the Borland control had the
keyboard focus. The parent window can intervene in the processing of the
keystroke by returning a nonzero value.
Selecting controls
Many editing options require that one or more controls be selected. For example, you
must select a control before you can change its size, and you must select at least two
controls before you can align them relative to each other.
To select a single control,
1 Choose the Selector tool.
2 Click the control.
A selection frame appears around the control you select.
Selector
tool To select one or more controls,
1 Choose the Selector tool.
2 Click on a control to make sure the dialog box template is not selected.
Moving controls
You can move selected controls by dragging anywhere inside the selection frame. As
you drag, the controls move together, maintaining their positions relative to each other.
To move a control with the keyboard, press Tab to select the control, then use the arrow
keys to move the control, and press Enter.
Resizing controls
You can resize controls with the options in the Size Controls dialog box:
1 Select the controls you want to resize.
The selection frame surrounds the selected controls. The individual controls that are
affected by the resizing options have shaded outlines.
2 Choose Align|Size. Choose the Vertical Size and Horizontal Size options you want
and click OK to resize the selected controls.
Horizontal size
options Description
No Change Prevents horizontal size change.
Shrink to Smallest Reduces width of controls to match the least wide of the selected controls.
Grow to Largest Increases width of controls to match the widest of the selected controls.
Width of Size Box Resizes controls so they are as wide as the selection frame.
Width of Dialog Resizes controls so they are as wide as the dialog box.
If you select a single control and then choose Align|Size, the following options are
available:
• No Change (Horizontal and Vertical)
• Width of Dialog (Horizontal)
• Height of Dialog (Vertical)
• Enter Values (Horizontal and Vertical)
The No Change, Width of Dialog, and Height of Dialog options are described in the
preceding tables.
The Enter Values options let you specify both the size and position of the selected
control. The X- and Y-values set the distance of the upper left corner of the control from
the upper left corner of the dialog box (directly below the title bar). The CX- and CY-
values set the width and height of the control. All values are measured in pixels or
dialog units.
Aligning controls
You can align controls on the dialog box template so they are more visually appealing.
You align controls with the Align|Align command, the Alignment palette, and the grid.
These alignment methods are described in the following sections.
Horizontal
alignment option Description
No Change Affects no change in horizontal alignment.
Left Sides Aligns the controls so their left sides are on the left of the selection frame.
Centers Aligns the controls so their horizontal centers are in the center of the selection
frame.
Right Sides Aligns the controls so their right sides are on the right side of the selection frame.
Space Equally Moves the controls horizontally within the selection frame so the spaces between
them are equal.
Center In Dialog Centers the selection frame horizontally in the dialog box. The relative position
of the individual controls within the selection frame is unchanged.
Vertical
alignment option Description
No Change Affects no change in vertical alignment.
Tops Aligns the controls so their tops are at the top of the selection frame.
Centers Aligns the controls so their vertical centers are in the center of the selection
frame.
Bottoms Aligns the controls so their bottoms are at the bottom of the selection frame.
Space Equally Moves the controls vertically within the selection frame so the spaces between
them are equal.
Center In Dialog Centers the selection frame vertically in the dialog box. The relative position of
the individual controls within the selection frame is unchanged.
Undoing actions
You can “undo” any editing you do in the Dialog editor, such as placing controls,
aligning them, deleting controls, and so on, with the Undo tool or the Edit|Undo
command.
Undo tool
To specify the number of actions that you can undo, use the File|Preferences command.
For more information, see “Customizing Resource Workshop” on page 144.
Property Description
Caption Text to display on or next to the control. Different types of controls have
captions in different areas. For example, in a group box, the caption is at the top
left. In a push button, the caption is inside the button.
Height The height of the control in pixels or dialog units.
Property Description
Caption Type Whether the caption is text or a number.
Horizontal Scroll Bar Whether the control has a horizontal scroll bar.
Vertical Scroll Bar Whether the control has a vertical scroll bar.
Alignment Whether text is aligned to the right, left, or center of the control.
Owner Drawing The amount of control the application has over the appearance of the control. For
more information about the Owner Drawing property, choose the Help button on
the Style window.
Owner Draw Whether the application handles the appearance of the control. When the Owner
Draw is selected, the control sends a WM_DRAWITEM message to its parent.
Parent Notify Whether the control generates the following Windows messages:
BBN_SETFOCUS, BBN_SETFOCUSMOUSE, BBN_GOTATAB, GOTABTAB. The
parent notify property is available with Borland controls only.
No Character The No Character Underline check box turns off character underlining. You can
Underlining underline a text character in your static control by preceding it with an
ampersand (&). If you check No Character Underline, underlining is disabled
and ampersands are displayed as literal characters.
Border Whether the control has a border.
Type property
You can set the Type property to one of the following values:
Value Description
Push Button A normal push button.
Default Push Button Identical to a push button, but also includes a bold border indicating that it’s the
default response if the user presses Enter.
Bitmap Button A button that contains a bitmap (available only for Borland push button controls).
If you choose the Bitmap option, you can insert a bitmap image (based on its control ID)
into the button. To read in a bitmap,
1 Add a Borland push button control to a dialog box. Note its control ID.
2 Create a bitmap. (For information about creating bitmaps, see Chapter 13, “Working
with graphics,” on page 187.)
3 Choose Resource|Rename.
4 In the New Name box, type an integer value that equals the current control ID of the
button plus the appropriate offset from the following table:
If the bitmap represents Use this offset for VGA Use this offset for EGA and
the button in this state and higher resolutions monochrome resolutions
Standard 1000 2000
Pressed 3000 4000
Keyboard focus 5000 6000
For example, for a bitmap that represents the button in its focused state, use the
control ID of the button plus 5000 for a VGA system and 6000 for an EGA system.
5 Choose OK.
6 Close the Graphic editor.
The bitmap won’t appear in the control until you close the Graphic editor.
7 Switch to the Dialog editor.
Control ID property
Just as with the other controls, you can set the Control ID property of a push button to
any integer value. However, the following values have predefined meanings:
Note If you’re using the Borland push button control, the appropriate caption is set
automatically when you specify a predefined control ID.
Value Description
Normal A normal check box. Your application is responsible for checking or unchecking the box.
Auto A normal check box that Windows automatically checks or unchecks.
3 State A check box with three states: checked, unchecked, and dimmed. Your application is
responsible for activating each state.
Auto 3 State A 3 state check box that Windows automatically checks, unchecks, or dims.
Value Description
Left Text Displays text flush left within the control border (default). If text would extend
past the edge of the frame, it automatically wraps to a new line.
Left Text—No Wrap Displays text flush left within the control border. Any line of text that extends past
the edge of the frame is clipped.
Centered Text Displays text centered within the control border. If text would extend past the
edge of the frame, it automatically wraps to a new line.
Right Text Displays text flush right within the control border. If text would extend past the
edge of the frame, it automatically wraps to a new line.
Simple Text Displays a single line of flush-left text. Doesn’t take tab characters and can’t be
broken to a new line. Simple text doesn’t process the WM_CTLCOLOR message.
Uses the current window background color.
Note The text in all these styles uses the current Windows text color from the Control Panel.
Also, in all static text but simple text, you can tab text by typing \T, and you can break text
to a new line with \R.
Option Description
None The scroll bar fills the entire selection frame (default). If you resize the selection frame,
you can change the scroll bar’s proportions, making the arrow buttons and scroll box
wider than usual.
Top Left A horizontal scroll bar displays at the top of the selection frame and extends the full
width of the frame. A vertical scroll bar displays at the left side of the selection frame
and extends the full height of the frame.
Bottom Right A horizontal scroll bar displays at the bottom of the selection frame and extends the full
width of the frame. A vertical scroll bar displays at the right side of the selection frame
and extends the full height of the frame.
Case property
You can set the Case property to one of the following values:
Value Description
Case Insensitive Displays text exactly as typed (default).
Upper Case Displays all text in uppercase letters, regardless of how it’s typed.
Lower Case Displays all text in lowercase letters, regardless of how it’s typed.
Value Description
Read Only The text is set to read-only. The windows.h constant for this style is ES_READONLY.
Want Return The Return key forces a line break in a multiline edit text control that has keyboard
focus. If the control doesn’t have keyboard focus, the carriage return goes to the
default push button. If the control doesn’t have this flag, the user must press
Ctrl+Return to create a line break. The windows.h constant for this style is
ES_WANTRETURN.
Value Description
Single Line Limits the edit text to a single line (default).
Multiple Line Lets the user type text on multiple lines. (To enable scrolling of multiple-line text, set
the Vertical Automatic Scroll option to on.)
Property Description
Automatic Horizontal Scroll When the user types a character at the right edge of the edit text
boundary, the text automatically scrolls ten characters to the right. When
the user presses Enter, the text scrolls back to the zero position.
Automatic Vertical Scroll When the user presses Enter on the last line of the edit text control, the text
scrolls up a full page. For example, if the control is five lines long,
pressing Enter on the last line causes text to scroll up five lines; the cursor
goes back to the top line.
Password When Password is on, the letters being typed are not displayed. Instead,
asterisks appear in their place. This is helpful for keeping passwords
secret.
Convert OEM Converts text typed into the control to the current OEM character set,
then reconverts the text to ANSI. This option is useful in file input boxes
because it ensures that any file name entered can be translated into the
OEM character set, which is used by the DOS file system.
Keep Selection Keeps selected text highlighted, even when this control doesn’t have
keyboard focus. For example, if a user highlights text in an edit text
control and then moves to another control, the text will no longer be
highlighted, unless the edit text control has the Keep Selection property
turned on.
Property Description
Notify Sends an input message to the parent window when the user clicks an item in
the list (default).
Sort Sorts the list alphabetically.
Multiple Select Lets the user select more than one item at a time. The user can also toggle
individual items on and off.
Don’t Redraw Prevents the list box from being redrawn when it is changed.
Tab Stops Organizes the information in the list box in columns. The default column
width is 32 dialog units or 8 characters. You should use tab characters. (If you
want to change the column width, the application should set its own tab stops
using the LB_SETTABSTOPS message.)
Integral Height Decreases list box height at run time, if necessary, to the nearest integral
multiple of the current font height (default) For example, a list box might have
three items that display completely, but a fourth that is partially cut off. If
Integral Height is turned on, the list box decreases its size at run time to the
space required for three items (three times the font height).
Type property
You can set the Type property to one of the following values:
Value Description
Simple The drop-down list is always expanded to display items in the list, and the user
can edit the items in the list (default).
Drop Down When the dialog box is first displayed, the combo box consists of a single line
of editable text. The user can click the down arrow to expand the list, and edit
all items in the list.
Drop Down List This option works like a drop down, but the list is static. The user can select,
but can’t change anything in the list.
Property Description
Sort Automatically sorts items in a list box in alphabetical order.
Integral Height Sizes the list box at run time so all items in the list are completely displayed
(default). If you want to control the height of the list box precisely, uncheck this
option.
OEM Conversion Converts text the user types in to the current OEM character set, then
reconverts the text to ANSI. This option is useful in file input boxes because it
ensures that any file name entered can be translated into the OEM character
set, which is used by the DOS file system.
Auto Horizontal Scrolls text to the left automatically when it exceeds the width of the control.
Vertical Scroll Always The combo box always displays a vertical scroll bar, regardless of the number
of items it contains. The windows.h constant for this style is
CBS_DISABLENOSCROLL. This property applies to Window 3.1 resources
only.
Frame properties
The frame control has a unique Type property, which you can set to any of the following
values:
Value Description
White Frame Displays an empty frame with a solid outline that uses the current Windows
background color set in the Control Panel. In Windows, the default color for the
background is white.
Gray Frame Displays an empty frame with a solid outline that uses the current screen
background (Desktop) color set in the Control Panel. In Windows, the default color
for the Desktop is gray.
Black Frame Displays an empty frame with a solid outline that uses the current Windows frame
color set in the Control Panel. The Windows default color for window frames is
black.
Rectangle properties
The rectangle control has a unique Type property, which you can set to any of the
following values:
Value Description
White Rectangle Displays a filled rectangle that uses the current Windows background color set in
the Control Panel. In Windows, the default color for the background is white.
Gray Rectangle Displays a filled rectangle that uses the current screen background (Desktop) color
set in the Control Panel. In Window, the default color for the Desktop is gray.
Black Rectangle Displays a filled rectangle that uses the current Windows frame color set in the
Control Panel. In Windows, the default color for window frames is black.
Line properties
The line control has a unique Type property, which you can set to any of the following
values:
In the resource script language, each type of control has a unique syntax. For example,
centered static text uses the CTEXT statement. The CONTROL statement, however, can
specify any type of control. If you want to generate only CONTROL statements in your
resource script (rather than the specialized control statements), select the Generate
CONTROL Statements Only option. For more information about the resource script
language, search Help for “Editing a Resource as Text.”
The Draw Custom Controls as Frames check box is available only when the Drawing
Type is set to Normal. When the option is checked, custom controls are drawn as empty
rectangular outlines. When the option is unchecked, custom controls are drawn as gray
rectangles with their text (if any) in a white rectangle in the center. Drawing custom
controls as frames can speed up drawing of your dialog boxes on the screen.
If you check CTL3D2V.DLL, the Dialog editor uses the Windows 3-D look for controls
such as radio buttons and check boxes.
Test pane
Attribute pane
Outline pane
After you start the Menu editor, you can edit the menu resource script by
• Adding a menu or separator to the menu bar
• Adding a menu item or separator to a menu
• Setting the initial state of a menu or menu item
• Changing the identifier for a menu item
• Associating Help text with a menu item
• Assigning an accelerator to a menu item
• Copying, moving, or removing a menu, menu item, or separator
• Checking for duplicate identifiers
To customize the Menu editor, see “Customizing the Menu editor” on page 178.
Command Description
Menu|New File Adds a File menu that contains the following commands: New, Open, Save, Save
As, Print, Page Setup, Printer Setup, and Exit.
Menu|New Edit Adds an Edit menu that contains the following commands: Undo, Cut, Copy and
Paste.
Menu|New Help Adds a Help menu that contains the following commands: Index, Keyboard,
Commands, Procedures, Using Help, and About.
Adding a separator
To add a separator to the menu bar,
1 In the Outline pane, select the POPUP line of a menu; this menu that will
immediately follow the separator.
2 In the Attributes pane, choose one of the following options:
Option Description
Menu Bar Break or Menu Break Starts a new line in the menu bar.
Help Break Moves the menu to the far right of the menu bar.
Option Description
Menu Bar Break Starts a new column that is preceded by a vertical line in the menu.
Menu Break Starts a new column in the menu.
Option Description
Enabled In its initial state, the menu or menu item is enabled. Use the EnableMenuItem function
to change the state of the menu or menu item in code.
Disabled In its initial state, the menu or menu item is disabled. The user can’t distinguish
between Enabled and Disabled commands; they look the same on the menu. Use the
EnableMenuItem function to change the state of the menu item.
Grayed In its initial state, the menu or menu item is disabled and its text is grayed. The shading
lets the user know the command is not currently available. Use the EnableMenuItem
function to change the state of the menu or menu item.
3 In the Attributes pane, select or unselect the Checked box. If you select the Checked
box, a check mark appears next to the menu item. You can use a checkmark to
Option Description
Alt Combines the Alt key with the accelerator key (for example, Alt+W).
Shift Combines the Shift key with the accelerator key (for example, Shift+F1). You can’t use the
Shift option with an ASCII key.
Control Combines the Ctrl key with the accelerator key (for example, Ctrl+W). You can’t use the
Control option with an ASCII key. However, you can combine the Ctrl key with an
ASCII key by including a caret (^) in the key name. (See step 2.)
Insert Causes the corresponding menu to flash when the user presses the accelerator key
combination.
Option Description
View|View As Popup Select this option to have menus displayed as cascading menus in a
single main menu; deselect this option to have menus displayed on the
menu bar.
Leave View As Pop-up unchecked if your menu resource contains the
application’s entire menu structure and you want it displayed as it
would appear to the user.
If you’re working on a floating menu, check this option to display the
test menu as it actually would appear. The command Pop-up appears on
the menu bar, and you select Pop-up to display the menu itself.
View|First Graphic This graphic represents the default configuration of the panes, with the
Test Menu pane over the Outline pane and to the right of the Attribute
pane.
View|Second Graphic Check this graphic to put the Test Menu pane across the top of the edit
window, like a normal menu bar.
Menu|Change Identifier Prefix Use this command to change the identifier prefix that is automatically
assigned to new menu items.
Menu|Track Test Menu Select this option if you want menu items to appear in the Attributes
pane when you select them in the Test pane.
Outline pane
Attribute pane
After you start the Accelerator editor, you can edit the resource script for the accelerator
table by
• Adding an accelerator resource
• Changing the identifier for an accelerator resource
• Changing the keyboard combination for an accelerator resource
• Copying, moving, or removing an accelerator resource
• Checking for duplicate keyboard combinations
13
Working with graphics
Chapter 13
With Resource Workshop, you can create and edit the following types of graphics:
• A bitmap, which is a graphic image, such as a picture, logo, or other drawing.
• An icon, which is a graphic image that represents a minimized window. An icon is
64x64, 32x32, 16x32, or 16x16 pixels in size.
• A cursor, which is a graphic image that shows the position of the mouse on the screen
and indicates the types of actions that a user can perform. A cursor is 32x32 pixels in
size. Many applications use a pointer, which indicates that the user can make a
selection, and an hourglass, which indicates that the system is performing an action.
• A font, which is a set of characters with a specific typeface and size. For example,
10-point Times Roman bold is a font. A font can also contain a set of bitmaps that
aren’t characters.
Like other resources, you define a graphic with a resource script. This chapter describes
how to edit a resource script for a graphic, and use the corresponding resource in an
application.
Drawing Area
Zoom Eraser
Pen Paintbrush
Line Text
Drawing a shape
You can draw a filled or unfilled rectangle, rounded rectangle, or ellipse.
The interior of a filled shape depends on the current paint pattern, and the shape border
depends on the current pen style. To draw a shape without a border, choose Null for the
pen style.
To draw a shape,
1 In the Tools palette, select a shape tool.
2 In the Drawing Area, move the cursor to where you want a corner of the shape, and
then click and hold down the left mouse button (for the foreground color) or the right
mouse button (for the background color).
3 To draw a square or circle, hold down Shift.
Filled
shape 4 Move the cursor to the opposite corner of the shape, and then release the mouse
tools button.
Adding text
To add text to a graphic,
1 In the Tools palette, select the Text tool.
2 In the Drawing Area, click where you want to add the text.
Text tool
3 Type the text.
4 To change the alignment of the text relative to the position you specified in step 2,
choose Text|Align Left, Text|Align Center, or Text|Align Right.
5 To change the font, choose Text|Font. Then specify a font name, size, and style, and
then choose OK.
6 To change the color of the text, click on a new color in the Colors palette.
When you perform another action, the text becomes part of the graphic; at that point,
you won’t be able to select or edit the text directly. However, you can erase the area that
contains the text and then add new text.
Erasing an area
You can erase an area by drawing or painting with the background color or by using the
Eraser tool. The Eraser tool allows you to paint with the background color when you
press the left mouse button, and with the foreground color when you press the right
Eraser tool
mouse button.
You can also fill the entire Drawing Area with the background color by double-clicking
the Eraser tool.
The size of the Eraser tool is proportionate to the size of the Drawing Area. Therefore,
you can zoom out to erase a larger area, and zoom in to erase a smaller area. For more
information about zooming in and out, see the section “Zooming in on or out from a
graphic” on page 194.
Selecting an area
You can align, copy, move, or remove any area that you select.
To select a rectangular area,
1 In the Tools palette, select the Pick Rectangle tool.
Pick
Rectangle 2 In the Drawing Area, move the cursor to a corner of the area you want to select, and
tool then click and hold down the mouse button.
Aligning an area
You can align an area with the top, bottom, sides, or center of a graphic.
To align an area,
1 Select the area.
2 Choose Options|Align.
3 Choose a horizontal alignment option.
4 Choose a vertical alignment option.
5 Click OK.
Note Any area left open is filled with the current background color.
Option Description
Face Name Type a name that you want to assign to your font.
Device Type a device name for your font if you want to inform your programs that this font
can be used only on a particular device.
Copyright Type copyright information for your custom font.
Font Version Font version 2.00 is supported in all cases. You can use version 3.00 if you’re creating
a Windows 3.x application that will run in a protected mode environment (Standard
mode or 386 Enhanced mode) on an 80386 (or later) processor.
Italic The font contains italicized characters.
Underline The font contains underlined characters.
Strikeout The font contains characters that are struck out.
Proportional The font is a variable-width font.
Weight The font is of normal weight (400) or boldfaced (700).
Family Describes the font family. The acceptable values are: Don’t care (0), Roman (1), Swiss
(2), Modern (3), Script (4), and Decorative (5).
Chapter 14, Working with version information and custom data types 205
Editing a resource script for version information
or a custom data type
To edit a resource script for version information or a custom data type, you must start
the Script editor.
To start the Script editor,
1 Add a new resource script for version information or a custom data type. Or open a
resource script file that contains a resource script for version information or a custom
data type.
2 If the Script editor doesn’t start automatically, double-click the version information or
custom data type in the Project window.
The Script editor appears.
Note You can also use an external text editor to edit a resource script for version information
or a custom data type.
Parameter Description
FILEVERSION version A file version number, which is a 64-bit integer. You can define the 64-
bit integer with four 16-bit integers separated by commas. For example,
“10,11,0,1” represents 0x000a 000b 0000 0001.
PRODUCTVERSION version A product version number, which is a 64-bit integer. You can define the
64-bit integer with four 16-bit integers separated by commas. For
example, “10,11,0,1” represents 0x000a 000b 0000 0001.
FILEFLAGSMASK fileflags The valid bits in FILEFLAGS statement. Use any of the fileflags
constants, which are described in the section “Constants” on page 208.
FILEFLAGS fileflags The Boolean attributes of a file. Use any of the fileflags constants, which
are described in the section “Constants” on page 208.
FILEOS fileos The operating system for a file. Use any of the fileos constants, which are
described in the Constants section. The values 0x00002L, 0x00003L,
0x20000L, and 0x3000L are reserved.
Parameter Description
lang-charset A string containing a hexadecimal number that represents a character set. The string is a
concatenation of the langID and charsetID constants, which are described in the section
“Constants” on page 208.
string-name The name of the corresponding value in the VALUE statement. Use a custom string or
one of the string-name constants, which are described in the section “Constants” on
page 208.
value The value of the corresponding string-name in the VALUE statement.
Parameter Description
langID A string containing a hexadecimal number that represents a language. Use any of the
langID constants, which are described in the Constants section.
charsetID A string containing a hexadecimal number that represents a character set. Use any of
the charsetID constants, which are described in the Constants section.
Chapter 14, Working with version information and custom data types 207
Constants
If you include the ver.h file in the resource script file that contains the version
information resource, you can use constants for the fileflags, fileos, filetype, subtype, langID,
and charsetID parameters.
fileflags
You can specify the following constants for the fileflags parameter:
Constant Description
VS_FF_DEBUG Debugging—file contains debugging information or was compiled with
debugging features enabled.
VS_FF_INFOINFERRED Incorrect version information—file contains a dynamically created
version information resource with possible empty or incorrect blocks. Do
not use this value in version information resources created with the
VERSIONINFO statement.
VS_FF_PATCHED Patch—file has been modified; it is not identical to the original shipping
file of the same version number.
VS_FF_PRERELEASE Prerelease—file is a development version, not a commercially released
product.
VS_FF_PRIVATEBUILD Private build—file was not built using standard release procedures.
When you use this value, include the PrivateBuild string in the string-
name parameter.
VS_FF_SPECIALBUILD Special build—file was built by the original company using standard
release procedures, but is a variation of the standard file of the same
version number. When you use this value, include the SpecialBuild string
in the string-name parameter.
fileos
You can specify the following constants for the fileos parameter:
Constant Description
VOS_UNKNOWN File designed for unknown operating system.
VOS_DOS File designed for MS-DOS.
VOS_NT File designed for Windows NT.
VOS_WINDOWS16 File designed for Windows 3.0 or later.
VOS_WINDOWS32 File designed for Windows 32-bit.
VOS_DOS_WINDOWS16 File designed for Windows 3.0 or later running on MS-DOS.
VOS_DOS_WINDOWS32 File designed for Windows 32-bit running on MS-DOS.
VOS_NT_WINDOWS32 File designed for Windows 32-bit running on Windows NT.
filetype
You can specify any of the following constants for the filetype parameter:
Constant Description
VFT_UNKNOWN File type is unknown to Windows.
VFT_APP File contains an application.
VFT_DLL File contains a dynamic-link library.
subtype
If the FILETYPE statement specifies VFT_DRV, you can specify any of the following
constants for the subtype parameter:
Constants Description
VFT2_UNKNOWN Driver type is unknown to Windows.
VFT2_DRV_COMM File contains a communications driver.
VFT2_DRV_PRINTER File contains a printer driver.
VFT2_DRV_KEYBOARD File contains a keyboard driver.
VFT2_DRV_LANGUAGE File contains a language driver.
VFT2_DRV_DISPLAY File contains a display driver.
VFT2_DRV_MOUSE File contains a mouse driver.
VFT2_DRV_NETWORK File contains a network driver.
VFT2_DRV_SYSTEM File contains a system driver.
VFT2_DRV_INSTALLABLE File contains an installable driver.
VFT2_DRV_SOUND File contains a sound driver.
If the FILETYPE statement specifies VFT_FONT, you can specify any of the following
constants for the subtype parameter:
Constant Description
VFT2_UNKNOWN Font type is unknown to Windows.
VFT2_FONT_RASTER File contains a raster font.
VFT2_FONT_VECTOR File contains a vector font.
VFT2_FONT_TRUETYPE File contains a TrueType font.
If the FILETYPE statement specifies VFT_VXD, you can’t specify a value for the subtype
statement.
langID
You can specify any of the following constants for the langID parameter:
Chapter 14, Working with version information and custom data types 209
Constant Description Constant Description
0x0404 Traditional Chinese 0x041B Slovak
0x0405 Czech 0x041C Albanian
0x0406 Danish 0x041D Swedish
0x0407 German 0x041E Thai
0x0408 Greek 0x041F Turkish
0x0409 U.S. English 0x0420 Urdu
0x040A Castilian Spanish 0x0421 Bahasa
0x040B Finnish 0x0804 Simplified Chinese
0x040C French 0x0807 Swiss German
0x040D Hebrew 0x0809 U.K. English
0x040E Hungarian 0x080A Mexican Spanish
0x040F Icelandic 0x080C Belgian French
0x0410 Italian 0x0810 Swiss Italian
0x0411 Japanese 0x0813 Belgian Dutch
0x0412 Korean 0x0814 Norwegian–Nynorsk
0x0413 Dutch 0x0816 Portuguese
0x0414 Norwegian–Bokmal 0x081A Serbo-Croatian (Cyrillic)
0x0415 Polish 0x0c0C Canadian French
0x0416 Brazilian Portuguese 0x100C Swiss French
0x0417 Rhaeto–Romanic
charsetID
You can specify any of the following constants for the charsetID parameter:
Constant Description
0 7-bit ASCII
932 Windows, Japan (Shift - JIS X-0208)
949 Windows, Korea (Shift - KSC 5601)
950 Windows, Taiwan (GB5)
1200 Unicode
1250 Windows, Latin-2 (Eastern European)
1251 Windows, Cyrillic
1252 Windows, Multilingual
1253 Windows, Greek
1254 Windows, Turkish
1255 Windows, Hebrew
1256 Windows, Arabic
Constant Description
Comments Additional information for diagnostic purposes. Optional.
CompanyName The company that produced the file. Required.
FileDescription File description. You can display this string in a list box during installation.
Required.
FileVersion File version number. Required.
InternalName File internal name. If file does not have internal name, use original filename,
without extension. Required.
LegalCopyright File copyright notices. Optional.
LegalTrademarks Trademarks and registered trademarks that apply to file. Optional.
OriginalFilename Original file name, not including path. Required.
PrivateBuild Information about private version of file. Required if VS_FF_PRIVATEBUILD is
set in FILEFLAGS.
ProductName Name of product that file is distributed with. Required.
ProductVersion Version of product that file is distributed with. Required.
Special Build Specifies how this version of file differs from standard version. Required if
VS_FF_SPECIALBUILD is set in FILEFLAGS.
Chapter 14, Working with version information and custom data types 211
The filename parameter
The name of the DOS file containing the user data. A full path name can be used to
specify files which are not in the current working directory. The data in the specified file
is included in the current project.
Chapter 14, Working with version information and custom data types 213
UnlockResource(hRCDataMem);
FreeResource(hRCDataMem);
For more information about using a resource for a custom data type in an application,
search the Windows 3.1 SDK Help file (WIN31WH.HLP) for “FindResource (2.x).”
Using EasyWin
Appendix A
A
EasyWin is a feature of Turbo C++ that lets you compile standard DOS applications that
use traditional “TTY style” input and output so they run as true Windows programs.
EasyWin does not require you to make any changes to a DOS program in order to run it
under Windows.
To convert your console-based applications that use standard files or iostream
functions, check the EasyWin Target Type in TargetExpert in the IDE. If you are using
the command-line compiler, use the compiler switch –W. Turbo C++ notes that your
program doesn’t contain a WinMain function (normally required for Windows
applications) and links the EasyWin library. When you run your program in Windows,
a standard window is created, and your program takes input and produces output for
that window exactly as if it were the standard screen:
The EasyWin window can be used any time input or output is requested from or to a
TTY device. This means that in addition to stdin and stdout, the stderr, stdaux, and cerr
“devices” are all connected to this window.
_InitEasyWin( )
EasyWin’s purpose is to convert DOS applications to Windows programs, quickly and
easily. However, you might occasionally want to use EasyWin from within a “true”
#pragma argsused
int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance,
LPSTR lpszCmdLine, int cmdShow)
{
_InitEasyWin();
Added functions
EasyWin also includes five functions that let you specify the X and Y window
coordinates for input and output, clear the window, or clear to the end of the current
line:
These functions have the same names (and uses) as functions in conio.h header file.
Classes in constrea.h provide conio functionality for use with C++ streams. See the
Turbo C++ Programmer’s Guide for information on constreams and iostreams. See online
Help for a description of the functions available to EasyWin programs.
The following routines are portable to EasyWin programs but are not available in 16-bit
Windows programs. They are provided to ease porting of existing code into a Windows
16-bit application.
Precompiled headers
Appendix B
B
Turbo C++ can generate and subsequently use precompiled headers for your projects.
Precompiled headers can greatly speed up compilation times.
Establishing identity
To use a precompiled header, a file must
• Have the same set of include files, in the same order, as the precompiled header
• Have the same macros defined to identical values as the precompiled header
• Use the same language (C or C++) as the precompiled header
\* BSOURCE.C *\
#include "yyy.h"
#include <string.h>
#include "myhdr.h"
#include <windows.h>
<...>
Error messages
Appendix C
C
This appendix describes the error messages that can be generated by Turbo C++. The
error messages in this appendix include messages that can be generated by the
compiler, linker, and the Windows Help compiler. This appendix also lists the errors
that you can receive when you run your program (run-time errors).
Messages are listed in ASCII alphabetic order. Messages beginning with symbols come
first, then messages beginning with numbers, and then messages beginning with letters
of the alphabet. Messages that begin with symbols are alphabetized by the first word in
the message that follows the symbols. For example, you might receive the following
error message if you incorrectly declared your function my_func:
my_func must be declared with no parameters
To find this error message, look under the alphabetized listing of “must.”
Message classes
Messages fall into three categories: fatal errors, errors, and warnings.
Fatal errors
Fatal errors can be generated by the compiler and linker. Fatal errors cause the
compilation to stop immediately; you must take appropriate action to fix the error
before you can resume compiling.
If the compiler issues a fatal error, no .EXE file is created. If the linker issues a fatal error,
any .EXE file that might have been created by the linker is deleted before the linker
returns.
Warnings
Warnings can be issued by the compiler, the linker, and the librarian. Warnings do not
prevent the compilation from finishing. However, they do indicate conditions that are
suspicious, even if the condition that caused the warning is legitimate within the
language. The compiler also produces warnings if you use machine-dependent
constructs in your source files.
Message explanations
‘)’ missing in macro invocation MAKE error
A left parenthesis is required to invoke a macro.
( expected Compiler error
A left parenthesis was expected before a parameter list.
) expected Compiler error
A right parenthesis was expected at the end of a parameter list.
, expected Compiler error
A comma was expected in a list of declarations, initializations, or parameters.
: expected after private/protected/public Compiler error
When used to begin a private/protected/public section of a C++ class, these reserved words must be followed by a
colon.
< expected Compiler error
The keyword template was not followed by a left angle bracket ( < ). Every template declaration must include the
template formal parameters enclosed within angle brackets ( < > ), immediately following the template keyword.
> expected Compiler error
A new-style cast (for example, dynamic_cast) is missing a closing “>”.
@ seen, expected a response-files name Librarian error
The response file is not given immediately after @.
{ expected Compiler error
A left brace ( { ) was expected at the start of a block or initialization.
} expected Compiler error
A right brace ( } ) was expected at the end of a block or initialization.
16-bit segments not supported in module module Linker error
16-bit segments aren’t supported in 32-bit applications. Check to make sure that you haven’t inadvertently compiled
your 32-bit application using the 16-bit compiler.
286/287 instructions not enabled Compiler error
Use the –2 command-line compiler option or the 80286 options from the Options|Compiler|Code Generation|
Advanced Code Generation dialog box to enable 286/287 opcodes. The resulting code cannot be run on 8086- and 8088-
based machines.
32-bit record encountered Linker error
An object file that contains 80386 32-bit records was encountered, and the /3 option had not been used.
Abnormal program termination Run-time error
The program called abort because there wasn’t enough memory to execute. This can happen as a result of memory
overwrites.
struct A:virtual VB
{
virtual f();
};
struct B:virtual VB
virtual f();
};
struct D1 : virtual VB
{
void f();
};
struct D2 : virtual VB
{
void h();
};
struct DD : D1, D2
{
}
v; // error: 'DD' is an abstract class
The above code fragment generates the following two error messages:
Error <filename> 21, Cannot creat3e instance of abstract class 'DD'
Error <filename> 21: Class 'DD' is abstract because of 'VB::g() = 0'
Code has no effect Compiler warning
The compiler encountered a statement with operators that have no effect. For example, the statement
a + b;
has no effect on either variable. The operation is unnecessary and probably indicates a bug in your file.
Colon expected MAKE error
Your implicit rule is missing a colon at the end.
.c.obj: # Correct
.c.obj # Incorrect
Command arguments too long MAKE error
The arguments to a command were more than the 511-character limit imposed by DOS.
Command syntax error MAKE error
This message occurs if
void main()
{
f(0);
}
The compiler issues an error message for each nesting of the recursive instantiation; it’s usually obvious where the
recursion has occurred. To fix a recursive template, either change the dependencies, or provide a specialized version that
stops the recursion. For example, adding the following function definiton to removes the endless recursion:
A<int> x;
This code will be flagged with the following errors:
Error: Template class nesting too deep: 'B<int * * * * *>'
Error: Template class nesting too deep: 'A<int * * * *>'
Error: Template class nesting too deep: 'B<int * * * *>'
Error: Template class nesting too deep: 'A<int * * *>'
Error: Template class nesting too deep: 'B<int * * *>'
Error: Template class nesting too deep: 'A<int * *>'
abc.exe : b.obj
abc.exe : c.obj
bcc -c b.c c.c
Too many storage classes in declaration Compiler error
A declaration can never have more than one storage class.
Too many suffixes in .SUFFIXES list MAKE error
The limit of 255 allowable suffixes in the suffixes list has been exceeded.
Too many types in declaration Compiler error
A declaration can never have more than one of the basic types: char, int, float, double, struct, union, enum, or typedef–
name.
Too much global data defined in file Compiler error
The sum of the global data declarations exceeds 64K bytes. Check the declarations for any array that might be too large.
Also consider reorganizing the program or using far variables if all the declarations are needed.
Trying to derive a far class from the huge base base Compiler error
If a class is declared (or defaults to) huge, all derived classes must also be huge.
Index 273
autodependency information metafiles vs. 205 Build All command (Project) 41,
MAKE 46 properties, setting 196 64
Project Manager 20 resizing 196 Build Node option 42
autodependency nodes 20, 40 resource scripts and 138 building projects 35
automatic error tracking 43 blank lines in code canceling builds 41
automatic file linkage 20 breakpoints and 97 MAKE vs. 41
Automatic Horizontal Scroll .BMP files 143 specific parts 42
property 165 Boolean expressions BUILDSYM.EXE 129
Automatic Vertical Scroll breakpoints and 99 buttons
property 165 Border property 161 See also specific types
automatically generating borders 189 Alignment palette
underscores 46 dialog boxes 150, 152, 161 (resources) 148
automatically saving IDE main windows 71 dialog boxes 152
settings 17 pop-up windows 167 IDE SpeedBars 9
automation servers See servers Borland Assist program 4 adding/deleting 16
(automation) Borland C++ compiling options 41
starting IDE 7 customizing 16
Borland resource compilers See Tools palette (resources) 148,
B BRCC.EXE; BRCC32.EXE 188
-b compiler option 45 Borland resource linkers See byte-wise alignment 48
background colors RLINK.EXE; RLINK32.DLL
dialog boxes 149 Borland Visual Solutions C
graphics resources 189 Pack 153
main windows 71 /C linker option 55
break character (fonts) 199
syntax highlighting 15 /c linker option 55
Breakpoint command 97
backward compatibility C calling convention 48
Breakpoint Properties dialog
loading project files 27 C language See ANSI C; Borland
box 98, 99
base classes C++
breakpoints 96–100
compiler options 52 See also debugging C++ Options option (Project
BBN_GOTABTAB message 153 conditional 99 Options) 52–54
BBN_GOTATAB message 153 customizing colors 100 Call Stack command 107
BBN_SETFOCUS message 153 deleting 98 Call Stack window 107–108
BBN_SETFOCUSMOUSE disabling 97 opening 107
message 153 invalid 97, 100 Calling Convention option
BCC.EXE properties 98–100 (Project Options) 48
See also command-line setting 95, 96–97 calling conventions
compilers after program start 96 fastthis 45
BCC32.EXE pass counts and 99 Pascal See Pascal
See also command-line skipping over 99 calls
compilers viewing 97, 100 far 57
BCCONFIG.BCW 17 Breakpoints window 97 function See function calls
BCDEF.CSM 217, 218 opening 97 optimizing 57
reducing size 219 Brief editor, emulating 15 Windows programs See
BCWDEF.DSW 17 Browse Symbol command Windows API calls
big attribute 56 (Search) 86 canceling builds 41
binary data 134 browser (IDE) 85–88 Caption property 160
WinSpector reports, configuring 87 Caption Type property 161
processing 126 customizing 88 captions
binary files error messages 86 controls 160, 161
resources 142–143 filters, setting 87 main windows 71
bit fields overview 86–87 cascading menus 173, 178
ACBP (Intel) 56 searching for symbols 88 case
bitmap buttons 162 starting 85, 86 controls, setting 164
bitmapped fonts 198–199 brushes (resources) 190 Case property 164
bitmaps 187, 201, 202 buffers case sensitivity
See also graphics transfer 80 external symbols 55
public symbols 55
Index 275
shortcuts 41 .CPP files 10 renaming 50
Compiler Output option (Project CPU uninitialized 50
Options) 46 flags 106 data types
compilers 217 registers, checking 106 char
See also command-line Create option (Style Sheets) 37 treating as unsigned 45
compilers creating compiler options 45, 53
error messages 222 new program files 10 resources, customizing 205,
Help systems 22, 222 DOS platforms 11 206, 211–212, 213
warnings, ignoring 13 Windows platforms 12 databases 153
compiling errors new projects 21–23, 36, 58 -dc compiler option 49
viewing 43 resources See Resource Debug command (IDE) 8
Compose option (Style Workshop Debug menu 89
Sheets) 37 Source Pools 29 debugger 89
compressed formats .CSM files 218 accessing 89
bitmaps 196 reducing size 219 compiler options and 92
fonts 198 CTL3D2V.DLL 169 controlling program
conditional breakpoints 99 Ctrl-key shortcuts 176 execution 92–96
disabling 97 .CUR files 143 deleting breakpoints 98
pass counts and 100 cursors disabling breakpoints 97
conditions position, Edit window 9 evaluating expressions 100,
breakpoints (defined) 99 cursors (graphics 101, 103–105
conforming extensions 46 resources) 187, 202, 203 changing values and 105
console applications creating 195–196 restrictions 103
converting to Windows 215 defining hot spots 196 examining register values 106
constants inverted areas 189 execution point 93, 100, 107
resources properties, setting 196 flickering screens,
versions 208–211 removing images 195 eliminating 91
Control ID property 162 testing 195 inspecting data elements 105
control-menu box transparent areas 189 invalid breakpoints 97, 100
adding to main window 71 viewing 194 loading symbol tables 109
controls 69, 80 Custom Control tool logging messages 108
See also resources (resources) 154 moving through code 93–95
aligning 148, 157–160 customer assistance 4 single stepping 93
text 161, 163 customizing Resource multiple statements and 92
arranging 159 multitasking and 109
Workshop 144–145
captions 160, 161 restarting programs 95
customizing the IDE 14–17
custom 153–154 running programs 91–92
CWH.HLP 22 to breakpoints 95
dialog boxes See dialog boxes
setting breakpoints 95, 96–97
focus, setting 153
grouping/ungrouping 157
D after program start 96
conditional 99
installing 153 -d compiler option 45 pass counts and 99
invisible 161 data starting 90
moving 155, 156 alignment stepping over code 94
naming 161 compiler options 48 stopping programs 95, 99,
painting 149 binary 134 108
resizing 155–156 WinSpector reports, symbolic debug
selecting 154, 161 processing 126 information 91, 93
tab order 157 far 50 DLLs and 109
three-dimensional 153, 169 IDE options 22 tracing into code 93–94, 107
conversions inspecting 105 DLLs and 109
DOS applications to resources and 135 viewing breakpoints 97, 100
Windows 215–216 values, changing 104, 105 watching expressions 101–
Convert OEM property 165 data objects 90 103
Copy option (Style Sheets) 38 data segments deleting watches 103
copying project nodes 26–27 compiler options 49, 50 disabling watches 102
copyright information 70 detailed maps 56 formatting watches 102,
resources 211 removing virtual tables 49 104
Index 277
DRAWAPP.CPP 65–67 resources 135, 138, 141, 206 Evaluate/Modify command 103
drawapp.h 65 dialog boxes 147–149 event handlers 76, 79
drawing 190–192, 200 graphics 187–188 deleting 79
brush shapes 190 in binary files 142 renaming 83
paint patterns 190 in graphics files 144 Event Log command 108
pen styles 189 in script files 136 Event Log window 100, 108
pop-up windows 149 menus 171–172 opening 108
drawing routines 149 string tables 183 events 75
drawing tools (resources) 148, Style Sheets 38, 41 exceptions 122
188, 200 editors 10 addresses 123
drive specifier 43 ClassExpert 76 compiler options 54
reconfiguring IDE 15 logging 122–126
drivers
resource scripts 135–136, 206 run-time identification 54
resources and 209
EGA/VGA Resolution .EXE files See executable files
drop-down lists See combo boxes
command (resources) 194, 195 executable files 129
.DSW files 17
ellipses, drawing 191 including debug
duplicate strings, merging 45
Enable Breakpoint command 98 information 91
Duplicate tool (resources) 159
Enable Watch command 103 reducing size 91
dynamic link libraries See DLLs
enabling menu commands 174 viewing 85
dynamic objects 54
enabling run-time type EXEMAP.EXE 128
information 54 exit code 51
E enhanced mode Exit command (Spy) 112
EasyWin 215–216 packing code segments 55 expanding lists
edit boxes 152 Entry/Exit Code option (Project AppExpert hierarchies 62
new lines 164 Options) 51 dialog boxes 14
properties, setting 164 enumerations Project Manager 20
Edit Breakpoint command 97, 98 treating as integers 45 export functions
Edit command (IDE) 8 environment compiler options 51–52
Edit Local Options command saving IDE settings 17 prologs and epilogs 51, 52
(IDE) 39 Environment command Expression Evaluator dialog
Edit menu (Options) 14 box 103–104
adding to menu bars 173 Environment Options dialog expressions
edit modes (IDE) 9 box 14 Boolean
Edit Node Attributes option 24, changing debugging breakpoints and 99
31 modes 110 changing 103
Edit option (Style Sheets) 38 expanding/contracting current value, viewing 101
Edit Source command 97, 107 lists 14 debugging 100–106
Edit window (IDE) 43 Project View options 28 evaluating 100, 101, 103–105
customizing 15 Epsilon editor, emulating 15 restrictions 103
debugging programs 92, 93, Eraser tool (resources) 192 inspecting 105
94, 96 error messages 221–271 logging 100, 108
deleting breakpoints 98 browser 86 Extend Select property 166
examining code 97, 107 compiler 54, 222 Extended Style property 151
inspecting data Help compiler 222 extensions
elements 105 IDE 42, 43 See also file-name extensions
setting watches 101 resources 183, 213 language, conforming 46
loading source files 21, 43 errors 43, 222 external modules 55
opening 10 automatically tracking 43 external programs,
overview 9 fatal 221, 222 debugging 95
SpeedMenu, activating 9 logic 90 external symbols 55
editing makefiles 222
code 43 run-time 89–90, 222 F
AppExpert 65, 66 syntax 42–43
Breakpoints window 97 TLINK 222 -f compiler option 46
Call Stack window 107 unrecoverable /f linker option 57
ClassExpert window 76 application 120, 127 far calls 57
node attributes 24, 26 viewing 43 far data 50
Index 279
brush shapes and warnings 218 inverted areas 189
patterns 190 heap, tracing into 126 properties, setting 197
colors 189, 195, 197 Height property 160 removing images 195
changing 200 Help command (IDE) 8 testing 195
creating See Graphic editor See also online help transparent areas 189
drawing and painting 189– Help compiler 22 viewing 194
192, 200 messages 222 ID source/Control ID
editing scripts 187–188 Help files, searching through property 161
enabling grids 201 multiple 4 ID Value property 161
erasing 192 Help menu 3 IDABORT constant 162
flood-filling algorithm 191 adding to menu bars 173 IDCANCEL constant 162
large 194 Help systems 61, 69, 222 .IDE files 21, 82
moving 194 About dialog box 70 See also project files
pen styles 189 Hex Values (WinSight IDE 7–18, 218
resource scripts and 138 option) 116 adding tools 31–33
RLE compression hexadecimal numbers browsing classes and
algorithm 196 resources and 212 objects 85–88
screen resolution, setting 194 customizing 14–17
hexadecimal values
source code for 201–203 keyboard shortcuts 15
watches and 102, 104
testing 195 Tool menu 18
viewing 194 Hide Palette command
(resources) 200 defining macros 45
multiple images 199 disabling invalid
zooming 194, 201 Hide Toolbox command
(resources) 200 breakpoints 97
graphics files displaying errors 42, 43
resources 143–144 hiding IDE SpeedBars 16
Edit window See Edit window
Grid command (resources) 159 hierarchies (classes) 86
generating resources 142
grids hierarchy trees See Project Tree integrated debugger,
aligning controls 159 history, recording 108 starting 90
enabling 201 See also log files menu 8
group boxes 152 Horizontal Scroll Bar predefined Style Sheets 36
properties, setting 164 property 161 preferences 17
Group property 157 horizontal scroll bars 164 Project Manager See Project
dialog boxes 152, 161 Manager
H main windows 71 Resource Workshop, starting
Horizontal Scroll property 150 from 135
-H compiler option 48 hot spots (cursors) 196 restoring defaults 17
-h compiler option 50 -Hu compiler option 48 running programs 18, 91–92
Hand tool (resources) 194 huge pointers saving settings 17
handlers compiler options 50 setting command-line options
See also event handlers debugging 47
hardware 2 I messages 54
Has Strings property 166 SpeedBars 9, 16
hdrfile pragma directive 218 -i compiler option 46 hiding 16
hdrstop pragma directive 219 /i linker option 57 SpeedMenus 9
Header command I/O starting 7
(resources) 197 See also input; output viewing program status 9
header files .ICO files 143 windows 16
compiler options 48 icons See also specific window
parsing 217 Alignment palette 148 identical SpeedBars 17
referencing 29 program 7 identifiers
resources 141, 142 Tools palette 148, 188 See also names
headers used in documentation 3 conflicts 46
containing code 218 icons (graphics resources) 138, generating underscores
precompiled 217–220 187, 202, 203 automatically 46
compiler options 218, 219 as controls 152, 167 resources 136, 140–142, 184
optimizing 219–220 colors, setting 197 accelerators 179
storing 217, 218 creating 195–196 changing 178, 181, 184
checking for duplicate 177
Index 281
adding comments 122 Member Pointer option (Project Help compiler 222
tracking exceptions 122–126 Options) 52 input
logging expressions 100, 108 memory controls 165
logging messages 108 allocation logging 108
logic errors 90 resources 139, 184, 211 saving WinSight 116
logical addresses 123 dump 104 tracing 112, 113, 115–120
loops location, watching 104 Messages option (Project
debugging 100 memory addresses Options) 54
pointers 104 metafiles 205
M Memory Model option (Project
Options) 49
Minimize Box property 150
minimize boxes
/M linker option 56 memory models main windows 71
/m linker option 56 See also specific model -ml compiler option 49
machine instructions See compiler options 49 -mm compiler option 49
instructions specifying 22 -mm! compiler option 49
machine-dependent Memory Options command modal dialog boxes 170
constructs 222 (resources) 139 Modal Frame property 150
macros menu bars 172–173 modes
defining 45 menu commands debugging 109
MAKE See MAKE adding to menus 173–176 memory 55
precompiled headers and 218 associating with module definition files
undefining 45 shortcuts 174, 175–176 case sensitivity 55
main windows checking for duplicate modules
AppExpert options 69, 71 names 177 compiling large 217
dialog boxes as 61, 149 display options 174 debugging information
disabling at startup 71 flashing 175, 176 and 91
.MAK files See makefiles Help text and 175 linking 55
MAKE manipulating 176 sharing objects 49
autodependency viewing 172 tracing into 125
information 46 Menu editor (resources) 171–172 moving controls 155, 156
building vs. 41 customizing 178 moving through Message
Make All command (Project) 41 starting 171 window 43
Make option (Project Menu property 149 moving through source code 93–
Options) 58 menus 171 95
makefiles adding to menu bars 172–173 single stepping 93
errors 221, 222 associating with -ms compiler option 49
mangled names 45 shortcuts 173 -ms! compiler option 49
linking and 56 creating See Menu editor Multi Column property 166
manifest constants See macros deleting 176 multiple controls, selecting 154
map files 56 dialog boxes 149 multiple Help files, searching 4
adding symbols 56 editing scripts 171–172 multiple inheritance 52
creating 128 floating 177 Multiple Select property 165
suppressing build 56 IDE 8
multiple-document interface
viewing code 57 moving 176
separators 173, 174 applications See MDI
Maximize Box property 150 applications
maximize boxes source code for 181–182
testing 177, 178 multitasking
main windows 71 debugger and 109
MDI applications 61, 68 viewing 172
merging duplicate strings 45 MULTITRG.IDE 25
AppExpert options 72, 73
medium memory models Message Trace Options dialog
compiler options, setting 49 box 116 N
member functions Message window 42 -N compiler option 47
debugging 95 messages -n compiler option 44
inline See also notification messages; /n linker option 55
compiler options 53 prompts
names
expansion 47 command-line options 54
See also identifiers
precompiled headers 218 error See error messages
Index 283
compiler options 49, 50 crashing 108 project nodes (IDE) 20
huge debugging See debugging See also Project Tree
compiler options 50 execution Project Options dialog box 36
memory addresses 104 controlling 90, 92–96 setting options 43
suspicious 49 pausing 95, 99 Project Style Sheet 36
pop-up windows 147 terminating 95 settings, overriding 36
See also dialog boxes external 95 Project Tree 20–21
drawing 149 failing 89 See also Project Manager
frames 167 history, recording 108 expanding/contracting
menus 149 implementation, problems lists 20
overlapping 151 with 90 nodes
properties 149–151 large 217 adding 24, 25, 42
-pr compiler option 49 linking See linkage compiling 29
#pragma directives running 13 copying 26–27
precompiled headers from the IDE 18 deleting 24, 26, 27
and 218, 219 in the IDE 91–92 editing 24, 26
precompiled headers 217–220 to breakpoints 95 moving 26
compiler options 48, 218, 219 to specific locations 92 option settings 35
optimizing 219–220 single-source 13 out-of-date 41
storing 217, 218 stepping through 93–95 referencing 29
warnings 218 single stepping 93 specifying 23
Precompiled Headers option testing 10, 90, 104 Style Sheets 36, 39
(Project Options) 48 tracing into 125 translating 24, 30, 41, 42
type, setting 11, 12 types, defined 20
predefined colors
watching 91 viewing 28
Project Manager 20 settings 40
syntax highlighting 15 Project command (IDE) 8
Project command (Options) 36 Project View options 28
predefined resources 153, 172,
Project command (View) 24 Project window
211 customizing 28
predefined Style Sheets project files 62, 69
See also projects generating symbolic debug
attaching to nodes 36 information 91
backward compatibility 27
preferences (IDE) 17 opening 24
browsing 85
Preferences command SpeedBar buttons 9
including debug
(Environment) 43 information 91 viewing resources 144
preserving IDE error opening 41 project-manager utility See
messages 43 rearranging in IDE 26 MAKE
printing 68 targets 36 projects
WinSight messages 116 adding 25 See also project files; Project
printing conventions changing defaults 21 Manager
(documentation) 3 defining multiple 29 adding source files 24
.PRJ files 27 deleting 26 building 41
Processor option (Project dependent files 20 parts of 42
Options) 48 setting options 21–23 canceling builds 41
program files updating 29, 41 compiling See compilation
adding to Tool menu 31 testing 10 creating new 21–23, 36, 58
creating new 10 viewing 20 importing earlier versions 27
DOS platforms 11 Project Manager (IDE) 19, 20–29 linking See linkage
Windows platforms 12 adding files 24 managing 19
default 10 creating projects 21–23, 36 options 35
status in Edit window 10 glyphs 21 changing 28
program group 7 loading preexisting project inheriting 36, 38
Program Manager files 27 setting defaults 58
Resource Workshop, starting Project Tree See Project Tree viewing 40
from 135 setting target options 21–23 sample
programs SpeedMenus 9 multi-targets 25
See also DOS programs; Style Sheets See Style Sheets Source Pools 30
Windows programs translators, specifying 25, 30 Style Sheets 36
compiling See compilation Project menu 41 setting up 10
Index 285
Style Sheets 36 Set Groups command editing
Save Events To File (resources) 157 Breakpoints window 97
command 108 Set Groups tool (resources) 157 Call Stack window 107
Save Resource As command Set Hot Spot command generating with
(resources) 138 (resources) 197 AppExpert 64, 70
saving Set Options command 108 graphics 201–203
IDE settings 17 Set Or Clear An Unconditional machine-dependent
window settings 17 Breakpoint button 96 constructs 222
scalars, inspecting 105 Set Order tool (resources) 157 menus 181–182
scanned photographs 196 moving through 93–95
Set Range command 106
Scissors tool (resources) 193 single stepping 93
Set Watch command 101 viewing 76, 81, 91, 97, 107
screens SetCursor member function
flickering, eliminating 91 source files 19
TWindow 202 accessing 21
resolution 194 SetIcon member function
Script editor (resources) 206–212 adding to projects 24
TFrameWindow 202 Edit window 21, 43
starting 206 setting breakpoints 95, 96–97 fixing errors 43
Scroll Bar Always property 166 after program start 96 rearranging in IDE 26
scroll bars 164 setting watches 101 viewing 21
combo boxes 166 settings WinSpector reports 127
dialog boxes 152, 161 reconfiguring IDE 15–17 source nodes (IDE) 20
list boxes 166 resources See properties See also Project Tree
main windows 71 saving IDE 17 adding 24
SDI applications 61, 68, 72 window 17 attributes 24
creating 62 shapes, drawing 191 deleting 24
Search command (IDE) 8 shortcuts referencing 29
search operations compiler options 41 specifying 23
online help 4 keyboard translating 24
symbols 88 adding to menus 173, 174, viewing 28
search paths See directory paths 175–176 Source option (Project
Second Graphic command IDE windows 15 Options) 46
(resources) 178 Show Palette command Source Pools 29–30
Segment Names Data option (resources) 200 compiling nodes 29
(Project Options) 50 Show Project Node option 20 creating 29
segments Show Properties command Special command
code See code segments (resources) 160 (SpeedMenu) 31
compiler options 50–51 Show Toolbox command SpeedBars (IDE) 9
data See data segments (resources) 200 customizing 16
detailed maps 56 single-document interface hiding 16
renaming 50–51 applications See SDI SpeedMenus
trailing 57 applications AppExpert 62
Selected Classes command single-source programs 13 ClassExpert 76
(Messages) 113 Size and Attributes command IDE 9, 31
Selected Windows command (resources) 196, 197 adding tools 32
(Messages) 115 Size command (resources) 155 Split Horizontal command
Selector tool (resources) 154 Size Controls dialog box 155, 156 (resourcers) 200
separators small memory models Split Vertical command
dialog boxes 152 compiler options, setting 49 (resourcers) 200
menus 173, 174 software 2 spying on classes 113
deleting 176 Sort property 165, 166 spying on windows 115
moving 176 source code squares, drawing 191
viewing 172 accelerators 181–182 SRCPOOL.IDE 30
servers (automation) 70 debugging 91, 92, 104 stack
servers (linking and breakpoints and 96 IDE options 22
embedding) 70 execution point 93, 100, overflow 47
Set Grid Attributes dialog 107 tracing into 47, 122, 124, 127
box 159 dialog boxes 170
Index 287
TFrameWindow class translating project nodes 24, 30, unions
creating icons 202 41, 42 watching 104
members translators 30 unrecoverable application
SetIcon 202 specifying 25 errors 120, 127
Thick Frame property 150 truncated identifiers 46 updating targets 29, 41
this pointer TTY devices 215 user interfaces
compiler options 45 Turbo Debugger 127 components 134
three-dimensional controls 153, Turbo Pascal See Pascal dialog boxes as main 61, 68
169 turning off testing 90
title bars breakpoints 97 user-defined resources 205–214
main windows 71 drawing tools 200 utilities See specific C++ utility
TLINK message tracing 112
See also TLINK32
ACBP fields and 56
palettes 200 V
syntax highlighting 16
compiler options 53 underscores 46 -V compiler option 53
errors 222 watches 102 -v compiler option 47
options 55 -tW compiler option 51 /v linker option 55
TListView class 78 -tWD compiler option 52 -V0 compiler option 53
TMAPSYM.EXE 128 -tWDE compiler option 52 -V1 compiler option 53
TMenu class 181 -tWE compiler option 51 values
Toggle Breakpoint command 96, TWindow class ACBP fields 56
98 creating cursors 202 changing 103, 104, 105
Tool command (IDE) 8 members checking 90, 91, 100
Tool menu SetCursor 202 CPU registers 106
adding files 31 TWindowView class 78 decimal
customizing 18 -tWS compiler option 52 watches and 102, 104
toolbars 68 -tWSE compiler option 52 expressions, viewing 101
TOOLHELP.DLL 121 Type property 149, 151 floating-point
tools 30–33 check boxes 163 watches and 102, 104
adding to IDE 31–33 combo boxes 166 hexadecimal
adding to SpeedMenus 32 frames 167 watches and 102, 104
defined 30 group boxes 164 variables
Tools command (Options) 31 lines 167 See also environment variables
Tools dialog box 31 push buttons 162 communal 46, 50
Tools palette radio buttons 163 debugging 99, 103
Dialog editor 148, 152 rectangles 167 global 50
adding custom static text controls 163 initializing to nonzero
controls 154 typographic conventions values 46
Graphic editor 188 (documentation) 3 instance 76, 80
hiding 200 renaming 83
local 47
Top property 161 U register 45
Trace Into button 93
-u compiler option 46 values
Trace Into command 93–94 changing 103, 104
tracing into code 93–94, 107 UAEs 120
multiple 127 checking 90, 91, 100
See also debugging variable-width fonts 197, 198
DLLs and 109 undefined watches 101
undefining macros 45 ver.h 208
tracing messages verbose stack trace 122, 127
(WinSight) 112, 113, 115 underbars See underscores
underscores 46 version compatibility
Track Test Menu command loading project files 27
(resources) 178 Undo command (Edit) 10
version information
trailing segments, Undo command (resources) 160
(resources) 206–211, 213
uninitialized 57 undocumented Windows
header file 208
transfer buffers messages 116
version numbers 70
resources 80 uninitialized data segments 50
Vertical Scroll Always
transfer macros 31 uninitialized trailing
property 166
segments 57
Vertical Scroll Bar property 161
Index 289
configuring 121 Zoom In command
DFA utility and 127 (resources) 194
WinSpector 120–129 Zoom Out command
adding source files to (resources) 194
reports 127 Zoom tool (resources) 194
appending new reports 121 -zP compiler option 51
exception types 122 -zR compiler option 50
heap information 126 -zS compiler option 50
including line numbers in -zV compiler option 51
reports 127 -zW compiler option 51
listing functions 124
locating last message
received 124
modules list 125
options 121
overwriting previous
reports 121
processing data 126–128
program lists 125
reading log file 122–126
setting preferences 121
stack pointer 123
starting 121
system information
returning 126
tracing into stack 124
utilities 128–129
viewing reports 122
word alignment 48
word-processor documents 143,
153
-WS compiler option 52
-WSE compiler option 52
-w-xxx compiler option 55
-wxxx compiler option 55
X
-X compiler option 46
-x compiler option 54
/x linker option 56
-xd compiler option 54
-xp compiler option 54
Y
-y compiler option 47
Z
-zA compiler option 51
-zB compiler option 50
-zC compiler option 51
-zD compiler option 50
-zE compiler option 50
-zF compiler option 51
-zH compiler option 51
®
VERSION 4.5 Turbo C ++
Borland International, Inc., 100 Borland Way
P.O. Box 660001, Scotts Valley, CA 95067-0001
Redistributable files
You can redistribute the following files in accordance with the terms of the No-Nonsense License Statement:
Refer to the file REDIST.TXT in the \TCWIN45\DOC directory for a complete list of files that you can redistribute in
accordance with the No-Nonsense License Statement.
Borland may have patents and/or pending patent applications covering subject matter in this document. The
furnishing of this document does not give you any license to these patents.
COPYRIGHT © 1987, 1995 Borland International. 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.
Printed in the U.S.A.
1E0R1094
9495969798-9 8 7 6 5 4 3 2 1
H1
Contents
Introduction 1 Deleting target nodes . . . . . . . . . . . . . . 25
Editing target attributes using TargetExpert. . 26
What’s new in Turbo C++. . . . . . . . . . . . . .1 Moving nodes within a project . . . . . . . . . 26
Hardware and software requirements . . . . . .2 Copying nodes in a project . . . . . . . . . . . . 26
Manual conventions . . . . . . . . . . . . . . . . .3 Importing projects from older versions of
Getting help . . . . . . . . . . . . . . . . . . . . . .3 Turbo C++ . . . . . . . . . . . . . . . . . . . . 27
Searching through multiple Help files with Importing projects from Borland C++ . . . . . 27
OpenHelp . . . . . . . . . . . . . . . . . . . . . .4 Customizing the Project window . . . . . . . . 28
Software registration and technical support . . . 4 Grouping sets of files with Source Pools . . . . 29
Creating a Source Pool . . . . . . . . . . . . . . 29
Part I Translators, viewers, and tools . . . . . . . . . . 30
Using the integrated development Adding translators, viewers, and tools to the
IDE . . . . . . . . . . . . . . . . . . . . . . . . . 31
environment 5
Chapter 3
Chapter 1 Specifying project options and
Getting started 7 compiling 35
Starting the Turbo C++ IDE. . . . . . . . . . . . . 7 Setting project options . . . . . . . . . . . . . . . 35
The IDE menu system . . . . . . . . . . . . . . . .8 Using Style Sheets . . . . . . . . . . . . . . . . . 35
The IDE SpeedBar . . . . . . . . . . . . . . . . . .9 Predefined Style Sheets . . . . . . . . . . . . . 36
Using SpeedMenus in the IDE . . . . . . . . . . . 9 The default project options . . . . . . . . . . . 36
Using the Edit window . . . . . . . . . . . . . . . 9 Managing Style Sheets. . . . . . . . . . . . . . 37
Creating a new file . . . . . . . . . . . . . . . . . 10 Attaching Style Sheets to a node . . . . . . . . 38
Working with simple projects . . . . . . . . . . 10 Sharing Style Sheets between projects . . . . . 38
Creating an EasyWin Program . . . . . . . . . . 11 Setting local overrides. . . . . . . . . . . . . . . 39
Creating a Windows program . . . . . . . . . . 12 Viewing project options . . . . . . . . . . . . . . 40
Single file programs . . . . . . . . . . . . . . . . 13 Compiling projects . . . . . . . . . . . . . . . . . 41
Customizing the IDE . . . . . . . . . . . . . . . . 14 Compiling part of a project. . . . . . . . . . . . 42
Configuring the IDE editor . . . . . . . . . . . . 15 Fixing compile-time errors. . . . . . . . . . . . . 42
Syntax highlighting. . . . . . . . . . . . . . . . . 15 Viewing errors . . . . . . . . . . . . . . . . . . . 43
Customizing the SpeedBars. . . . . . . . . . . . 16 Fixing errors . . . . . . . . . . . . . . . . . . . . 43
Setting IDE preferences . . . . . . . . . . . . . . 17 Project options reference . . . . . . . . . . . . . . 43
Saving your IDE settings . . . . . . . . . . . . . 17 Directories. . . . . . . . . . . . . . . . . . . . . . 43
Running other programs from the IDE . . . . . 18 File-search algorithms . . . . . . . . . . . . . . 44
Compiler . . . . . . . . . . . . . . . . . . . . . . 44
Chapter 2 Defines . . . . . . . . . . . . . . . . . . . . . . . 45
Code generation . . . . . . . . . . . . . . . . . 45
Creating and managing projects 19 Floating Point . . . . . . . . . . . . . . . . . . . 46
What is project management? . . . . . . . . . . 19 Compiler Output . . . . . . . . . . . . . . . . . 46
Using the Project Manager . . . . . . . . . . . . 20 Source . . . . . . . . . . . . . . . . . . . . . . . 46
Creating a project . . . . . . . . . . . . . . . . . . 21 Debugging. . . . . . . . . . . . . . . . . . . . . 47
Setting target options with the New Target Precompiled headers. . . . . . . . . . . . . . . 48
dialog box . . . . . . . . . . . . . . . . . . . . 21 Advanced Compiler. . . . . . . . . . . . . . . . 48
Specifying the source node types . . . . . . . 23 Processor. . . . . . . . . . . . . . . . . . . . . . 48
Opening existing projects . . . . . . . . . . . . 24 Calling Convention. . . . . . . . . . . . . . . . 48
Adding source nodes to your project . . . . . . 24 Memory Model . . . . . . . . . . . . . . . . . . 49
Deleting source nodes . . . . . . . . . . . . . . 24 Segment Names Data . . . . . . . . . . . . . . 50
Editing source node attributes . . . . . . . . . . 24 Segment Names Far Data . . . . . . . . . . . . 50
Adding target nodes to your project. . . . . . . 25 Segment Names Code . . . . . . . . . . . . . . 51
i
Entry/Exit Code . . . . . . . . . . . . . . . . . 51 Deleting a class . . . . . . . . . . . . . . . . . . . 82
C++ Options. . . . . . . . . . . . . . . . . . . . . 52 Moving a class . . . . . . . . . . . . . . . . . . . 82
Member Pointer . . . . . . . . . . . . . . . . . 52 Renaming an element . . . . . . . . . . . . . . . 83
C++ Compatibility . . . . . . . . . . . . . . . . 53 Importing a class . . . . . . . . . . . . . . . . . . 83
Virtual Tables . . . . . . . . . . . . . . . . . . . 53 Rebuilding the .APX database file. . . . . . . . 83
Templates . . . . . . . . . . . . . . . . . . . . . 53
Exception handling/RTTI . . . . . . . . . . . 54 Chapter 6
Messages . . . . . . . . . . . . . . . . . . . . . . . 54 Browsing classes and objects 85
Linker. . . . . . . . . . . . . . . . . . . . . . . . . 55
General . . . . . . . . . . . . . . . . . . . . . . 55 Generating browser information . . . . . . . . . 85
Map File . . . . . . . . . . . . . . . . . . . . . . 56 Browsing objects (class overview) . . . . . . . . 86
Advanced Linker. . . . . . . . . . . . . . . . . 57 Browsing global and local symbols . . . . . . . 86
Other Project Options dialog box options. . . . 58 Configuring the browser display . . . . . . . . . 87
Option defaults . . . . . . . . . . . . . . . . . . . 58 Using regular expressions with global
symbols . . . . . . . . . . . . . . . . . . . . . . . 88
Chapter 4 Customizing the browser . . . . . . . . . . . . . 88
Building applications with AppExpert 61
AppExpert basics . . . . . . . . . . . . . . . . . . 62 Chapter 7
Creating a small application . . . . . . . . . . . 62 Using the integrated debugger 89
Overview of the generated code . . . . . . . . . 64 Types of bugs . . . . . . . . . . . . . . . . . . . . 89
The application object . . . . . . . . . . . . . . 64 Run-time errors . . . . . . . . . . . . . . . . . . 89
The client window . . . . . . . . . . . . . . . . 67 Logic errors . . . . . . . . . . . . . . . . . . . . . 90
AppExpert options reference . . . . . . . . . . . 68 Planning a debugging strategy . . . . . . . . . . 90
Application . . . . . . . . . . . . . . . . . . . . . 68
Starting a debugging session . . . . . . . . . . . 90
Basic Options . . . . . . . . . . . . . . . . . . . 68
OLE 2 Options . . . . . . . . . . . . . . . . . . 69 Compiling with debug information. . . . . . . 91
Code Gen Control . . . . . . . . . . . . . . . . 70 Running your program in the IDE . . . . . . . 91
Admin Options. . . . . . . . . . . . . . . . . . 70 Specifying program arguments . . . . . . . . 92
Main Window. . . . . . . . . . . . . . . . . . . . 71 Controlling program execution . . . . . . . . . . 92
Basic Options . . . . . . . . . . . . . . . . . . . 71 Running to the cursor location. . . . . . . . . . 92
SDI Client . . . . . . . . . . . . . . . . . . . . . 72 The execution point . . . . . . . . . . . . . . . . 93
MDI Client . . . . . . . . . . . . . . . . . . . . 72 Finding the execution point. . . . . . . . . . . 93
Dialog Client . . . . . . . . . . . . . . . . . . . 73 Stepping through code . . . . . . . . . . . . . . 93
MDI Child/View . . . . . . . . . . . . . . . . . . 73 Trace Into . . . . . . . . . . . . . . . . . . . . . 93
Basic Options . . . . . . . . . . . . . . . . . . . 74 Step Over . . . . . . . . . . . . . . . . . . . . . 94
Debugging member functions and external
Chapter 5 code. . . . . . . . . . . . . . . . . . . . . . . . 95
Running to a breakpoint . . . . . . . . . . . . . 95
Modifying applications with Pausing the program . . . . . . . . . . . . . . . 95
ClassExpert 75 Terminating the program. . . . . . . . . . . . . 95
Starting ClassExpert . . . . . . . . . . . . . . . . 75 Using breakpoints. . . . . . . . . . . . . . . . . . 96
ClassExpert basics . . . . . . . . . . . . . . . . . 76 Setting breakpoints . . . . . . . . . . . . . . . . 96
Classes pane . . . . . . . . . . . . . . . . . . . 76 Setting breakpoints after starting a program . 96
Events pane . . . . . . . . . . . . . . . . . . . . 76 Invalid breakpoints. . . . . . . . . . . . . . . . 97
Edit pane . . . . . . . . . . . . . . . . . . . . . 76 Working with breakpoints . . . . . . . . . . . . 97
Adding a class. . . . . . . . . . . . . . . . . . . . 76 Viewing and editing code at a breakpoint . . 97
Creating document types . . . . . . . . . . . . . 78 Disabling and enabling breakpoints . . . . . . 97
Adding and deleting event handlers . . . . . . 79 Deleting breakpoints . . . . . . . . . . . . . . . 98
Adding and deleting instance variables. . . . . 80 Modifying breakpoint properties. . . . . . . . . 98
Jumping to class source code . . . . . . . . . . . 81 Creating conditional breakpoints . . . . . . . . 99
Using Resource Workshop with ClassExpert . 81 Setting Boolean conditions . . . . . . . . . . . 99
Running Resource Workshop from the IDE . . 81 Using pass counts . . . . . . . . . . . . . . . . 99
Using Rescan . . . . . . . . . . . . . . . . . . . . 82 Logging expressions. . . . . . . . . . . . . . . .100
ii
Customizing the breakpoint and execution Other WinSpector tools . . . . . . . . . . . . . 128
point colors . . . . . . . . . . . . . . . . . . . 100 Using EXEMAP.EXE . . . . . . . . . . . . . . .128
Examining program data values . . . . . . . . 100 Using TMAPSYM.EXE . . . . . . . . . . . . . .128
Watching expressions . . . . . . . . . . . . . . 101 Using BUILDSYM.EXE . . . . . . . . . . . . . .129
Formatting watch expressions . . . . . . . . . 102
Disabling a watch . . . . . . . . . . . . . . . . 102 Part II
Deleting a watch . . . . . . . . . . . . . . . . . 103 Using Resource Workshop 131
Evaluating and modifying expressions . . . . 103
Evaluating expressions . . . . . . . . . . . . . 103
Modifying the values of variables . . . . . . . 104 Chapter 9
Inspecting data elements . . . . . . . . . . . . 105 An overview of working
Examining register values. . . . . . . . . . . . 106
Viewing function calls . . . . . . . . . . . . . . 107
with resources 133
Navigating to function calls. . . . . . . . . . . 107 What is a resource? . . . . . . . . . . . . . . . . 134
Locating functions . . . . . . . . . . . . . . . . 108 Why you should link resources to your
Catching general protection faults . . . . . . . 108 applications. . . . . . . . . . . . . . . . . . . . 135
Sending messages to the Event Log window 108 Starting Resource Workshop . . . . . . . . . . 135
Debugging dynamic-link libraries . . . . . . . 109 Working with resource script files . . . . . . . 135
Debugging in soft and hard mode . . . . . . . 109 Creating a resource script file . . . . . . . . . .136
Editing an existing resource script file . . . . .136
Chapter 8 Adding resource scripts . . . . . . . . . . . . .137
Adding a new resource script indirectly . .137
WinSight and WinSpector 111 Adding one or more existing resource
WinSight . . . . . . . . . . . . . . . . . . . . . . 111 scripts indirectly . . . . . . . . . . . . . . .137
Starting and stopping screen updates . . . . . 112 Adding a new resource script directly . . .138
Turning off message tracing . . . . . . . . . . 112 Adding an existing resource script
directly . . . . . . . . . . . . . . . . . . . .138
Choosing a view . . . . . . . . . . . . . . . . . 112 Editing a resource script . . . . . . . . . . . . .138
Class List view. . . . . . . . . . . . . . . . . . . 113 Specifying memory options . . . . . . . . .139
Using the Class List view . . . . . . . . . . . . 113 Specifying a language version. . . . . . . .139
Spying on classes . . . . . . . . . . . . . . . . . 113 Removing a resource script . . . . . . . . . . .140
Window Tree view . . . . . . . . . . . . . . . . 114 Adding an identifier . . . . . . . . . . . . . . .140
Finding a window . . . . . . . . . . . . . . . . 114 Editing an identifier . . . . . . . . . . . . . . .141
Leaving Find Window mode. . . . . . . . . . 115 Removing an identifier . . . . . . . . . . . . .141
Spying on windows . . . . . . . . . . . . . . . 115 Generating binary resources from a resource
Choosing messages to trace . . . . . . . . . . . 115 script file. . . . . . . . . . . . . . . . . . . . . .142
Using the Message Trace view . . . . . . . . . 115 Working with binary files . . . . . . . . . . . . 142
Other tracing options . . . . . . . . . . . . . . 116 Creating a .RES file . . . . . . . . . . . . . . . .142
WinSpector. . . . . . . . . . . . . . . . . . . . . 120 Editing resources in a binary file . . . . . . . .142
Configuring WINSPCTR.LOG . . . . . . . . . 121 Working with graphic files . . . . . . . . . . . 143
WINSPCTR.LOG reference . . . . . . . . . . . 122 Creating a graphic file. . . . . . . . . . . . . . .143
Disassembly section . . . . . . . . . . . . . . . 123 Editing a graphic file . . . . . . . . . . . . . . .144
Stack Trace section . . . . . . . . . . . . . . . . 124 Customizing Resource Workshop . . . . . . . 144
Register section . . . . . . . . . . . . . . . . . . 124 Specifying which information appears in the
Message Queue section . . . . . . . . . . . . . 124 Project window. . . . . . . . . . . . . . . . . .144
Tasks section . . . . . . . . . . . . . . . . . . . 125 Setting general environment options . . . . . .144
Modules section . . . . . . . . . . . . . . . . . 125
USER and GDI heap section . . . . . . . . . . 126 Chapter 10
System Information section. . . . . . . . . . . 126 Working with dialog boxes 147
Processing WinSpector data. . . . . . . . . . . 126
DFA output . . . . . . . . . . . . . . . . . . . . 127
Editing a dialog box resource script . . . . . . 147
Setting dialog box properties. . . . . . . . . . .149
Using DFA with WINSPCTR.LOG . . . . . . 127
Class property. . . . . . . . . . . . . . . . . . .149
Using DFA with WINSPCTR.BIN . . . . . . . 127
Menu property . . . . . . . . . . . . . . . . . .149
iii
Type property . . . . . . . . . . . . . . . . . . 149 Line properties . . . . . . . . . . . . . . . . . .167
Style properties . . . . . . . . . . . . . . . . . . 150 Testing a dialog box resource . . . . . . . . . . 168
Frame Style property . . . . . . . . . . . . . . 150 Testing two dialog boxes at the same time. . .168
Font properties . . . . . . . . . . . . . . . . . . 150 Returning to Edit mode . . . . . . . . . . . . . .168
Extended Style property . . . . . . . . . . . . 151 Customizing the Dialog editor . . . . . . . . . 169
Common properties . . . . . . . . . . . . . . . 151
Moving and resizing a dialog box . . . . . . . 151 Using a dialog box resource in an application 170
Adding a standard control to a dialog box . . 151 Programming a dialog box with OWL . . . . .170
The advantages of using Borland controls . . 153 Programming a dialog box with the
Windows API. . . . . . . . . . . . . . . . . . .170
Working with custom controls . . . . . . . . . 153
Installing a control library (.DLL or .VBX) . . 153
Adding a custom control to a dialog box . . . 154
Chapter 11
Creating custom controls . . . . . . . . . . . . 154 Working with menus and
Selecting controls . . . . . . . . . . . . . . . . . 154 accelerator tables 171
Moving controls. . . . . . . . . . . . . . . . . . 155
Resizing controls . . . . . . . . . . . . . . . . . 155 Editing a menu resource script . . . . . . . . . 171
Fine-tuning the size of controls . . . . . . . . . 156 Adding a menu or separator to the menu bar .172
Moving and resizing controls at the same Adding a predefined menu . . . . . . . . . . .172
time . . . . . . . . . . . . . . . . . . . . . . . . 156 Adding a custom menu . . . . . . . . . . . . .173
Grouping and ungrouping controls . . . . . . 157 Adding a separator. . . . . . . . . . . . . . . .173
Setting the tab order of controls . . . . . . . . 157 Adding a menu item or separator to a menu .173
Aligning controls . . . . . . . . . . . . . . . . . 157 Setting the initial state of a menu or menu
item. . . . . . . . . . . . . . . . . . . . . . . . .174
Aligning controls with the Align|Align
command . . . . . . . . . . . . . . . . . . . . 158 Changing the identifier for a menu item . . . .175
Aligning controls with the Alignment Associating Help text with a menu item . . . .175
palette . . . . . . . . . . . . . . . . . . . . . . 158 Assigning an accelerator to a menu item. . . .175
Aligning controls with the grid . . . . . . . . 159 Copying, moving, or removing a menu,
Aligning controls in columns and rows . . . 159 menu item, or separator. . . . . . . . . . . . .176
Undoing actions . . . . . . . . . . . . . . . . . 160 Checking for duplicate identifiers. . . . . . . .177
Setting the Windows class of a control . . . . 160 Creating a resource script for a floating menu 177
Setting common properties using the Customizing the Menu editor. . . . . . . . . . 178
Properties window . . . . . . . . . . . . . . . 160 Editing an accelerator table resource script . . 178
Setting common properties using the Style Adding an accelerator resource . . . . . . . . .179
window . . . . . . . . . . . . . . . . . . . . . 161
Changing the identifier for an accelerator
Setting the unique properties of a control. . . 161 resource . . . . . . . . . . . . . . . . . . . . . .179
Push button properties . . . . . . . . . . . . . 162 Changing the keyboard combination for an
Type property . . . . . . . . . . . . . . . . 162 accelerator resource . . . . . . . . . . . . . . .180
Control ID property . . . . . . . . . . . . . 162 Copying, moving, or removing an
Radio button properties . . . . . . . . . . . . . 163 accelerator resource . . . . . . . . . . . . . . .180
Check box properties . . . . . . . . . . . . . . 163 Checking for duplicate keyboard
Static text properties . . . . . . . . . . . . . . . 163 combinations . . . . . . . . . . . . . . . . . . .181
Group box properties . . . . . . . . . . . . . . 164
Customizing the Accelerator editor . . . . . . 181
Scroll bar properties . . . . . . . . . . . . . . . 164
Edit box properties. . . . . . . . . . . . . . . . 164 Using menu and accelerator resources in an
Case property. . . . . . . . . . . . . . . . . 164 application . . . . . . . . . . . . . . . . . . . . 181
Windows 3.1 Style property . . . . . . . . 164 Programming menus and accelerators with
Line property . . . . . . . . . . . . . . . . . 165 OWL . . . . . . . . . . . . . . . . . . . . . . . .181
Miscellaneous Boolean properties . . . . . 165 Programming menus and accelerators with
List box properties . . . . . . . . . . . . . . . . 165 the Windows API . . . . . . . . . . . . . . . .181
Combo box properties. . . . . . . . . . . . . . 166
Type property . . . . . . . . . . . . . . . . 166 Chapter 12
Miscellaneous Boolean properties . . . . . 166 Working with string tables 183
Icon properties . . . . . . . . . . . . . . . . . . 167
Frame properties . . . . . . . . . . . . . . . . . 167
Editing a string table resource script . . . . . . 183
Rectangle properties . . . . . . . . . . . . . . . 167 Adding a string resource . . . . . . . . . . . . .183
Changing the characters of a string resource .184
iv
Changing the identifier for a string resource . 184 Changing a color on the Colors palette . . . . .200
Grouping string resources to maximize Specifying whether the Colors palette is
memory efficiency . . . . . . . . . . . . . . . 184 saved. . . . . . . . . . . . . . . . . . . . . . . .201
Copying, moving, or removing a string Specifying whether a grid appears when
resource . . . . . . . . . . . . . . . . . . . . . 185 you zoom in. . . . . . . . . . . . . . . . . . . .201
Customizing the String editor . . . . . . . . . 185 Using a graphic resource in an application . . 201
Using a string resource in an application . . . 185 Programming a bitmap with OWL . . . . . . .201
Programming an icon with OWL . . . . . . . .202
Chapter 13 Programming a cursor with OWL . . . . . . .202
Working with graphics 187 Programming a bitmap with the Windows
API . . . . . . . . . . . . . . . . . . . . . . . . .202
Editing a resource script for a graphic. . . . . 187 Programming an icon with the Windows
Choosing colors . . . . . . . . . . . . . . . . . . 189 API . . . . . . . . . . . . . . . . . . . . . . . . .203
Choosing a color that represents a Programming a cursor with the Windows
transparent or inverted area . . . . . . . . . 189 API . . . . . . . . . . . . . . . . . . . . . . . . .203
Choosing a pen style . . . . . . . . . . . . . . . 189
Choosing a brush shape . . . . . . . . . . . . . 190 Chapter 14
Choosing a paint pattern . . . . . . . . . . . . 190 Working with version information
Drawing and painting . . . . . . . . . . . . . . 190
Drawing a line. . . . . . . . . . . . . . . . . . . 191 and custom data types 205
Drawing a shape . . . . . . . . . . . . . . . . . 191 Creating a custom data type. . . . . . . . . . . 205
Filling an area with color . . . . . . . . . . . . 191 Editing a resource script for version
Adding text . . . . . . . . . . . . . . . . . . . . 192 information or a custom data type . . . . . . 206
Erasing an area . . . . . . . . . . . . . . . . . . 192 Editing a resource script for version
Selecting an area . . . . . . . . . . . . . . . . . 192 information . . . . . . . . . . . . . . . . . . . .206
Aligning an area . . . . . . . . . . . . . . . . . 193 The versionID parameter . . . . . . . . . . . .206
Moving or resizing an area . . . . . . . . . . . 193 The fixed-info parameter . . . . . . . . . . . .206
Copying or removing an area. . . . . . . . . . 193 The block-statements parameter . . . . . . . .207
Zooming in on or out from a graphic . . . . . 194 A string information block . . . . . . . . . .207
Moving a graphic around in the Drawing A variable information block . . . . . . . .207
Area. . . . . . . . . . . . . . . . . . . . . . . . 194 Constants . . . . . . . . . . . . . . . . . . . . .208
Viewing an icon or cursor in another fileflags . . . . . . . . . . . . . . . . . . . . .208
resolution . . . . . . . . . . . . . . . . . . . . 194 fileos. . . . . . . . . . . . . . . . . . . . . . .208
Testing an icon or cursor . . . . . . . . . . . . 195 filetype . . . . . . . . . . . . . . . . . . . . .208
Adding or removing an image from an icon subtype . . . . . . . . . . . . . . . . . . . . .209
or cursor . . . . . . . . . . . . . . . . . . . . . 195 langID. . . . . . . . . . . . . . . . . . . . . .209
Changing the properties of a bitmap . . . . . 196 charsetID . . . . . . . . . . . . . . . . . . . .210
Changing the properties of a cursor . . . . . . 196 string-name . . . . . . . . . . . . . . . . . .211
Changing the properties of an icon . . . . . . 197 Editing a resource script for a custom data
Changing the properties of a font . . . . . . . 197 type. . . . . . . . . . . . . . . . . . . . . . . . .211
Changing the general properties of a font . . 197 The resource-name parameter . . . . . . . . .211
Changing the height and width of the The type-ID parameter . . . . . . . . . . . . .211
characters in a font . . . . . . . . . . . . . . . 198 The load-type parameter . . . . . . . . . . . .211
Changing the ANSI codes of the characters The filename parameter . . . . . . . . . . . . .212
in a font . . . . . . . . . . . . . . . . . . . . . 198 The block-statements parameter . . . . . . . .212
Changing the number of characters in a Entering data in a resource script . . . . . . . .212
font . . . . . . . . . . . . . . . . . . . . . . . . 199 Compiling a resource script . . . . . . . . . . . 212
Editing a specific character in a font . . . . . . 199 Using a version information resource in an
Customizing the Graphic editor . . . . . . . . 199 application . . . . . . . . . . . . . . . . . . . . 213
Adding or removing a second pane from the Using a resource for a custom data type in
Edit window. . . . . . . . . . . . . . . . . . . 199 an application. . . . . . . . . . . . . . . . . . .213
Hiding or showing the Tools and Colors
palettes . . . . . . . . . . . . . . . . . . . . . . 200
v
Appendix A Appendix C
Using EasyWin 215 Error messages 221
_InitEasyWin( ) . . . . . . . . . . . . . . . . . . 215 Message classes . . . . . . . . . . . . . . . . . . 221
Added functions . . . . . . . . . . . . . . . . . 216 Fatal errors . . . . . . . . . . . . . . . . . . . . .221
Errors . . . . . . . . . . . . . . . . . . . . . . . .222
Appendix B Warnings . . . . . . . . . . . . . . . . . . . . . .222
Precompiled headers 217 Help compiler messages . . . . . . . . . . . . . 222
How they work . . . . . . . . . . . . . . . . . . 217 Message listings . . . . . . . . . . . . . . . . . . 223
Drawbacks. . . . . . . . . . . . . . . . . . . . . 218 Message explanations . . . . . . . . . . . . . . 223
Using precompiled headers. . . . . . . . . . . 218
Setting file names . . . . . . . . . . . . . . . . . 218 Index 273
Establishing identity . . . . . . . . . . . . . . . 218
Optimizing precompiled headers . . . . . . . 219
vi
Tables Figures
1.1 The IDE menus . . . . . . . . . . . . . . . . . . .8 1.1 The Turbo C++ IDE . . . . . . . . . . . . . . . . 8
3.1 Default Project Option settings . . . . . . . . . 58 1.2 The New Target dialog box . . . . . . . . . . .11
4.1 Sample application files . . . . . . . . . . . . . 64 1.3 The Environment Options dialog box . . . . .14
6.1 Filter letters in the browser . . . . . . . . . . . 87 2.1 The Project window displaying a
6.2 Browser search expressions . . . . . . . . . . . 88 Project Tree . . . . . . . . . . . . . . . . . . . . .20
7.1 Expression format specifiers . . . . . . . . . 104 2.2 TargetExpert dialog box . . . . . . . . . . . . .22
7.2 CPU flags in the Register window . . . . . . 106 2.3 The Environment Options dialog box . . . . .28
8.1 Mouse messages . . . . . . . . . . . . . . . . .117 2.4 The Tools dialog box . . . . . . . . . . . . . . .31
8.2 Window messages . . . . . . . . . . . . . . . .117 2.5 The Tool Advanced Options dialog box. . . .33
8.3 Input messages . . . . . . . . . . . . . . . . . .117 3.1 The Project Options dialog box . . . . . . . . .36
8.4 System messages . . . . . . . . . . . . . . . . .117 3.2 Style Sheets dialog box . . . . . . . . . . . . . .37
8.5 Pen messages . . . . . . . . . . . . . . . . . . .118 3.3 The Options Hierarchy dialog box . . . . . . .40
8.6 Initialization messages . . . . . . . . . . . . . .118 4.1 AppExpert Application Generation
8.7 Clipboard messages . . . . . . . . . . . . . . .118 Options dialog box . . . . . . . . . . . . . . . .63
8.8 DDE messages. . . . . . . . . . . . . . . . . . .118 4.2 DRAW.IDE loaded into the Project
8.9 Nonclient messages . . . . . . . . . . . . . . .118 Manager. . . . . . . . . . . . . . . . . . . . . . .65
8.10 Control messages . . . . . . . . . . . . . . . . .118 5.1 ClassExpert . . . . . . . . . . . . . . . . . . . . .75
8.11 Multimedia messages . . . . . . . . . . . . . 120 5.2 Add New Class dialog box. . . . . . . . . . . .77
8.12 Other messages and messages not 6.1 Viewing classes in an application . . . . . . . .86
documented by Microsoft . . . . . . . . . . . 120 6.2 Symbol declaration window. . . . . . . . . . .87
8.13 Exception types . . . . . . . . . . . . . . . . . 122 7.1 The Breakpoints window. . . . . . . . . . . . .97
8.14 DFA options . . . . . . . . . . . . . . . . . . . 128 7.2 The Breakpoint Properties dialog box . . . . .98
7.3 The Watch window . . . . . . . . . . . . . . . 101
7.4 The Watch Properties dialog box . . . . . . . 102
7.5 The Expression Evaluator dialog box . . . . 103
7.6 Inspect windows. . . . . . . . . . . . . . . . . 106
7.7 Call Stack window. . . . . . . . . . . . . . . . 107
xii