Top Banner
Introduction 1 Copyright Agreement Turbo C ++ for Windows ® Introduction 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. What’s new in Turbo C++ Turbo C++ 4.5 has many new features and additions. The following is a brief list of major additions and changes: The compiler provides improved code generation and faster compilation times. ObjectComponents, a new set of C++ classes, lets you easily implement OLE 2.0 in your applications. See the ObjectWindows Programmer’s Guide for more information. ObjectWindows (OWL) 2.5 contains new classes that give you access to OLE 2.0 through ObjectComponents. See the ObjectWindows Programmer’s Guide for more information. OLE 2.0 support was added to AppExpert and ClassExpert. See Chapter 4 and Chapter 5 in this book for more information. A Dialog Client application model was added to AppExpert, which lets you create an application that uses a dialog box as its main user interface. See Chapter 4 for more information. OpenHelp lets you quickly and easily search through multiple online Help files. See “Searching through multiple Help files with OpenHelp” on page 4 for more information. WinRun, lets you run Windows programs from a DOS box. See the ObjectWindows Programmer’s Guide for more information. User’s Guide
300
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: UG

I n t r o d u c t i o n 1

CopyrightAgreement

Turbo C ++ for Windows®

I n t r o d u c t i o n

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.

What’s new in Turbo C++Turbo C++ 4.5 has many new features and additions. The following is a brief list of major additions and changes:

• The compiler provides improved code generation and faster compilation times.

• ObjectComponents, a new set of C++ classes, lets you easily implement OLE 2.0 in your applications. See the ObjectWindows Programmer’s Guide for more information.

• ObjectWindows (OWL) 2.5 contains new classes that give you access to OLE 2.0 through ObjectComponents. See the ObjectWindows Programmer’s Guide for more information.

• OLE 2.0 support was added to AppExpert and ClassExpert. See Chapter 4 and Chapter 5 in this book for more information.

• A Dialog Client application model was added to AppExpert, which lets you create an application that uses a dialog box as its main user interface. See Chapter 4 for more information.

• OpenHelp lets you quickly and easily search through multiple online Help files. See “Searching through multiple Help files with OpenHelp” on page 4 for more information.

• WinRun, lets you run Windows programs from a DOS box. See the ObjectWindows Programmer’s Guide for more information.

User’s Guide

Copyright Agreement
REDISTRIBUTABLE FILES You can redistribute the following files in accordance with the terms of the No-Nonsense License Statement: • BC450RTL.DLL • BIVBX11N.EXE • OWL250.DLL • BIDS45.DLL • BIVBX11S.DLL • PICT.VBX • BIVBX11.DLL • BOCOLE.DLL • BWCC000C.DLL • BWCC.DLL • GAUGE.VBX • SWITCH.VBX • BIVBX11C.DLL • BWCC0009.DLL • LOCALE.BLL 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.
Page 2: UG

2 U s e r ’ s G u i d e

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.

Hardware and software requirementsTo use Turbo C++, your computer must have

• DOS version 4.01 or higher

• Windows 3.1 or higher, running in enhanced mode

• An 80386 (or compatible) CPU or greater

• A hard disk with 40MB of available disk space for a normal installation (100MB for a full installation)

• A 1.44 floppy drive or CD ROM (for installation)

• At least 4MB of extended memory to run the IDE (at least 8MB of extended memory is recommended)

• A Windows-compatible mouse

Although not required, the following hardware greatly increases the performance of Turbo C++:

• 8MB (or more) RAM

• An 80x87 math coprocessor (if you’re writing programs that use floating-point math).

Page 3: UG

I n t r o d u c t i o n 3

Manual conventionsThis manual uses the following special fonts:

Getting helpThe 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:

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

Page 4: UG

4 U s e r ’ s G u i d e

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

Searching through multiple Help files with OpenHelpOpenHelp is a tool that lets you search through multiple online Help files from a single dialog box. When you search for a keyword, OpenHelp searches through the keyword lists of all the Help files that you specify; all your Windows Help files are now available to you with a single Help command.

There are several ways to access OpenHelp:

• Click the Search All button on the Help button bar in any Borland Help file.• Choose Help|Keyword Search in the Turbo C++ IDE (or press F1).• Double-click the OpenHelp icon in the Turbo C++ group on your Windows desktop.

When you access OpenHelp, you can search through the Help files you specify to locate the information you need. By default, OpenHelp searches through a predefined set of Help files. The set of files that OpenHelp accesses is known as the search range. By customizing OpenHelp, you can add new search ranges and modify existing ones to create a Help system that suits your needs.

For more information on OpenHelp, and for instructions on customizing the OpenHelp search ranges, press F1 inside Turbo C++, then search on the topic “Using OpenHelp.”

Software registration and technical supportThe Borland Assist program offers a range of technical support plans to fit the different needs of individuals, consultants, large corporations, and developers. To receive help with Turbo C++, send in the registration card and select the Borland Assist plan which best suits your needs. North American customers can register by phone 24 hours a day by calling 1-800-845-0147. For additional details on these and other Borland services, see the Borland Assist Support and Services Guide included with your Turbo C++ package.

Page 5: UG

P a r t I , U s i n g t h e i n t e g r a t e d d e v e l o p m e n t e n v i r o n m e n t 5

P a r t

IPart IUsing the integrated development

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

Page 6: UG

6 U s e r ’ s G u i d e

• Chapter 6, “Browsing classes and objects,” shows you how to use the browser to examine your C++ classes.

• Chapter 7, “Using the integrated debugger,” describes the integrated debugger, which you can use to step and trace through your program code.

Page 7: UG

C h a p t e r 1 , G e t t i n g s t a r t e d 7

C h a p t e r

1Chapter 1Getting started

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

Starting the Turbo C++ IDEAfter installing Turbo C++, the Program Manager contains a program group called Turbo C++ 4.5. Open this group to reveal the icons for the C++ IDE (labeled Turbo C++) and the other programming tools that ship with Turbo C++.

When you double-click the Turbo C++ icon, the IDE opens. Inside the IDE, you’ll find all the tools you’ll need to create C++ programs. Along with windows for the editor, browser, and debugger, the IDE contains windows for project files and compiler and programming tool messages. Figure 1.1 shows how the IDE might look after compiling a simple Windows project.

Page 8: UG

8 U s e r ’ s G u i d e

Figure 1.1 The Turbo C++ IDE

The IDE menu systemTable 1.1 describes the menus on the IDE menu bar.

Table 1.1 The IDE menus

Menu item Command descriptions

File Commands to open, save, and print files. Also includes the IDE exit command.Edit Clipboard commands and commands for undoing and redoing program edits.Search Commands for searching and replacing strings, browsing symbols, locating functions,

and reviewing error messages generated by the programming tools.View Commands to open the ClassExpert, Project Manager, Message window, and Browser.

Also contains commands to open the various integrated debugger windows.Project Commands to open, close, and compile projects. Also contains the AppExpert

command.Debug Commands to run your project under control of the integrated debugger.Tool Commands to launch programming tools from the IDE, including Turbo Debugger.Options IDE customization and project configuration commands.Window IDE window management commands.Help Commands to access the Turbo C++ online Help system.

Menu Bar

Edit window

Message window

SpeedBar

Project window

Status Bar

Page 9: UG

C h a p t e r 1 , G e t t i n g s t a r t e d 9

The IDE SpeedBarThe 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.

Using SpeedMenus in the IDERight-clicking (clicking the right mouse button) accesses the Turbo C++ SpeedMenus. SpeedMenus contain commands that are context-sensitive to the area of the program you’re working in. For example, the SpeedMenu for the Edit window contains commands that are related to the editor. In the Project Manager, the SpeedMenus contain commands to help you with managing your projects.

To get a feeling for SpeedMenus, try the following:

1 From the IDE, choose Project|Open, then open the project file MULTITRG.IDE in the \TCWIN45\EXAMPLES\IDE\MULTITRG directory.

2 Double-click the MULTITRG [.CPP] node to open the file in an Edit window.

3 Move the cursor to the string.h header file reference by clicking on the file name in the source code.

4 Right click to open the Edit window SpeedMenu, then choose Open Source to open an Edit window that contains this header file.

Note In addition to right-clicking, the IDE speedmenus can be accessed at any time by pressing Alt+F10.

Using the Edit windowEdit windows contain the Turbo C++ editor, which you can use to create and edit your program code. When you’re editing a file, the IDE status bar displays the following information about the file you’re editing:

• The line number and character position of the cursor. For example, if the cursor is on the first line and first character of an Edit window, you’ll see 1:1 in the status bar; if the cursor is on line 68 and character 23, you’ll see 68:23.

• The edit mode: insert or overwrite. Press Insert to toggle whether your text additions overwrite existing characters or insert new ones into the file.

Page 10: UG

10 U s e r ’ s G u i d e

• The file’s save status. The word Modified appears if you’ve made changes to the file in the active Edit window, and you have not yet saved your edits or changes.

Note The Turbo C++ editor contains many powerful features to help you enter and modify your program code. For example, you can undo multiple edits by choosing Edit|Undo or pressing Alt+Backspace. You can also open multiple Edit windows; tile the windows as you wish; subdivide the window into different Edit panes; and cut, copy, and paste text between any open files.

Although this chapter provides a brief introduction to the editor, complete details on how to use and customize the editor can be found in the online Help that accompanies the IDE. Choose Help|Contents, then click Integrated Development Environment for a list of topics that relate to the IDE. From here, view the Editor topic, and the Menu Commands topics Edit Menu and Search Menu.

Creating a new fileTo introduce you to the editor, step through the following instructions to create an EasyWin program that’s used as an example later in this chapter.

1 Create the directory \MYSOURCE using File Manager (you’ll use this directory to hold the project files you create later in this chapter).

2 From the IDE, choose File|New to open a new Edit window with an empty file.

By default, Turbo C++ names new files NONAMExx.CPP, where xx is a number that’s incremented with each new file opened.

3 In the Edit window, type the following C++ code to create an EasyWin program:

#include <iostream.h>

int main (void){

cout << "Welcome to the World of Windows!\n"; //print textreturn(0);

}

4 Choose File|Save As, and save your new file in the \MYSOURCE directory with the file name EZW_TEST.CPP (this file is used later in this chapter).

Working with simple projectsAfter you first install Turbo C++, you’ll want to make sure the program is correctly setup; the details of the compiler and the IDE can wait until later. The best way to test your setup is to compile a few sample programs.

In this section, you’ll learn how to create and run two simple programs. The first program is an EasyWin program. (For more information about EasyWin, see Appendix A.) After creating the EasyWin program, you’ll be taken through the steps to create a 16-bit Windows program.

Page 11: UG

C h a p t e r 1 , G e t t i n g s t a r t e d 11

Creating an EasyWin ProgramYou 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.

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.

Figure 1.2 The New Target dialog box

Page 12: UG

12 U s e r ’ s G u i d e

4 Compile and run the program by double-clicking the EZW_TEST [.EXE] project node.

If you correctly followed all the steps in this section, the program builds without errors and then runs in a window. If the compiler reports errors or warnings during the compile, retrace the steps in this section to ensure you correctly followed the steps. When the program compiles without errors, the Project Manager creates an executable program called EZW_TEST.EXE and places it in the \MYSOURCE directory.

Creating a Windows programThis section demonstrates how to compile a simple Windows program.

If you followed the steps in the preceding section to create an EasyWin program, you’ll find that most of the steps for creating this Windows program are identical to those listed for the EasyWin program. When you’re finished with this example, the tasks involved with creating and compiling simple programs with the IDE should be familiar:

1 Create a new project.

2 Set the target options using the New Target dialog box.

3 Add code to the appropriate nodes in the project.

4 Compile and run the project.

Indeed, most projects will require more involved steps, but the basic steps for creating and compiling projects remains the same. With this in mind, follow these steps to create a simple Windows program:

1 Choose Project|New Project to open the New Target dialog box, then make the following settings:• Type the following path and name for your new project in the Project Path And

Name input box:

\mysource\win_test.ide

Note If the directory doesn’t exist, the IDE creates the directory for you.• In the Target Type list box, click Application [.EXE] to set the type of program you

plan to create (this is the default setting).• In the Platform combo box, set the Target Type to Windows 3.x (16).

2 Click the Advanced button, then uncheck both the .RC and .DEF options in the dialog box that appears. Unchecking these settings tells the Project Manager that this project doesn’t use definition and resource files, as most Windows programs do.

3 Choose OK to accept the settings, then choose OK again to close the New Target dialog box. The Project window opens with your new project.

4 In the Project window, double-click the win_test [.cpp] node to open an empty file in the Edit window.

5 In the Edit window, type the following code to create a Windows program, then save the program by choosing File|Save.

Page 13: UG

C h a p t e r 1 , G e t t i n g s t a r t e d 13

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

Single file programsUsually when you begin to write a new program, you start by creating a new project for that program. Although it’s possible to compile a single-source file program without using a project, it’s usually easier to maintain the program settings through a project file. However, if you want to set target options for a single-source file program without creating a project,

1 Choose Project|Close Project to make sure you don’t have a project file open.

2 Choose File|Open, then open the source file containing your program.

3 Open the TargetExpert by right-clicking in the Edit window and choosing TargetExpert from the SpeedMenu.

4 Adjust the target settings for your single-source file program using the TargetExpert dialog box, as described in “Editing target attributes using TargetExpert” on page 26.

5 Choose Options|Project from the menu, and set the project options, as described in Chapter 3.

6 Choose Project|Compile (this command compiles the code in the current Edit window if no project is loaded).

Page 14: UG

14 U s e r ’ s G u i d e

Customizing the IDEYou can configure the IDE in many ways to create a customized environment that meets your programming needs. For example, you can have the IDE do tasks automatically (such as saving backups of your files in the Editor windows) or handle special events.

The Environment Options dialog box (accessed with the Options|Environment command) lets you configure the different elements and windows of the IDE. Once you’ve customized the IDE to your liking, choose Options|Save, check the options you want to save, then choose OK; the IDE saves your environment settings to a file called TCCONFIG.TCW. By default, the file is saved to the BIN directory in your Turbo C++ directory tree. This default directory is specified by the DefaultDesktopDir field of your TCW.INI file, which is located in the your Windows directory.

The Environment Options dialog box displays a list of customizable topics on the left and each topic’s configurable options on the right. Some topics contain subtopics, indicated by a + next to the topic. For example, the Editor topic has subtopics called Options, File, and Display. To view a topic’s subtopics, click the + sign next to the topic; its subtopics appear under it and the + turns to a – (you can then click the – to collapse the list of subtopics). Topics without subtopics appear with a dot next to their name.

Figure 1.3 The Environment Options dialog box

This chapter discusses the following Environment Options topics:

• Configuring the IDE editor• Syntax highlighting• Customizing the SpeedBars• Setting IDE preferences• Saving your IDE settings

Note Although this chapter doesn’t offer a complete reference to the Environment Options dialog box, a complete reference is available by clicking the Help button in the Environment Options dialog box.

Page 15: UG

C h a p t e r 1 , G e t t i n g s t a r t e d 15

Configuring the IDE editorYou 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 highlightingSyntax 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

Page 16: UG

16 U s e r ’ s G u i d e

appears in the color). If FB appears in the color, the color is used as both a background and a foreground color.

6 If you want, choose an Attribute (for example, bold).

7 You can check Default FG (foreground) or BG (background) to use the Windows default colors for an element.

8 Repeat steps 2–4 for the elements you want to modify.

To turn off syntax highlighting, Choose Options|Environment|Syntax Highlighting, then uncheck Use Syntax Highlighting.

Customizing the SpeedBarsThe IDE has context sensitive SpeedBars for all its windows, including the Edit, Browser, Debugger, Project Manager, Message, Desktop, and ClassExpert windows. When a window has focus, the corresponding SpeedBar appears. Using the Environment Options dialog box, you can customize each of the SpeedBars so that they include only the buttons you want.

To add or delete buttons from the SpeedBars,

1 Choose Options|Environment from the IDE’s main menu.

2 Choose the SpeedBar topic on the left. The right side of the dialog box displays general options for all SpeedBars.

The options here let you specify if you want to hide or view the SpeedBar, where you want the SpeedBar to appear (on the top or bottom of the IDE), and if you want to use the Flyby Help Hints. If you check Use Flyby Help Hints, the IDE displays descriptions of the SpeedButtons on the status line when you pass the mouse pointer over a button. If you leave this box unchecked, the hints show on the status line only when you click a SpeedButton.

3 Choose the Customize topic listed under the SpeedBar topic to customize the SpeedBar for a particular window.

4 In the Window combo box, choose the specific window (Editor, Browser, Debugger, Project, Message, IDE Desktop, or ClassExpert) whose SpeedBar you want to customize.

The Available Buttons list box displays all the available (unused) buttons that you can add to a particular window’s SpeedBar. (Each button has a name next to it that describes the button’s function.) The Active Buttons list box displays the buttons that are currently contained in the selected window’s SpeedBar.• To add a button to a SpeedBar, double-click the button icon in the Available Buttons

list, or select it and click the right-pointing arrow. The IDE places the button in front of the selected button in the Active Buttons list.

• To remove a button from a SpeedBar, double-click the button icon in the Active Buttons list, or select it and click the left-pointing arrow. The button moves to the Available Buttons list.

Page 17: UG

C h a p t e r 1 , G e t t i n g s t a r t e d 17

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

Setting IDE preferencesThe Preferences command lets you customize what IDE settings you want automatically saved and how you want some IDE windows to work.

To set preferences,

1 Choose Options|Environment|Preferences.

2 Check and uncheck the options you want, then choose OK. For an explanation of each option, see the online Help (press the Help button).

Saving your IDE settingsThe IDE automatically saves information when you exit the IDE, run the integrated debugger, or close or open a project. You can control which areas of the IDE get saved from the Preferences topic in the Environment Options dialog box (choose Options|Environment from the main menu).

If you want to save your settings manually, you can do so as follows:

1 Choose Options|Save.

2 Check Environment to save the settings from the Editor, Syntax Highlighting, SpeedBar, Browser, and Preferences sections of the Environment Options dialog box. These settings are saved in a file called TCCONFIG.TCW.

3 Check Desktop to save information about open windows and their positions. This information is saved to a file called <prjname>.DSW. If you don’t have a project open, the information is saved to a file called TCWDEF.DSW.

4 Check Project to save changes to your project (.IDE) file, including build options and node attributes.

Page 18: UG

18 U s e r ’ s G u i d e

Running other programs from the IDEBy default, the IDE lists Resource Workshop, GREP, WinSight, WinSpector, and Key Map Compiler on the Tool menu. To run any of these tools from the IDE, choose Tool|ProgramName, where ProgramName is the name of the program you want to run (for example, Tool|GREP runs the GREP utility).

You can run any executable program or utility without leaving the IDE by adding it to the Tool menu. For a complete discussion on adding items to the Tool menu, see “Adding translators, viewers, and tools to the IDE” on page 31.

Page 19: UG

C h a p t e r 2 , C r e a t i n g a n d m a n a g i n g p r o j e c t s 19

C h a p t e r

2Chapter 2Creating and managing projects

The Turbo C++ IDE contains a Project Manager that gives you a visual representation of the files contained in your project. With the Project Manager, you can see exactly what files you’re building, the files you’re using in the builds, and the options that you’ve set for the builds.

This chapter covers the following topics, which describe how to use the Project Manager to organize the files in your project:

• Project management• Using the Project Manager• Grouping sets of files with Source Pools• Translators, viewers, and tools

For information on setting project options and compiling, see Chapter 3.

What is project management?As your applications grow in size and complexity, you’ll discover that your programs become more and more dependent on different intermediate files. In addition, you’ll find that some of the modules in your project must be compiled with different compilers or different compiler options. A Windows program, for example, can be composed of resource scripts, import libraries, and source code, with each different file type requiring a different compiler and compiler settings.

As the complexity of your projects increase, the need increases for a way to manage the different components of your projects. By studying the files that make up a project, you can see how a project combines different source files to produce different target files. Target files, for example, can be .DLL or .EXE files. The source files that these targets are dependent upon can consist of files like .C, .CPP, and .H files. Project management is the organization and management of the sources and targets that make up your project.

Page 20: UG

20 U s e r ’ s G u i d e

Using the Project ManagerThe Project Manager visually organizes all the files in your project using a Project Tree. The Project Tree displays files in a hierarchy diagram. Each level of the hierarchy contains a single target and all the target’s dependencies. To show their relationship to the target, dependencies are indented below the target listing. Figure 2.1 shows how the Project window displays a Project Tree. To expand and collapse the hierarchy tree, click nodes containing the + and – symbols.

Figure 2.1 The Project window displaying a Project Tree

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:

Project nodeTarget node

Run-time nodes

Autodependency nodes

Source node

Page 21: UG

C h a p t e r 2 , C r e a t i n g a n d m a n a g i n g p r o j e c t s 21

• 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 projectWhen 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.

Setting target options with the New Target dialog boxWhen you create a new project, the IDE automatically assigns default file names to the nodes in your project. The following steps show how to change these default settings and how to complete the initial project setup.

1 Type the path and name for the new project into the Project Path And Name input box (the project name must contain eight characters or less). Note that you don’t have to type a file extension because the IDE automatically assigns the extension .IDE to all project files.

2 In the Target Name input box, type the name for the first target in your project. This is usually the name of the .EXE or .DLL file that you want to create.

Page 22: UG

22 U s e r ’ s G u i d e

Note The remaining fields in the New Target dialog box set the options for the first target in the project. These fields are commonly referred to as the TargetExpert, since these are the fields contained in the TargetExpert dialog box, as shown in Figure 2.2.

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.

Figure 2.2 TargetExpert dialog box

Page 23: UG

C h a p t e r 2 , C r e a t i n g a n d m a n a g i n g p r o j e c t s 23

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.

Specifying the source node typesThe Advanced button in the New Target dialog box opens the Advanced Options dialog box. Use this dialog box to set the types of source nodes that the IDE creates with a new target node.

• .CPP Node creates a C++ source node.

• .C Node creates a C language source node.

• No Source Node creates a target node that doesn’t use a source node. Use this option when you do not want to create a source node that uses the same file name as the name of the project. When you create a new target with this option, you must specifically add the source node, as described in “Adding source nodes to your project” on page 24.

If your program is a Windows program, check the following boxes according to the files your target uses.• .RC creates a source node that is associated with a resource script.• .DEF creates a source node that’s associated with a Windows definition file.

Page 24: UG

24 U s e r ’ s G u i d e

Opening existing projectsTo open an existing project, choose Project|Open Project, then use the file browser to select an existing .IDE or .PRJ project file (.PRJ files are converted to .IDE files when you save the project). If the project opens, but the Project window is not visible, choose View|Project to access the Project window.

Adding source nodes to your projectTo add a source node to a project,

1 Select any node in the Project Tree under which you want the new node to appear. For example, if you want the new node to appear under the target, select the target node.

2 Press Ins, click the button on the SpeedBar, or right-click the node to open the Project window SpeedMenu, then choose Add Node.

3 Using the file browser, choose the file or files you want associated with the new node. Alternatively, you can type the name of the file you want to add.

4 Choose OK to confirm your settings.

You can use the Windows File Manager to add one or more source nodes.

1 Open the File Manager and arrange the windows so you can still view the Project window in the IDE.

2 In the File Manager, press Ctrl and select the files you want to add as source nodes.

3 Drag the files from the File Manager and drop them on a node in the Project window. The Project Manager automatically adds the source files under the selected node.

Deleting source nodesTo delete a node in a project, select the node and press Del, or choose Delete Node from the SpeedMenu. To delete many nodes, select the ones you want to delete (press Ctrl or Shift and click the left mouse button to select multiple nodes), then press Del. The Project Manager asks if you want to delete the nodes before it proceeds.

Editing source node attributesNode attributes describe the node and define the tool that translates it (if applicable). To edit the attributes of a source node,

1 Right-click the source node (or select the node and press Alt+F10), then choose Edit Node Attributes from the SpeedMenu. The Node Attributes dialog box appears.

2 Update the node attributes, then choose OK to confirm your settings.

Node attributes are defined as follows:• Name is the file name of the node, without a file extension.• Description is an optional text description of the node.

Page 25: UG

C h a p t e r 2 , C r e a t i n g a n d m a n a g i n g p r o j e c t s 25

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

Adding target nodes to your projectTo add a target to a project with the New Target dialog box,

1 Choose Project|New Target, or click the button on the SpeedBar.

2 Type the name for the new target, then choose one of the following target types:• Standard (default) can be an executable, DLL, or other file.• AppExpert is an automatically generated ObjectWindows-based application. See

Chapter 4 for more information on this type of target.• Source Pool is a collection of files that can be referenced in other targets. See page

29 for more information on using Source Pools.

3 Choose OK. If the target type is Standard, the TargetExpert dialog box appears (as shown on page 22) so you can further define your target. If the target type is SourcePool, the target is added to the project and you can add nodes to it immediately, as described on page 29. If you choose AppExpert as the target, AppExpert appears.

When you add a new target, it is always appended to the end of the Project Tree.

To view a sample project with two targets, open the MULTITRG.IDE project in the\TCWIN45\EXAMPLES\IDE\MULTITRG directory. This project file builds two versions of the WHELLO program—one with debug information and one without. The project file contains a text file that describes how to use two or more targets in a project.

With more than one target in a project, you can choose to build a single target, multiple targets, or the whole project. For more information, see “Compiling projects” on page 41.

Deleting target nodesTo delete a target node:

1 Right-click the target node you want to delete (or highlight it and press Alt+F10).

2 Choose Delete Node from the SpeedMenu.

3 The Project Manager asks if you’re sure you want to delete the target. Choose OK to delete the target and all its dependencies from the project.

Page 26: UG

26 U s e r ’ s G u i d e

You can also delete several nodes by pressing Ctrl and clicking the nodes you want to delete, then press Del.

Warning! Use care when deleting target nodes—you cannot undo the deletion.

Editing target attributes using TargetExpertTarget attributes describe the target. Using TargetExpert (shown in Figure 2.2 on page 22), you can modify the attributes for Standard and AppExpert target types. However, you can’t change target attributes for Source Pools.

To change a target’s attributes,

1 In the Project window, right-click the target node (or select it and press Alt+F10), then choose TargetExpert from the SpeedMenu to open the TargetExpert dialog box.

Or choose Options|Target, select the target, and choose the Edit button.

Note The TargetExpert fields are a subset of the fields in the New Target dialog box. For a description of these fields, refer to “Setting target options with the New Target dialog box” on page 21.

2 Update the target attributes, then choose OK to confirm your new settings.

Moving nodes within a projectYou can move nodes within a project in the following ways:

• By dragging the node to its new location.

• By selecting the node and press Alt and the arrow keys. This moves the selected node up or down through the visible nodes. You can also use Alt and the right and left arrow keys to promote and demote nodes through levels of dependencies. For example, if you have a .CPP file dependent that’s on a header file (the .H file appears under and right of the .CPP in the project window), you can move the header file to the same level as the .CPP file by selecting the header file and pressing Alt ←.

Copying nodes in a projectYou can copy nodes in your project file either by value or by reference. When you copy a node by value, the Project Manager places an identical, but separate, copy of the node in the location you specify. The nodes you copy inherit all the attributes from the original node and you have the ability to modify any of the copied node’s attributes.

When you copy by reference, you simply point to one node from a different location in the project; a reference copy isn’t distinct from the original node. If you modify the structure of the original node, the reference copy is also modified. However, a reference copy does not inherit the options of the original node; you’re free to attach Style Sheets and override options in the copied node without affecting the original node.

To copy a node by value,

Page 27: UG

C h a p t e r 2 , C r e a t i n g a n d m a n a g i n g p r o j e c t s 27

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.

Importing projects from older versions of Turbo C++The Project Manager can load projects from older versions of Turbo C++. Choose Project|Open Project, then type the name of the .PRJ file. To display the old project files in the file name list, change the search extensions from *.IDE to *.PRJ in the List Files Of Type drop-down box.

When you open an old project file, the Project Manager converts the old project to a new one. Be sure to save the new project if you want to keep using it with this version of Turbo C++. To save the project, choose Options|Save. Make sure Project is checked, then click OK. The new project is saved with an .IDE file extension.

Importing projects from Borland C++When you attempt to load .IDE files created with Borland C++, a dialog box warns you that the BC file may contain features that Turbo C++ does not support. To disable this dialog box, add the following line to your TCW.INI file:

[Project] ImportBorlandIDEFile=1

Warning! Some options supported in BC .IDE files do not transfer gracefully to Turbo C++. Only 16-bit Windows and EasyWin targets will build successfully under Turbo C++. Other

Page 28: UG

28 U s e r ’ s G u i d e

targets, such as DOS and Win32, will produce build failures. If you open TargetExpert, it will forcibly reassign any target types it does not recognize.

Any compiler optimization switches set in the original BC project are simply ignored. They remain set, however, so if you return the project to BC the optimizations still work. Any compiler and linker options not available in TCW are not visible in the options dialogs. In this category are 8086 and 80286 CPU support, tiny and huge memory models, entry/exit code options for DOS targets, some prolog/epilog options, and the target Windows version for Win32 resources. If you import project files with unsupported options, you should open the options dialog and choose supported settings.

Customizing the Project windowBy default, the Project window displays target nodes and source nodes. To control the display of nodes and options,

1 Choose Options|Environment to open the Environment Options dialog box, then choose Project View. The right side of the dialog box displays the Project View options.

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.

Figure 2.3 The Environment Options dialog box

Page 29: UG

C h a p t e r 2 , C r e a t i n g a n d m a n a g i n g p r o j e c t s 29

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

Grouping sets of files with Source PoolsA Source Pool is a collection of source nodes that can be referenced by multiple target nodes. When a Source Pool is referenced by a target node, the nodes in the Source Pool take on the options and target attributes of the target. Because Source Pools let you create different targets using a common set of source nodes, it’s easy to maintain the files that the targets use. When you add or delete a file from the Source Pool, you don’t have to worry about updating all your target nodes; they’re updated automatically through the reference to the Source Pool.

You can also use Source Pools when you have several header files that you need to include throughout your project. If you place the header files in a Source Pool, you can reference them wherever you need them in your project. Then, you only have to update the original Source Pool when you need to make changes to the group of header files; if you add a new header file to the Source Pool, all the referenced copies are automatically updated.

Source Pools are also useful when you want to assign a single Style Sheet to multiple nodes. For example, if three targets in a project need to use the same Style Sheet, you can reference a Source Pool that contains the Style Sheet instead of attaching the same Style Sheet to each individual node. Then, if you need to update the Style Sheet (for example, if you want change from compiling with debug information to compiling without it), you can update all the targets by modifying the single Style Sheet. You can also use Source Pools to apply custom tools to project nodes. For more information, see the example project \TCWIN45\EXAMPLES\IDE\DELIVER.

Creating a Source PoolWhen you create a Source Pool, you create a target node with a group of nodes under it. However, the target node of the Source Pool cannot be compiled—to compile the nodes

Page 30: UG

30 U s e r ’ s G u i d e

in a Source Pool, you must copy the Source Pool to another target node. Source Pools work to your best advantage when you copy them by reference.

1 In your project, create a new target node by choosing Project|New Target.

2 Type the name of the Source Pool in Target Name.

3 Select SourcePool from the Type list, then press OK to create a Source Pool target node in your project.

4 Select the Source Pool node in the Project Tree, and press Ins to open the Add To Project List dialog box.

5 Select the source files you want, then press OK to add them to the Source Pool.

6 Copy the Source Pool by reference by holding down Alt and dragging the Source Pool to the target nodes you want.

Note To see a working example of Source Pools, open the sample project called SRCPOOL.IDE in the \TCWIN45\EXAMPLES\IDE\SRCPOOL directory. The project file includes a text file that describes how the Source Pool is used in the example.

Translators, viewers, and toolsTranslators, viewers, and tools are internal and external programs that are available to you through the IDE.

• Translators are programs that create one file type from another. For example, the C++ compiler is a translator that creates .OBJ files from .CPP files; the linker is a translator that creates .EXE files from .OBJ, .LIB, .DEF, and .RES files.

• Viewers are programs that let you examine the contents of a selected node. For example, an editor is a viewer that lets you examine the source code of a .CPP file. Resource Workshop is a viewer for Windows resource files.

• Tools are programs that help you create and test your applications. WinSight and GREP are examples of programming tools.

The IDE associates each node in a project with different translators or viewers, depending on the file extension of the node. Although each node can be associated with several different translators or viewers, each node is associated with a single default translator or viewer. This is how the IDE knows to open the Edit window when you double-click a .CPP node (double-clicking a node invokes the default viewer on the node). To see the default node type (determined by file extension) for a specific translator or viewer:

Page 31: UG

C h a p t e r 2 , C r e a t i n g a n d m a n a g i n g p r o j e c t s 31

1 Choose Options|Tools to open 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.

Adding translators, viewers, and tools to the IDEThe Tools dialog box displays the default set of translators, tools, and viewers. The following steps show how to add an item to this list of programs.

1 Choose Options|Tools to access the Tools dialog box. This dialog box displays the default list of translators, tools, and viewers.

2 Choose New to add a new program to the Tools list (to modify a program that’s already listed, select the tool, then choose Edit).

3 Set the following options in the Tools Options dialog box:• Name is a description of the item you’re adding. This is placed on the Tool list.• Path is the path and executable program name. You can use the Browse button to

complete this selection.• Command-line holds any command-line options, transfer macros, and IDE filters

you want to pass to the program. For information on transfer macros, refer to

Figure 2.4 The Tools dialog box

Page 32: UG

32 U s e r ’ s G u i d e

online Help. (Try using $prompt if you want to experiment with transfer macros.) IDE filters are .DLL files that let tools interface with the IDE (for example, the GrepFile tool uses a filter to output text to the Message window). See the FILTER.IDE project in \TCWIN45\EXAMPLES\IDE\FILTER for more information on filters. To see transfer macros and filters in use, choose Options|Tools, then select GrepFiles and choose Edit.

• Menu Text appears on SpeedMenus and on the Tools menu. If you want to assign a shortcut key to your menu text, precede the shortcut letter with an ampersand—this letter appears underlined in the menu. For example, &File assigns F as the shortcut key for File. If you want an ampersand to appear in your menu text, use two ampersands (&&Up&date appears as &Update in the menu).

Note You must supply Menu Text if you want the program item to appear on the SpeedMenu or Tools menu.

• Help Hint is descriptive text that appears in the status line of the Tools dialog box when you select the program item.

4 Open the Advanced Options dialog box (choose Advanced) to set the options for your new program. Depending on the Tool Type you choose (Simple Transfer, Translator, or Viewer), different fields become available. If you create a Translator, the program becomes available for make and build processes.• Place On Tools Menu adds the item to the Tool menu.• Place On SpeedMenu adds a viewer or translator to the associated SpeedMenus.• Target Translator, available for translators and viewers. For translators, this field

specifies whether the program produces a final target (such as an .EXE file) or an intermediate file (such as an .OBJ or .I file). If you check this box, the translator produces a final target that’s saved to the directory you specify in the Final text box (choose Project|Options|Directories). If you don’t check Target Translator, the translated file is saved in the directory you specify in the Intermediate text box.

For viewers, Target Translator specifies that the viewer works only on nodes that have been translated (such as .OBJ or .EXE files); the node has to be translated before you can view it.

• Translate From defines the node types (determined by file extension) that a translator can translate. To specify multiple node types, use a semicolon to separate file extensions.

When you enter a file extension in this field, the Project Manager adds the translator to the Special menu of the project nodes that have that file extension. When you choose Special from the Project Manager SpeedMenu, the Project Manager displays all the available translators for that node type. However, it’s important that each node type can have only a single, default translator (see the description for Default For).

To see how this works, look at the tool CppCompile (choose Options|Tools, double-click CppCompile, then click Advanced). The Tool Advanced Options dialog box shows that the C++ compiler is a translator for .CPP, .C, .CAS, and .H

Page 33: UG

C h a p t e r 2 , C r e a t i n g a n d m a n a g i n g p r o j e c t s 33

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.

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

Figure 2.5 The Tool Advanced Options dialog box

Page 34: UG

34 U s e r ’ s G u i d e

Page 35: UG

C h a p t e r 3 , S p e c i f y i n g p r o j e c t o p t i o n s a n d c o m p i l i n g 35

C h a p t e r

3Chapter 3Specifying project options and

compilingAfter you create a project file and write the code for the source nodes in your project, you need to set the options for the different project nodes before you can compile the project. This chapter describes how to set options in a project, how to view the options you set, how to compile a project, and how to use the Message window to view and fix compile-time errors. In addition, this chapter contains a complete reference to the compiler and linker options that can be set from the IDE.

Setting project optionsProject options tell the IDE how to compile and link the nodes in your project to form the targets you need. The settings of the project options can indicate whether or not to generate debugging information, where to look for source code, what types of compiler optimizations you want to use, and so on.

The Project Manager lets you set project options in two different ways:

• You can attach Style Sheets to your project nodes.• You can override the settings in a Style Sheet using local overrides.

Style Sheets group a collection of option settings into a single unit. Once a Style Sheet is created, you can attach it to a node, a group of nodes, or an entire project. Local overrides are settings that take precedence over Style Sheet settings at the node level.

Using Style SheetsOften, different project nodes require different option settings. For example, you might want to compile .C files with one set of options and .CPP files with another, or you might want to build one target with debugging information, and another one without it. By applying different Style Sheets to different nodes in your projects, you can easily

Page 36: UG

36 U s e r ’ s G u i d e

control how the different nodes get built. In addition, Style Sheets make it easy to view and maintain the settings of your project options.

To view the options that can be incorporated into a Style Sheet, open the Project Options dialog box by choosing Options|Project. This dialog box contains a hierarchical list of topics on the left, with the options that relate to each topic listed on the right. To expand and collapse the Topic list, click the + and – icons to the left of the topic listings.

Figure 3.1 The Project Options dialog box

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.

Predefined Style SheetsThe Project Manager contains several predefined Style Sheets that you can attach to any node in your project. You can also customize a predefined Style Sheet to meet the special needs of your projects, as described in “Managing Style Sheets” on page 37.

To inspect the predefined Style Sheets, choose Options|Style Sheets. This opens the Style Sheets dialog box (shown in Figure 3.2), which lists the predefined Style Sheets on the left and a description of the selected Style Sheet on the right.

The default project optionsWhen you initially create a project, the project inherits the Style Sheet known as the Default Project Options (see “Option defaults” on page 58 for information on these default settings). If you can build all the components in your project with the same options, you can edit this Style Sheet using the Project Options dialog box. However, if different nodes in your project require different option settings, you should override the default option settings by attaching different Style Sheets to the nodes in your project.

Page 37: UG

C h a p t e r 3 , S p e c i f y i n g p r o j e c t o p t i o n s a n d c o m p i l i n g 37

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.

Managing Style SheetsThe buttons at the bottom of the Style Sheets dialog box let you create, compose, copy, edit, rename, and delete user-defined Style Sheets.

• Create lets you design a new Style Sheet for the currently loaded project. To create a Style Sheet,

1 Choose the Create button, then enter a name for your new Style Sheet into the Create Style Sheet dialog box. Choose OK to add the new Style Sheet to the Available Style Sheets list.

2 Select the new Style Sheet from the Available Style Sheets list, then use the Compose, Copy, or Edit buttons to create your custom Style Sheet.

• Compose lets you create a Style Sheet that contains the combined options from one or more Style Sheets. To compose a Style Sheet,

1 Create a new Style Sheet using the Create button.

2 Select the new Style Sheet in the Available Style Sheets list, then click Compose.

3 Select the Style Sheet you want included in your new Style Sheet from the Available Style Sheets list, then move the Style Sheet to the Composite Style Sheets list by double-clicking it or by clicking the → button. (You can also remove Style

Page 38: UG

38 U s e r ’ s G u i d e

Sheets from the Composite Style Sheet list by selecting a Style Sheet there and clicking ←.)

4 Continue modifying the composed Style Sheet, then choose OK when you’re finished.

Note You cannot edit the option settings in a composed Style Sheet. However, you can edit the option settings in the Style Sheets contained in the composed Style Sheet, which affects the settings in the composed Style Sheet.

• Copy lets you create a new Style Sheet from an existing one. When you choose Copy, you’re prompted for the new Style Sheet’s name. Enter the new name, then choose OK to make an exact copy of the selected Style Sheet. Copying is a fast way to create a Style Sheet that closely resembles another—you only have to change the options you want.

• Edit lets you modify the option settings of an existing Style Sheet, including any predefined Style Sheet.

• Rename lets you rename a selected Style Sheet.

• Delete lets you remove an unwanted Style Sheet. (This action cannot be reversed.)

Attaching Style Sheets to a nodeTo attach a Style Sheet to a project node,

1 Right-click the node in the Project Tree (or select it and press Alt+F10).

2 Choose Edit Node Attributes from the SpeedMenu. The Node Attributes dialog box appears.

3 Select a Style Sheet from the drop-down box, then choose OK.

When you attach a Style Sheet to a node, all the child nodes of that node inherit the settings of the selected Style Sheet. To change the settings of a child node, attach a different Style Sheet, or override an option setting using a local override.

Note Although you can attach only a single Style Sheet to a project node, one Style Sheet can be composed of several different Style Sheets.

Sharing Style Sheets between projectsWhen you create a custom Style Sheet, that Style Sheet remains with the project for which it was created; it doesn’t get added to the list of predefined Style Sheets. However, if you want a new project to use one of your custom Style Sheets or user-defined tools, you can do so by letting a project inherit the settings of another project.

Before a project can inherit the settings of another project, you must modify the TCW.INI file that resides in your Windows directory. If the file doesn’t contain an inherit setting, then you must add the settings to the file as follows:

[Project];To have new projects inherit settings from the Default Project Settings (default):inherit=0

Page 39: UG

C h a p t e r 3 , S p e c i f y i n g p r o j e c t o p t i o n s a n d c o m p i l i n g 39

;To have new projects inherit settings from currently open project:inherit=1

;To have new projects inherit factory default settings:inherit=2

To pass Style Sheets or user-defined tools from one project to a new project,

1 Modify TCW.INI so that inherit=1.

2 Open the project that contains the Style Sheet or tools you want to share.

3 Choose Project|New Project.

When the new project is created, it inherits the Style Sheets and user-defined tools of the project that was open when you choose Project|New Project.

Setting local overridesOption settings can be overridden at the node level using local overrides. Local overrides are useful when a node’s option settings must differ from its associated Style Sheet by one or two settings.

Note Although local overrides make it easy to set options for individual nodes, they have the disadvantage of being difficult to track. While the Options Hierarchy dialog box (described in “Viewing project options” on page 40) displays the Style Sheet and local override settings for a selected node, you must examine each individual node to see which ones have been overridden. Because of this, it’s recommended that you use separate Style Sheets for nodes that require different option settings, and use local overrides only in special cases.

To override an option setting,

1 Choose the node whose settings you want to override.

2 Right-click the node (or press Alt+F10) and choose Edit Local Options from the SpeedMenu. The Options dialog box (which is similar to the Project Options dialog box) appears and displays the settings for that node.

3 Select the option you want to override. The IDE automatically checks the Local Override box whenever you modify a Style Sheet setting.

4 Choose OK to confirm your new settings.

Warning! The Local Override check box is enabled only when an option within a topic is selected; otherwise, the check box is grayed. When you select an option (using Tab, or by clicking and dragging the mouse off the option), the Local Override check box shows the status of the selected option. Because of this, you must individually select each option in a topic to see which ones have been overridden locally. If you choose an option (by clicking it, or by selecting it and pressing Enter), you change its setting, which always causes the Local Override check box to be checked.

To undo an override,

1 Right-click the node whose setting you want to modify, then choose Edit Local Options from the SpeedMenu.

Page 40: UG

40 U s e r ’ s G u i d e

2 In the Options dialog box, select the topic that contains the overridden setting.

When you select a topic page that has a locally overridden option, the Project Manager enables the Undo Page button.

3 Select the option (using Tab, or by clicking and dragging the mouse off the option) whose local override you want to undo; the Local Override check box will be checked.

4 Click the Local Override check box to undo the override; the option will revert to its default Style Sheet setting. To revert the entire topic to the settings contained in the associated Style Sheet, choose the Undo Page button.

5 Choose OK to confirm your modifications.

Viewing project optionsBecause each node can have its own Style Sheet and you can override the options in the Style Sheet, you need a quick way to view the option settings for each node.

To view option settings for the nodes in your project,

1 Right-click any node in the Project window and choose View Options Hierarchy, or click the button on the SpeedBar.

The Options Hierarchy dialog box appears, listing the nodes in the project on the left and the options that each node uses on the right. You can expand and collapse the list of nodes in the dialog box just like you can in the Project window, however, Autodependency nodes don’t appear.

Note An option that’s surrounded by double-asterisks (**) in the Options listing indicates that the option is overridden (by either a Style Sheet or local override) by a dependent node located farther down in the Options listing. (The asterisks display only when you select the node where the option is overridden.)

2 When you select a node in the Project Options At list, its settings appear to the right in the Options list.

Figure 3.3 The Options Hierarchy dialog box

Page 41: UG

C h a p t e r 3 , S p e c i f y i n g p r o j e c t o p t i o n s a n d c o m p i l i n g 41

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

Page 42: UG

42 U s e r ’ s G u i d e

For example, if you have a project with an .EXE target that is dependent on two separate .OBJ files, the Project Manager creates the first .OBJ file by compiling all its dependents. It then creates the next .OBJ file. Once a target node’s dependents are created, it can compile or link the target node. In this case, the Project Manager will link the two .OBJ files (and any runtime nodes) to create the final .EXE.

Compiling part of a projectThere are several ways to compile specific parts of a project. You can

• Translate an individual node• Build a node and its dependents• Make a node and its dependents• Select several nodes and compile

To translate an individual node,

1 Select the node you want to translate.

2 Choose Project|Compile from the main menu or choose the default translation command from the SpeedMenu. For example, if you’ve selected a .CPP file, the node SpeedMenu contains the command C++ Compile, which compiles only the selected node.

To build a node and its dependents,

1 Select the node you want to build.

2 Right-click the node (or press Alt+F10) and choose Build Node from the SpeedMenu. All the dependent nodes are built regardless of whether they’re out-of-date.

To make a node and its dependents,

1 Select the node you want to build.

2 Right-click the node (or press Alt+F10) and choose Make Node from the SpeedMenu. This command compiles only the dependent nodes whose source files are newer than their associated target files.

To compile several selected nodes,

1 Select the project nodes you want to compile by pressing Ctrl and clicking the desired project nodes. (The nodes must be of the same file type, such as .CPP).

2 Choose Make Node or Build Node from the Project Manager SpeedMenu to compile the selected nodes.

Fixing compile-time errorsCompile-time errors, or syntax errors, occur when your code violates a syntax rule of the language you’re programming in; the C++ compiler cannot compile your program unless it contains valid language statements. If the compiler encounters a syntax error while compiling your code, the Message window opens and displays the type of error

Page 43: UG

C h a p t e r 3 , S p e c i f y i n g p r o j e c t o p t i o n s a n d c o m p i l i n g 43

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

Project options referenceYou set compiler, linker, librarian, and make options in the Project Options multiple-page dialog box. In the following sections, the options in the Project Options dialog box are described in the order that they appear in the Topics list on the left side of the box. The chapter ends with a section listing the default options set by the IDE.

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

Page 44: UG

44 U s e r ’ s G u i d e

Library instructs the IDE to get the C0x.OBJ startup file, the Turbo C++ library files, and all other .OBJ and .LIB files from the named directory or directories. By default, the linker looks for the files in the directory containing the project files.

Source is an additional set of directories where the IDE looks for source code.

Intermediate is where the associated tool (such as a compiler or resource compiler) places any files that the tool creates.

Final is the location where the IDE places the generated target files (for example, .EXE and .DLL files).

File-search algorithmsTurbo 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 asc:\my_libs\mylib1.lib), Turbo C++ searches only the location specified with the library file name; other directories are not searched.

CompilerThe compiler topic contains general compiler options, such as the debugging options, the code generation options, and so on.

Page 45: UG

C h a p t e r 3 , S p e c i f y i n g p r o j e c t o p t i o n s a n d c o m p i l i n g 45

DefinesThe 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 generationAllocate 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.

Page 46: UG

46 U s e r ’ s G u i d e

Automatic uses register variables. The compiler automatically assigns variables to registers if possible, even when you don’t specify a register variable by using the register type specifier. This option is on by default.

Floating PointNo 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 OutputAutodependency 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.

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

Page 47: UG

C h a p t e r 3 , S p e c i f y i n g p r o j e c t o p t i o n s a n d c o m p i l i n g 47

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.

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

Page 48: UG

48 U s e r ’ s G u i d e

Precompiled headersGenerate And Use generates and uses precompiled header files using the default file name <projectname>.CSM. Precompiled headers can dramatically increase compile speed, although they require considerable disk space. See Appendix B for more information on precompiled headers.

Use But Do Not Generate uses preexisting precompiled header files, but doesn’t generate new ones.

Do Not Generate Or Use doesn’t generate or use precompiled header files.

Precompiled Header Name lets you specify the name of your precompiled header file. When this option is used from the command line, the compiler generates and uses precompiled headers and sets the name of the precompiled header file to fname.

Stop Precompiling After Header File stops compiling precompiled headers when it compiles the file specified as “xxx”.

Advanced CompilerThe following sections describe advanced compiler options.

Processor80386 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 ConventionC 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.

Page 49: UG

C h a p t e r 3 , S p e c i f y i n g p r o j e c t o p t i o n s a n d c o m p i l i n g 49

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

Page 50: UG

50 U s e r ’ s G u i d e

Fast Huge Pointers offers an alternative method of calculating huge pointer expressions. Huge pointers are normalized by the value of the variable _ALTINCR, which is initialized by Windows at the startup time of the application.

Usually, Turbo C++ normalizes a huge pointer whenever adding to or subtracting from it. This ensures, for example, that if you have a huge array of structs that’s larger than 64K, indexing into the array and selecting a struct field always works with structs of any size. Turbo C++ accomplishes this by always normalizing the results of huge pointer operations—the address offset contains a number that is no higher than 15 and a segment wraparound never occurs with huge pointers. The disadvantage of this approach is that it tends to be quite expensive in terms of execution speed.

Automatic Far Data changes global variables greater than or equal to the threshold size to far. The threshold size defaults to 32,767. This option is useful for code that doesn’t use the huge memory model but declares enough large global variables that their total size is close to or exceeds 64K. For tiny, small, and medium models, this option has no effect. If you use this option in conjunction with the Generate COMDEFs option on the Compiler|Floating Point page, the generated COMDEFs become far in the compact, large, and huge models.

Far Data Threshold changes the point where data is forced to be far (used by the Far Data Threshold option).

Segment Names DataUse these options only if you have a good understanding of segmentation on the 80x86 processor. Under normal circumstances, you don’t need to specify segment names.

Initialized Data Segment sets the name of the initialized data segment to name. By default, the initialized data segment is named _DATA for near data and modulename_DATA for far data.

Initialized Data Group changes the name of the initialized data segment group to name. By default, the data group is named DGROUP.

Initialized Data Class sets the name of the initialized data segment class to name. By default, the initialized data segment class is named DATA.

Uninitialized Data Segment changes the name of the uninitialized data segment to name. By default, the uninitialized data segment is named _BSS for near uninitialized data and modulename_BSS for far uninitialized data.

Uninitialized Data Group changes the name of the uninitialized data segment group to name. By default, the data group is named DGROUP.

Uninitialized Data Class changes the name of the uninitialized data segment class to name. By default, the uninitialized data segments are assigned to class BSS.

Segment Names Far DataFar Data Segment changes the name of the segment where _ _far objects are put to name. By default, the segment name is the name of the source file followed by _DATA. A name beginning with an asterisk (*) indicates that the default string should be used.

Page 51: UG

C h a p t e r 3 , S p e c i f y i n g p r o j e c t o p t i o n s a n d c o m p i l i n g 51

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.

Segment Names CodeCode Segment changes the name of the code segment to name. By default, the code segment is named _TEXT for near code and modulename_TEXT for far code.

Code Group causes any output files to be generated with a code group for the code segment named name.

Code Class changes the name of the code segment class to name. By default, the code segment is assigned to class CODE.

Entry/Exit CodeEntry/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

Page 52: UG

52 U s e r ’ s G u i d e

you use this option along with the _export keyword, you don’t need to define exports in your .DEF files.

Windows Smart Callbacks, All Functions Exportable creates an object module with smart callbacks for all far functions exported. Use this option only if the compiler can assume that DS==SS for all functions in the module (which is the vast majority of Windows programs, and the default for Borland tools).

This option creates a Windows .EXE function prolog/epilog for all far functions, then sets up those functions to be called from another module. MakeProcInstance need not be called and no .DEF file editing is needed.

Windows Smart Callbacks, Explicit Functions Exportable creates an application with smart callbacks and explicit exported functions. This option is the same as Windows Smart Callbacks except that only those functions marked with the _export keyword (and methods of classes marked as _export) are given the extra prolog/epilog. This is far more efficient 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.

Windows DLL, All Functions Exportable creates a DLL object module with all far functions exportable. This option creates a Windows DLL 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 .DLL, function names need to be included in the .DEF file of the executable.

Windows DLL, Explicit Functions Exported creates a DLL object module in which only far functions marked as _export are exportable. The Windows DLL, Explicit Functions Exported is the same as Windows DLL, 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 is far more efficient than Windows DLL, 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. No .DEF file manipulation is needed.

C++ OptionsThe C++ options let you control the compiler’s interpretation of the C++ language.

Member PointerHonor 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.

Page 53: UG

C h a p t e r 3 , S p e c i f y i n g p r o j e c t o p t i o n s a n d c o m p i l i n g 53

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++ CompatibilityDo 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 TablesThe 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.

TemplatesFor 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

Page 54: UG

54 U s e r ’ s G u i d e

of the instance. To generate the instances, however, the compiler must have available the function body (in the case of a template function) or the bodies of the member functions and definitions for static data members (in the case of a template class).

Global generates public definitions for all template instances encountered. Duplicate instances are not merged, causing the linker to report public symbol redefinition errors if more than one module defines the same template instance.

External generates external references to template instances. Make sure instances are publicly defined in some other module (using the Global option), so that external references are properly resolved.

Exception handling/RTTIEnable 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.

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

Page 55: UG

C h a p t e r 3 , S p e c i f y i n g p r o j e c t o p t i o n s a n d c o m p i l i n g 55

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.

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

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

Page 56: UG

56 U s e r ’ s G u i d e

Map FileOff tells the linker to not generate a map file.

Segments creates a map file with the same features as the publics option, but adds a detailed segment map. If you don’t specify map file options, then the Segments option is used. For each segment in each module, this map file includes the address, length in bytes, class, segment name, group, module, and ACBP information. If the same segment appears in more than one module, each module appears as a separate line. Except for the ACBP field, the information in the detailed segment map is self-explanatory.

The ACBP field encodes the A (alignment), C (combination), and B (big) attributes into a set of four bit fields, as defined by Intel. The linker uses only three of the fields, the A, C, and B fields. The ACBP value in the map is printed in hexadecimal. The following values of the fields must be OR’ed together to arrive at the ACBP value printed.

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.

Field Value Description

The A field (alignment) 00 An absolute segment.20 A byte-aligned segment.40 A word-aligned segment.60 A paragraph-aligned segment.80 A page-aligned segment.A0 An unnamed absolute portion of storage.

The C field (combination) 00 Cannot be combined.08 A public combining segment.

The B field (big) 00 Segment less than 64K.02 Segment exactly 64K.

0002:000008740002:00000CE40002:000000E7

Idle

Idle

Symbol1Symbol2Symbol3

Page 57: UG

C h a p t e r 3 , S p e c i f y i n g p r o j e c t o p t i o n s a n d c o m p i l i n g 57

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

Page 58: UG

58 U s e r ’ s G u i d e

Once the import library or .DEF file has been created, there is no need to keep the names in either the resident or the nonresident names tables. Relinking the .DLL and specifying both the Transfer Resident Names To Nonresident Names Table and Discard Nonresident Names Table options cause the linker to build a .DLL with an “empty” names table. Not only does this post-processing avoid the problem of exceeding the header limitation, it also creates a .DLL that loads faster (because it’s smaller) and runs faster (because references to entry points are by ordinal number instead of by name). To summarize this process, you must:

1 Enable the Transfer Resident Names To Nonresident Names Table option to transfer the names in the resident names table to the nonresident names table. This also assigns ordinal numbers to the names. However, before doing so; make sure you have included a .DEF file with the following export definition in the EXPORTS section:

EXPORTSWEP @1 RESIDENTNAME

2 Build the .DLL.

3 Run IMPLIB/IMPDEF on the new .DLL file.

4 Enable the Discard Nonresident Names Table option.

5 Relink the .DLL.

Other Project Options dialog box optionsDefinitions for the Librarian, Resources, and Make topics in the Project Options dialog box can be found in online Help by selecting the options, then choosing the Help button.

Option defaultsWhen 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 | DefinesCompiler | Code Generation | Allocate enums As intsCompiler | Code Generation | Register Variables: AutomaticCompiler | Floating Point | Fast Floating PointCompiler | Compiler Output | Autodependency InformationCompiler | Compiler Output | Generate UnderscoresCompiler | Source | Borland ExtensionsCompiler | Debugging | Standard Stack FrameCompiler | Debugging |Debug Information In OBJsCompiler | Debugging |Browser Reference Information In OBJsCompiler | Precompiled Headers | Generate And Use

Page 59: UG

C h a p t e r 3 , S p e c i f y i n g p r o j e c t o p t i o n s a n d c o m p i l i n g 59

Advanced Compiler | Processor | Instruction Set: 80386Advanced Compiler | Processor | Data Alignment: ByteAdvanced Compiler | Calling Convention | CAdvanced Compiler | Memory Model | LargeAdvanced Compiler | Entry/Exit Code | Windows smart callbacks, All Functions ExportableC++ Options | Member Pointer | Member Pointer Representation: Support All CasesC++ Options | C++ Compatibility | Virtual Base Pointers: Always NearC++ Options | Virtual Tables | Linkage: SmartC++ Options | Templates | Instance Generation: SmartC++ Options | Exception Handling/RTTI | Enable ExceptionsC++ Options | Exception Handling/RTTI | Enable Destructor CleanupC++ Options | Exception Handling/RTTI | Enable Runtime Type InformationMessages (see “Messages” on page 54 for default Message information)Linker | General | Case Sensitive LinkLinker | General | Case Sensitive Exports And ImportsLinker | General | Include Debug InformationLinker | General | Default LibrariesLinker | General | Pack Code Segments (Code Pack Size 8192)Linker | Map File | OffLinker | Map File | Include Source Line NumbersMake | Break Make On: ErrorsMake | Autodependencies: Cache

Table 3.1 Default Project Option settings (continued)

Option

Page 60: UG

60 U s e r ’ s G u i d e

Page 61: UG

C h a p t e r 4 , B u i l d i n g a p p l i c a t i o n s w i t h A p p E x p e r t 61

C h a p t e r

4Chapter 4Building applications with AppExpertAppExpert generates ObjectWindows 2.0 applications, which provide source-code foundations to the Windows applications you want to create. For example, AppExpert generates the source code for your main and child windows, tool bars, status bars, menu systems, and online Help systems. You can also use AppExpert to add other features to your Windows programs, such as scroll bars, Min and Max boxes on a caption bar, and printing and print preview.

After AppExpert generates an application, you can use ClassExpert and Resource Workshop to help complete the program functionality. To get the most out of AppExpert, you should be familiar with ClassExpert (described in Chapter 5), Resource Workshop (described in Part II), ObjectWindows (described in ObjectWindows Programmer’s Guide), and the Project Manager (described in Chapter 2).

AppExpert lets you create programs that conform to the following program models:

• Single-document interface (SDI) model, which lets you have only a single object open at a time.

• Multiple-document interface (MDI) model, which lets you have a number of objects and views open at the same time.

• “Dialog Client” model, which uses a dialog box as the main user interface.

In addition, you can choose to have your application follow the Document/View model of ObjectWindows (for more information on Document/View, see the ObjectWindows Programmer’s Guide).

This chapter provides the following sections to help you get started with AppExpert:

• “AppExpert basics” describes the general method for creating an application with AppExpert.

• “Creating a small application” shows you how to create an SDI application.

• “AppExpert options reference” summarizes AppExpert options.

Page 62: UG

62 U s e r ’ s G u i d e

AppExpert basicsThe following steps outline the basic tasks involved in creating an application:

1 Use AppExpert to define the user interface and general features of your application.

2 Generate the source code of your application.

3 Use ClassExpert to add functionality to your application. With ClassExpert, you add code to classes, event handlers, virtual functions, and so on.

4 Use Resource Workshop to edit and add Windows resources, such as dialogs, dialog controls, and menus.

5 Use the Project Manager to build your program.

When you generate an application with AppExpert, it creates the following files:

Depending on the options you choose, AppExpert can also generate the following files:

Creating a small applicationThe following tutorial shows how to use AppExpert to create an SDI application that uses the ObjectWindows framework.

1 Start the IDE and choose Project|AppExpert to open the New AppExpert Project dialog box.

2 Type \myapp\draw into the File Name text box. This specifies both the path and the project file name for your new application. By default, most generated files (including the .EXE) are derived from the project name you supply.

If the directory you specify doesn’t exist, AppExpert creates it for you. You can also use the Directories list box to select an existing directory for your project. In either case, the directory you specify becomes the base directory for all generated source files. To help organize your project files, it’s best to use a unique base directory for each project you create.

3 Choose OK. The AppExpert Application Generation Options dialog box appears. It contains a list of topics on the left, with the options that relate to each topic on the right. To expand the hierarchical topics list, click the + and – icons to the left of the listed topics, or right-click in the Topics pane to reveal a SpeedMenu that contains

• A project file (.IDE)• A source file (.CPP)• A resource header file (.RH)• A module-definition file (.DEF)

• A header file (.h)• A resource script file (.RC)• An AppExpert database file (.APX)

• Help source files (.RTF)• A Help project file (.HPJ)• Icon and bitmap files (.ICO and .BMP)

Page 63: UG

C h a p t e r 4 , B u i l d i n g a p p l i c a t i o n s w i t h A p p E x p e r t 63

commands to expand and contract the list of topics. For online help on any of the options or topics, choose Help.

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.

Figure 4.1 AppExpert Application Generation Options dialog box

Page 64: UG

64 U s e r ’ s G u i d e

11 After AppExpert generates the application, the Project window appears and lists most of the files that AppExpert generated. From here, you can build the application, or you can use ClassExpert to add the functionality of the application. To build your application, choose Project|Build All.

Note With AppExpert, you specify your application options once, then generate the code. After generating the code, you can modify the files with ClassExpert, but you can’t go back to AppExpert and change options. For example, if you generate an application with no status line, you can’t use AppExpert later to add that functionality—you need to add it manually, or regenerate the application from scratch.

Overview of the generated codeAppExpert generates the following files when you generate the DRAW.IDE project:

The application objectAfter you generate DRAW.IDE, the Project Manager opens and displays the a project tree showing the project files generated by AppExpert. Figure 4.2 shows DRAW.IDE in the Project Manager (the Project Manager has both run-time nodes and the project node visible).

Table 4.1 Sample application files

File name Description

DRAWAPP.CPP Source file for the application object and the main window object.DRAWAPP.H Header file for the application object and the main window object.DRAWWNDW.CPP Source file for the client window object.DRAWWNDW.H Header file for the client window object.DRWABTDL.CPP Source file for the About dialog box object.DRWABTDL.H Header file for the About dialog box object.DRAWAPP.RC The resource script file for the project.DRAWAPP.RH The resource header file for the project.DRAWAPP.DEF Module definition file for the project.DRAW.APX Database files that stores project information which ClassExpert uses.APPLSDI.ICO Predefined icon for the project.DRAW.IDE The IDE project file.

Page 65: UG

C h a p t e r 4 , B u i l d i n g a p p l i c a t i o n s w i t h A p p E x p e r t 65

Figure 4.2 DRAW.IDE loaded into the Project Manager

From the Project Manager, open DRAWAPP.CPP by double-clicking the source-file listing. The rest of this section describes the code in this file.

/* Project DrawThe SourceWorks, Inc.Copyright © 1994. All Rights Reserved.

SUBSYSTEM: draw.exe ApplicationFILE: drawapp.cppAUTHOR: Ed Moddyƒ

The first few lines in the file describe the application. AppExpert gets some of this information from your entries in the Application|Administrative Options topic. Farther down in the listing, you’ll notice a number of comments with a structure similar to the following lines of code:

//{{ ... }}

//{{..._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:ƒ

Page 66: UG

66 U s e r ’ s G u i d e

This code shows that AppExpert derives DrawApp from TApplication. In this DrawApp, AppExpert defines a constructor and destructor, overrides the function InitMainWindow, and defines some command response functions.

AppExpert defines the member functions declared in drawapp.h in DRAWAPP.CPP. AppExpert also defines a response table to handle the basic menu items contained in DRAWAPP.CPP:

ƒ//{{DrawApp Implementation}}

//// 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 (*.*)|*.*|");

// INSERT>> Your constructor code here.

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

Page 67: UG

C h a p t e r 4 , B u i l d i n g a p p l i c a t i o n s w i t h A p p E x p e r t 67

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 *frame = new SDIDecFrame(0, GetName(), 0, false);

nCmdShow = nCmdShow != SW_SHOWMINIMIZED ? SW_SHOWNORMAL : nCmdShow;ƒ

Taking a look at the constructor for SDIDecFrame, you’ll see that the it allocates an instance of DrawWindow, and sets the instance to be its client window if no other is passed to it. Again, the destructor for SDIDecFrame is only a placeholder.

ƒ//{{SDIDecFrame Implementation}}

SDIDecFrame::SDIDecFrame (TWindow *parent, const char far *title, TWindow *clientWnd, bool trackMenuSelection, TModule *module)

: TDecoratedFrame(parent, title, clientWnd == 0 ? new DrawWindow(0, "") : clientWnd, trackMenuSelection, module)

{// INSERT>> Your constructor code here.

}

SDIDecFrame::~SDIDecFrame (){ // INSERT>> Your destructor code here.}ƒ

The client windowThe window class that AppExpert creates is DrawWindow. This class is defined in drawwndw.h and DRAWWNDW.CPP. By viewing this code, you’ll notice that AppExpert generates only a constructor and a destructor. The constructor performs a single function; it calls the constructor for the base class TWindow. The DrawWindow destructor calls Destroy as a precautionary measure. This ensures that your application provides the proper cleanup when you terminate the program.

Page 68: UG

68 U s e r ’ s G u i d e

AppExpert options referenceThis section describes the options that are available from the AppExpert Application Generation Options dialog box, shown in 3 on page 63. Topics and options are described in the order in which they appear in the Topics list.

ApplicationThe 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 OptionsThe 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.

Page 69: UG

C h a p t e r 4 , B u i l d i n g a p p l i c a t i o n s w i t h A p p E x p e r t 69

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

Page 70: UG

70 U s e r ’ s G u i d e

Application Is An OLE 2 Server EXE specifies an .EXE OLE 2 server.

Enable Automation In The Application specifies this application is now capable of exposing objects for OLE 2 automation. For best results, use ClassExpert to select the objects to expose for automation.

Server ID generates a unique OLE 2 GUID or USID server identification number. Although you can edit this field, it’s best to let the system generate the number for you.

Code Gen ControlCode Gen Control options name various elements of the code-generation process, and let you specify where to store the generated code.

Target Name displays the name of the project, as defined in Basic Options|Target.

Base Directory displays the base directory for the project, as defined in Basic Options|Base Directory.

Source Directory lets you specify the directory for the application source files. This path is relative to the directory specified as the Base Directory (see the Basic Options topic). If supply an absolute path, it’s converted to a path relative to the Base Directory (you can’t specify another drive). You can choose a directory by typing it or by using Browse to select one. The default value for the Source Path is “.\” (which is the Base Directory).

Header Directory lets you specify the directory for the application header files. This path is relative to the directory specified as the Base Directory. If you supply an absolute path, it’s converted to a path relative to the Base Directory (you can’t specify another drive). The default value for the Header Path is “.\” (which is the Base Directory).

Main Source File names the main application source file.

Main Header File names the main application header file.

Application Class specifies the class that AppExpert derives from TApplication. The default class name is based on the project name.

About Dialog Class specifies the class that AppExpert derives from TDialog. The default class name is based on the project name.

Comments documents the generated code partially (terse) or fully (verbose).

Admin OptionsAdmin 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.

Page 71: UG

C h a p t e r 4 , B u i l d i n g a p p l i c a t i o n s w i t h A p p E x p e r t 71

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 WindowMain 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 OptionsBasic 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).

Page 72: UG

72 U s e r ’ s G u i d e

SDI ClientSDI Client defines the class that represents the client window of the Single Document Interface frame.

Client/View Class names the class of the SDI client area window or view. The interpretation of this value depends on whether you selected Document/View in the Application Model settings. If Document/View is selected, Client/View Class specifies the default view class. If Document/View is not selected, Client/View Class selects the class of the client window.

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 ClientThe 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

Document/View on Document/View off

TEditView (default) TEditFile (default)TListView TListBox

TWindowView TWindow

Page 73: UG

C h a p t e r 4 , B u i l d i n g a p p l i c a t i o n s w i t h A p p E x p e r t 73

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 ClientDialog 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/ViewMDI 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.

Page 74: UG

74 U s e r ’ s G u i d e

Basic OptionsBasic Options define the default MDI child window.

MDI Client/View Class names the class of the default MDI view. The interpretation of this value depends on whether you check the Document/View setting in the Application topic:

Document Class, available only if your application supports Document/View, names the class of the document in the default Document/View (TFileDocument by default).

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 MDI frame window. By default, AppExpert names this class <TargetName><ClientClass>. This class is derived from the class specified in the MDI Client/View Class text box.

Source File is the name of the source file that implements the class named in the MDI Client/View Class text box. By default, AppExpert names this file <TargetName><ClientClass>.CPP (if needed, AppExpert shortens the project name to limit the file name to eight characters).

Header File specifies the name of the header file that defines the class named in the MDI 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).

Document/View on Document/View off

TEditView (default) TEditFile (default)

TListView TListBox

TWindowView TWindow

Page 75: UG

C h a p t e r 5 , M o d i f y i n g a p p l i c a t i o n s w i t h C l a s s E x p e r t 75

C h a p t e r

5Chapter 5Modifying applications with

ClassExpertClassExpert works with the applications that you create with AppExpert. ClassExpert lets you create new classes, edit and refine the implementation of classes, and navigate through the source code for existing classes. You can also use ClassExpert with Resource Workshop to associate classes with resources (for example, you can associate a TDialog class with a dialog resource). In addition, ClassExpert displays virtual functions and events for existing classes, and it checks the virtual functions implemented in your application.

Starting ClassExpertTo 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

Page 76: UG

76 U s e r ’ s G u i d e

ClassExpert basicsThe ClassExpert window consists of three independent panes: the Classes pane, the Events pane, and the Edit pane. You can size the individual panes by dragging their borders. If you resize the ClassExpert window, the panes retain their relative proportions.

Classes paneThe 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 paneThe 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 paneThe 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 classClassExpert lets you add ObjectWindows-based classes and supports one level of inheritance. If you need to add more derivations, you must do so manually.

Page 77: UG

C h a p t e r 5 , M o d i f y i n g a p p l i c a t i o n s w i t h C l a s s E x p e r t 77

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.

3 Set the options in this dialog box as follows:• Base Class is the ObjectWindows base class you want your class derived from.• Class Name is the name you want to give to the new class.• Source File is the file name that contains the source code to the class. The file

indicates should be located in the source directory of the project.• Header File is the name of the header file that defines the class. This file defaults to

the source file name but uses the extension .h.• Show All OWL Classes, when enabled, displays all available ObjectWindows

classes in the Base Class combo box. This allows you to select from the non-GUI classes that are not derived from either TEventHandler or TWindow.

4 Set the following options according on your Base Class selection:• Resource Id displays if your Base Class entry is TDialog. Use Resource Id to

specify the dialog template associated with TDialog. The Resource Id combo box contains IDs for all the current dialog resources in your application. If you specify an ID that doesn’t exist, ClassExpert creates an empty dialog template with the identifier you specify (for consistency, use the prefix IDD_). ClassExpert then loads Resource Workshop so you can define the dialog box.

• Class Client displays if your Base Class selection is TFrameWindow or a TFrameWindow-derived class. Choose an existing class in the Client Class combo box to represent the client area of the new frame window. Note that this is the only value that you can change after you create the class.

• Set Window Properties displays if Base Class is TWindow or a TWindow-derived class. When you choose the Set Window Properties button, the Window Styles dialog box appears, from where you can set the window properties (such as the window color, border, caption, and so on) of the new frame window. See the

Figure 5.2 Add New Class dialog box

Page 78: UG

78 U s e r ’ s G u i d e

“Main Window” on page 71 for information on the individual window options. Choose OK when you’re done.

5 Choose OK again to add the new class and have ClassExpert add a source node to the project tree.

Creating document typesWhen you create an application that supports Document/View, you can use ClassExpert to create view classes and document types.

To create a document type,

1 Using AppExpert, create a class for the view (unless you want to use one of the three predefined view classes TEditView, TListView, or TWindowView).

2 In ClassExpert right-click the Classes pane, then choose View Document Types from the SpeedMenu.

3 Select a view class (if you created your own class, it appears in this list). The default view classes are• TEditView provides a view wrapper for ObjectWindows text edit class.• TListView provides views for list boxes.• TWindowView provides window-based views.

4 Use the Description text box to describe the class of files associated with the Files Of Type lists that appear in Windows common file dialog boxes. The default value is All Files (*.*). The value you specify serves as the description for the value entered in Filters.

5 Use Filters to list wildcard file specifications (separate different filters with a comma). The filters you specify are passed to Windows common file dialog boxes to filter the files that appear in those dialog boxes. For example, if you’re creating a document type for bitmaps, you might have a filter *.BMP. The default value for this field is *.*, and the value entered in Description serves as an explanation of this value.

6 Use Default Extension to specify the default file-name extension. This value is passed to Windows common file dialog boxes and added to file names that do not have extensions. The default value is TXT.

7 Click the Style’s button to set styles for the Document/View. The styles you can choose are as follows (see the ObjectWindows documentation for more information):• dtAutoDelete deletes the document object when the last view is closed.• dtNoAutoView doesn’t automatically create a default view type.• dtSingleView provides a single view for each document.• dtAutoOpen opens a document when it’s created.• dtUpdateDir updates the directory with the dialog directory.• dtHidden hides the template from the list of user selections.• dtSelected indicates the last selected template.

Page 79: UG

C h a p t e r 5 , M o d i f y i n g a p p l i c a t i o n s w i t h C l a s s E x p e r t 79

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

Adding and deleting event handlersTo add a handler for an event,

1 In the Classes pane, select the class for the event handler. The events appear in the Events pane.

2 Select the event to handle (you might have to expand the list of events), then right-click the event to view the SpeedMenu.

3 Choose Add Handler from the SpeedMenu.

• If you add a handler for a Windows message, ClassExpert adds an entry to the response table whose name is defined by default. The function associated with the handler appears in the Edit pane with the appropriate default handling code defined.

• If you add a handler for a virtual function, the function associated with the handler appears in the Edit pane with the appropriate default handling code defined.

• If you add a handler for either command or control notifications, ClassExpert prompts you for the function name before adding the entry to the response table.

Note The Add Handler SpeedMenu command is applicable only for events that are not already handled by a member function of the selected class. Unhandled events and non-overridden virtual functions do have a check mark next to them in the Events pane (the Events pane marks handled events with a check mark). A lighter gray check mark means that some events under the event category are handled (expand the list to view the all the actual events).

To delete a handler for an event,

1 In the Classes pane, select the class for the message handler. The events appear in the Events pane.

2 Select the check-marked event with the handle you want to remove (you might have to expand the list of events), then right-click the event to view the SpeedMenu.

Page 80: UG

80 U s e r ’ s G u i d e

3 Choose Delete Handler. ClassExpert deletes the handler from the Events pane, but the code that implements the function is not deleted. ClassExpert notifies you of this and you have to manually remove the function code. The code for the handler appears in the Edit pane, so you can delete it. If you delete the function, remove the function definition from the header file (you can choose Edit Header from the Classes pane SpeedMenu to view the file). If you delete an event, command, or control notification, ClassExpert removes the associated response table entry.

Adding and deleting instance variablesInstance variables let you handle many controls easily. When you create instance variables, ClassExpert adds a transfer buffer to your code. This transfer buffer collects information at run time, so you can use the information in the transfer buffer instead of creating code that checks whether each check box is enabled. For example, if you have a dialog box that has six check-box controls, and you want your application to do something based on which boxes are checked, you can use instance variables for each control, then use the transfer-buffer data in your code. Consult the ObjectWindows Programmer’s Guide for more information on transfer buffers and instance variables.

To add (associate) an instance variable to a control,

1 Right-click the control notification in the Events pane, then choose Add Instance Variable from the SpeedMenu (you might need to expand the list of control notifications to view the control you need to modify).

2 In the Add Instance Variable dialog box, type a name for the variable. ClassExpert adds the following to your application code:• In the header file, it adds a structure declaration with an entry for the instance

variable.• In the .CPP file, the instance variable is allocated in the class constructor (this

allocates the ObjectWindows class with the resource object).• In the .CPP file, a static instance of the transfer structure is declared.

3 Choose OK. The Control Notifications in the Events pane displays the class and name of the instance variable you just created.

To delete an instance variable,

1 Select the control with the instance variable you want to delete.

2 Right-click the control and choose Delete Instance Variable from the SpeedMenu.

3 ClassExpert deletes the following from your code:• The entry from the structure• The pointer variable in the class declaration• The allocation of the class variable associated with the resource control in the

constructor

If you delete all instance variables from your code, you’ll be left with an empty structure and the call to set the transfer buffer. Because this information doesn’t affect the rest of your code, you don’t need to delete it manually.

Page 81: UG

C h a p t e r 5 , M o d i f y i n g a p p l i c a t i o n s w i t h C l a s s E x p e r t 81

Jumping to class source codeTo 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 Resource Workshop with ClassExpertResource Workshop is the default viewer for resource scripts (.RC files). When you start Resource Workshop from ClassExpert (by choosing Edit Dialog or Edit Menu from a SpeedMenu), Resource Workshop automatically loads the RC script for that application.

When using Resource Workshop with AppExpert-generated code, you should always run it from ClassExpert because Resource Workshop and ClassExpert update each other as you make changes to the project. When you start Resource Workshop, it checks the resource code for changes and sends updates immediately to ClassExpert. For example, if you add a button to a dialog box, Resource Workshop tells ClassExpert, which then adds the control to the Events pane. To view the control in ClassExpert, select the control in Resource Workshop, right-click, then choose ClassExpert from the SpeedMenu. Resource Workshop returns you to ClassExpert with the control highlighted in the Events pane.

Running Resource Workshop from the IDEWhen you start Resource Workshop as a viewer for an application (either through the Project Manager in the IDE or through ClassExpert), its behavior differs from running Resource Workshop separately:

• When you make changes in Resource Workshop that affect the class structure or functionality (such as editing menus or dialog boxes), those changes are instantly updated in the window.

• You can’t open another script (no File|Open or File|New).

• If you close the IDE, Resource Workshop is also closed and any changes you made are automatically saved.

• If you close the project file that started Resource Workshop, Resource Workshop is also closed.

• If you build a project while Resource Workshop is open, it creates a .RES file based on the resources loaded. For example, if you edit a dialog box, but haven’t saved it, the .RES file will reflect the unsaved edits.

Page 82: UG

82 U s e r ’ s G u i d e

• You can access the IDE from Resource Workshop using the SpeedMenu (right-click) and choosing ClassExpert.

Using RescanRescan 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 classTo 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 classTo 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.

Page 83: UG

C h a p t e r 5 , M o d i f y i n g a p p l i c a t i o n s w i t h C l a s s E x p e r t 83

Renaming an elementTo 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 classTo 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.

Rebuilding the .APX database fileTo rebuild a lost or damaged database file (the .APX file),

1 Open the project file that contains the AppExpert target and dependent nodes (this is the .IDE file).

2 Right-click the AppExpert target, then choose Special|Rescan from the SpeedMenu. Rescan automatically creates a new database file using markers from the source code for the application.

Page 84: UG

84 U s e r ’ s G u i d e

Page 85: UG

C h a p t e r 6 , B r o w s i n g c l a s s e s a n d o b j e c t s 85

C h a p t e r

6Chapter 6Browsing classes and objects

The IDE contains a browser that lets you view the classes, functions, variables, and constants in your .EXEs and .DLLs. In addition to this, the browser also lets you

• Graphically view the class hierarchies used in your application• View the functions and symbols contained in and inherited by an object• List the global symbols defined in your program• List all references to a variable in your program• View and edit the declaration of a variable

Generating browser informationBefore you can access the browser, you must compile your project with browser reference information. To generate symbolic browser information,

1 Open the project which you want to browse.

2 Choose Options|Project and set the following options in the Project Options dialog box:• Under the Compiler|Debugging topic, check both Debug Information In OBJs

and Browser Reference Information In OBJs.• Under the Linker|General topic, check Include Debug Information.

3 Compile and link the project.

After you compile the project with browser reference information, choose one of the following commands to access the browser:

• Search|Browse Symbol• View|Classes• View|Globals

Page 86: UG

86 U s e r ’ s G u i d e

You can also place your cursor on a symbol in your code and choose Search|Browse Symbol to open the browser.

If you try to browse a class definition (or any symbol that doesn’t have symbolic debug information), you’ll get an error message.

Browsing objects (class overview)Choose View|Classes to see the “big picture,” the object hierarchies in your application, as well as the small details. When you choose View|Classes, the browser draws your objects and shows their ancestor-descendant relationships in a horizontal tree. The red lines in the hierarchy diagram help you see the immediate ancestor-descendant relationships of the currently selected object more clearly. Figure 6.1 shows the class hierarchy from the AppExpert Draw application created in Chapter 4.

Figure 6.1 Viewing classes in an application

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.

Browsing global and local symbolsChoose View|Globals to open a window that lists every global symbol in your application in alphabetical order. The browser also lists the symbols (the functions, variables, and so on) used in a particular object.

Use one of these methods to see the declaration of a particular symbol displayed in a list:

• Double-click the symbol.• Select the symbol and press Enter.• Select the symbol, press Alt+F10 to view the SpeedMenu, then choose Browse Symbol.

The symbol declaration appears in a window, as shown in Figure 6.2.

Page 87: UG

C h a p t e r 6 , B r o w s i n g c l a s s e s a n d o b j e c t s 87

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.

Configuring the browser displayYou can check the Browser options in the Environment Options dialog box to select the type of symbols you want to view, but you must set these options before opening the browser.

When you browse the program global variables, or a particular symbol, the same letters that identify the symbol appear in a Filters matrix at the bottom of the window. You can use filters to select the type of symbols you want to see listed. (See Table 6.1 for a list of letters and their meaning.)

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.

Table 6.1 Filter letters in the browser

Letter Symbol

F FunctionsT TypesV VariablesC Integral constants? DebuggableI Inherited from an ancestorv Virtual method

Page 88: UG

88 U s e r ’ s G u i d e

One or more letters appear to the left of each symbol in the object listing. The letters describe the type of the symbol. Letters that appear after the first letter (which identifies the symbol type) further describe the symbol.

Using regular expressions with global symbolsYou can use regular expressions when you search for global symbols (for example, you can use ?, * and +). To get more information on a particular symbol, either click the symbol or use your cursor keys to select it. A Search input box at the bottom of the window lets you quickly search through the list of global symbols by typing the first few letters of the symbol’s name. As you type, the highlight bar in the list box moves to a symbol that matches the typed characters. You can view the symbol declaration by selecting the symbol and pressing Enter. See Table 6.2 for a list of the regular expression symbols allowed.

Customizing the browserYou can set several browser options using the Environment Options dialog box. Choose Options|Environment, click the Browser topic and select the options you want to use. Single window means you can have only one browser window up at a time; Multiple windows opens a new browser window each time you perform a browsing action (such as choosing View|Globals from the main menu). The browser also has a customizable SpeedBar (see page 16 for more information on customizing SpeedBars).

Table 6.2 Browser search expressions

Character Function

. (a period) Matches one of any character.* Matches zero or more of the previous character. For example:

* is an error because there is no previous character.mo* matches “mo,” “moo,” “mooo,” and so on.bo*x matches “box,” ”boox,” “booox,” and so on.

+ Matches one or more of the previous character. For example:+ is an error.mo+ matches “moo,” “mooo,” and so on.bo+x matches “boox,” “booox,” and so on.

? Matches zero or one of the previous character. For example:? is an error.mo? matches “m” or “mo” only.bo?x matches “bx” or “box” only.

Page 89: UG

C h a p t e r 7 , U s i n g t h e i n t e g r a t e d d e b u g g e r 89

C h a p t e r

7Chapter 7Using the integrated debugger

No matter how careful you are when you write code, a newly-completed program is likely to contain errors, or bugs, that prevent it from running the way you intended it to. Debugging is the process of locating and fixing the errors in your programs.

The Turbo C++ IDE contains an integrated debugger that lets you debug programs from within the IDE. Among other things, the integrated debugger lets you control the execution of your program, inspect the values of variables and items in data structures, modify the values of data items while debugging. You can access the functionality of the integrated debugger through two menus: Debug and View. This chapter introduces you to the functionality of the integrated debugger and gives a brief overview of the debugging process.

Types of bugsThe integrated debugger can help find two basic types of programming errors: run-time errors and logic errors.

Run-time errorsIf 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.

Page 90: UG

90 U s e r ’ s G u i d e

Although you can find run-time errors by searching through your program source code, the integrated debugger can help you quickly track down these types of errors. Using the integrated debugger, you can run to a specific program location. From there, you can begin executing your program one statement at a time, watching the behavior of your program with each step. When you execute the statement that causes your program to fail, you have pinpointed the error. From there, you can fix the source code, recompile the program, and resume testing your program.

Logic errorsLogic 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.

Planning a debugging strategyAfter program design, program development consists of a continuous cycle of program coding and debugging. Only after you thoroughly test your program should you distribute it to your end users. To ensure that you test all aspects of your program, it’s best to have a thorough plan for your debugging cycles.

One good debugging method involves breaking your program down into different sections that you can systematically debug. By closely monitoring the statements in each program section, you can verify that each area is performing as designed. If you do find a programming error, you can correct the problem in your source code, recompile the program, and then resume testing.

Starting a debugging sessionTo start a debugging session,

1 Build your program with debug information.2 Run your program from within the IDE.

When debugging, you have complete control of your program’s execution. You can pause the program at any point to examine the values of program variables and data structures, to view the sequence of function calls, and to modify the values of program variables to see how different values affect the behavior of your program.

Page 91: UG

C h a p t e r 7 , U s i n g t h e i n t e g r a t e d d e b u g g e r 91

Compiling with debug informationBefore 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).

Running your program in the IDEOnce you’ve compiled your program with debug information, you can begin a debugging session by running your program in the IDE. By running your program in the IDE, you have control of when the program runs and when it pauses. Whenever the program is paused in the IDE, the debugger takes control.

When your program is running under the IDE, it behaves as it normally would: your program creates windows, accepts user input, calculates values, and displays output. During the time that your program is not running, the debugger has control, and you can use its features to examine the current state of the program. By viewing the values of variables, the functions on the call stack, and the program output, you can ensure that the area of code you’re examining is performing as it was designed.

As you run your program through the debugger, you can watch the behavior of your application in the windows it creates. For best results during your debugging sessions, arrange your screen so you can see both the IDE Edit window and your application window as you debug. To keep windows from flickering as the focus alternates between the debugger windows and those of your application, arrange the windows so they don’t overlap (tile the windows). With this setup, your program’s execution will be quicker and smoother during the debugging session.

Page 92: UG

92 U s e r ’ s G u i d e

Specifying program argumentsIf the program you want to debug uses command-line arguments, you can specify those arguments in the IDE in the following way:

1 Choose Options|Environment, then select the Debugger topic.

2 In the Run Arguments text box, type the arguments you want to use when you run your program under the control of the integrated debugger.

Controlling program executionThe most important advantage of a debugger is that it lets you control the execution of your program; you can control whether your program will execute a single line of code, an entire function, or an entire program block. By dictating when the program should run and when it should pause, you can quickly move over the sections that you know work correctly and concentrate on the sections that are causing problems.

The integrated debugger lets you control the execution of your program in the following ways:

• Running to the cursor location• Stepping and tracing• Running to a breakpoint• Pausing your program

When running code through the debugger, all program execution is based on lines of source code. The integrated debugger lets you control the rate of debugging to the level of a single line of code. However, the debugger considers multiple program statements on one line of text to be a single line of code; you cannot individually debug multiple statements contained on a single line of text. In addition, the debugger regards a single statement that’s spread over several lines of text as a single line of code.

Running to the cursor locationOften when you start a debugging session, you’ll want to run your program to a spot just before the suspected location of the problem. At that point, use the debugger to ensure that all data values are as they should be. If everything is OK, you can run your program to another location, and again check to ensure that your program is behaving as it should.

To run to a specific program location,

1 In the Edit window, position the cursor on the line of code where you want to begin (or resume) debugging.

2 Run to the cursor location in one of the following ways:• Click the Run To Cursor button on the SpeedBar.• Choose Run To Cursor from the Edit window SpeedMenu.• Press F4.

Page 93: UG

C h a p t e r 7 , U s i n g t h e i n t e g r a t e d d e b u g g e r 93

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.

The execution pointThe execution point marks the next line of source code to be executed by the debugger. Whenever you pause your program execution within the debugger (for example, whenever you run to the cursor or step to a program location), the debugger highlights a line of code, marking the location of the execution point. The execution point always shows the next line of code to be executed, whether you are going to trace, step, or run your program at full speed.

Finding the execution pointWhile debugging, you’re free to open, close, and navigate through any file in an Edit window. Because of this, it’s easy to lose track of the next program statement to execute, or the location of the current program scope. To quickly return to the execution point, choose Debug|Find Execution Point or click the SpeedBar button. Even if you’ve closed the Edit window containing the execution point, Find Execution Point opens an Edit window, and highlights the source code containing the execution point.

Stepping through codeThe Trace Into and Step Over commands offer the simplest way of moving through your program code. While the two commands are very similar, they offer different ways to step through code. When you step, you watch your program execute statements one at a time. After stepping, the program execution pauses and you can use the debugger to investigate the different aspects of your program.

Trace IntoThe 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.

Page 94: UG

94 U s e r ’ s G u i d e

The following example helps explain how single stepping works. Suppose you want to follow the sequence of events through the following two functions contained in a bubble sort program:

void bubble( int *ptr, int n){

int i, j;

for (i=0; i<n-1; i++)for (j=i+1; j<n; j++)

order (ptr+i, ptr+j);}

void order (int *n1, int *n2){

if (*n1 > *n2){

int temp = *n1;*n1 = *n2;*n2 = temp;

}}

If you load the program into the Edit window and place the cursor on the first for statement in the bubble function, pressing F4 runs the program to that location. Choosing Debug|Trace Into executes that line of code, and moves the execution point to the next line of code in the program (the second for statement). Choosing Trace Into again causes the debugger to execute the second for statement, this time placing the execution point on the line containing the call to the function order:

order (ptr+i, ptr+j);

Choosing Trace Into a third time calls the function order, causing the debugger to trace into that function by placing the execution point on the first line of the function definition:

void order (int *n1, int *n2)

From here, successive Trace Into commands execute the lines of code in that function one at a time. When the execution point is located on the last line in the function, stepping (with either the Trace Into or Step Over commands) causes the function to return, which places the execution point on the statement following the function call. In this case, the debugger returns the execution point to the second for statement in bubble.

Step OverThe 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.

Page 95: UG

C h a p t e r 7 , U s i n g t h e i n t e g r a t e d d e b u g g e r 95

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

Debugging member functions and external codeIf you implement classes in your C++ programs, you can still use the integrated debugger to step and trace. The debugger handles member functions the same way it would step over or trace through functions in a program that is not object-oriented.

You can also trace into or step over external code written in any language (including C, C++, and Pascal) as long as the code meets all the requirements for external linking and the linked object file contains full Borland symbolic debugging information.

Running to a breakpointYou 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.

Pausing the programIn addition to stepping over or tracing into code, you can also pause your program while it’s running. Choosing Debug|Pause Program causes the debugger to pause your program inside the window message loop. You can then use the debugger to examine the state of your program with respect to this program location. When you’re done examining the program, continue debugging by running as usual.

If your program assumes control and won’t allow you to return to the debugger (for example, if it runs into an infinite loop), you can press Ctrl+Alt+SysRq to stop your program. You might need to press this command several times before your program actually stops—the command will not work if Windows kernel code is executing.

Terminating the programSometimes while debugging, you’ll find it necessary to restart the program from the beginning. For example, you might need to restart the program if you step past the

Page 96: UG

96 U s e r ’ s G u i d e

location of a bug, or if variables or data structures become corrupted with unwanted values.

Choose Debug |Terminate Program (or press Ctrl+F2) to end the current program run and reset the program. Terminating a program closes all open program files, releases all memory allocated by the program, and clears all variable settings. However, terminating a program does not delete any breakpoints or watches that you might have set. This makes it easy to resume a debugging session.

Using breakpointsYou 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 breakpointsBreakpoints 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.

Setting breakpoints after starting a programWhile your program is running, you can switch to the debugger (just like you would switch to any Windows application) and set a breakpoint. When you return to your application, the new breakpoint will be set, and your application will halt when it reaches the breakpoint.

Page 97: UG

C h a p t e r 7 , U s i n g t h e i n t e g r a t e d d e b u g g e r 97

Invalid breakpointsIf 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.

Working with breakpointsThe Breakpoints window lists all breakpoints by file name and line number, the breakpoint state (verified, unverified, or invalid), and the pass count. The check box to the left of a breakpoint listing indicates whether the breakpoint is enabled (a check mark means enabled).

To open the Breakpoints window, choose View|Breakpoint.

Figure 7.1 The Breakpoints window

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.

Viewing and editing code at a breakpointIf a breakpoint isn’t displayed in the current Edit window, you can use the Breakpoints window to quickly find the breakpoint’s location in your source code. To do so, select the breakpoint in the Breakpoints window, then choose View Source or Edit Source from the SpeedMenu. The Edit window is updated to show the breakpoint’s location. If you choose View Breakpoint, the Breakpoints window remains active so you can modify the breakpoint or go on to view another. If you choose Edit Breakpoint, the Edit window gains focus on the line containing the breakpoint, enabling you to modify the source code at that location.

Disabling and enabling breakpointsDisabling a breakpoint hides the breakpoint from the current program run. When you disable a breakpoint, all the breakpoint settings remain defined, but the breakpoint is hidden from the execution of your program; your program will not stop on a disabled breakpoint. Disabling a breakpoint is useful if you have defined a conditional breakpoint that you don’t need to use now, but might need to use at a later time.

Page 98: UG

98 U s e r ’ s G u i d e

The Breakpoint window contains an Enable check box to the left of each breakpoint listing. When you set a breakpoint, the breakpoint is enabled by default, and the check box is checked. To disable a breakpoint, do one of the following:

• Open the Breakpoint window and uncheck the Enable check box.

• Highlight the breakpoint in the Breakpoint window and choose Disable Breakpoint from the SpeedMenu.

You can also disable all current breakpoints by selecting the Disable All Breakpoints SpeedMenu command. To reenable a breakpoint, recheck the Enable check box, or select it and choose Enable Breakpoint from the SpeedMenu.

Deleting breakpointsWhen 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.

Modifying breakpoint propertiesTo view and modify the properties of a breakpoint, double-click the breakpoint in the Breakpoints window, or select it and choose Edit Breakpoint from the SpeedMenu. The Breakpoint Properties dialog box appears.

Figure 7.2 The Breakpoint Properties dialog box

In addition to examining a breakpoint’s properties, you can use the Breakpoint Properties dialog box to change the location of a breakpoint, set a conditional breakpoint, and specify an expression for a breakpoint to log to the Event Log.

Page 99: UG

C h a p t e r 7 , U s i n g t h e i n t e g r a t e d d e b u g g e r 99

Creating conditional breakpointsWhen 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

Setting Boolean conditionsThe Conditional Expression input box in the Breakpoint Properties dialog box lets you enter an expression that will be evaluated each time the breakpoint is encountered during the program execution. If the expression evaluates to true (or not zero), then the breakpoint will pause the program execution. If the condition evaluates to false (or zero), then the debugger will not stop at the breakpoint location.

Conditional breakpoints are useful when you want to see how your program behaves when a variable falls into a certain range, or what happens when a particular flag gets set. For example, suppose you want a breakpoint to pause on a line of code only when the variable mediumCount is greater than 10. To do so,

1 Set a breakpoint on the desired line of code by moving the text cursor to that line of code in the Edit window and pressing F5.

2 Open the Breakpoints window by choosing View|Breakpoint.

3 Highlight the breakpoint just set and choose Edit Breakpoint from the SpeedMenu. The Breakpoint Properties dialog box opens.

4 Check Enable Conditional Breakpoint, then enter the following expression into the Conditional Expression input box:

mediumCount > 10

5 Click OK to confirm your settings.

Note You can input any valid C or C++ language expression into the Conditional Expression input box; however, all symbols in the expression must be accessible from the breakpoint’s location and the expression cannot contain any function calls. For more on valid debugger expressions, see “Evaluating expressions” on page 103.

Using pass countsThe Pass Count input box lets you specify a particular number of times that a breakpoint must be passed for the breakpoint to activate; pass counts tell the debugger to pause the program execution the nth time that the breakpoint is encountered during the program run (the number n is user-specified, and is set to 1 by default).

The pass count number is decremented each time the line containing the breakpoint is encountered during program execution. If the pass count equals 1 when the breakpoint

Page 100: UG

100 U s e r ’ s G u i d e

line is encountered, the breakpoint activates and pauses the program execution on that line of code.

Pass counts are useful, for example, when you think that a loop is failing on the nth iteration. Or, if you can’t tell on which iteration the loop fails, you can set the pass count to the maximum loop count and run your program. When the program fails, you can calculate the number of times that the program went through the loop by examining the number in the pass count field.

When pass counts are used in conjunction with Boolean conditions, the breakpoint will pause the program’s execution the nth time that the condition is true; the condition must be true for the pass count to be decremented.

Logging expressionsYou 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.

Customizing the breakpoint and execution point colorsYou can customize the colors used to indicate the execution point and the enabled, disabled, and invalid breakpoint lines:

1 Choose Options|Environment.

2 Choose Syntax Highlighting|Customize Syntax Highlighting.

3 From the Element list, select Execution Point, Enabled Break, Disabled Break, or Invalid Break, then set the background and foreground to the colors you want. For more about syntax highlighting, see “Syntax highlighting” on page 15.

Examining program data valuesEven though you can discover many interesting things about your program by running and stepping through it, you’ll usually need to examine the values of program variables to uncover bugs. For example, it’s helpful to know the value of the index variable as you step though a for loop, or the values of the parameters passed to a function call.

The integrated debugger has the following tools to help you examine the data values in your program:

Page 101: UG

C h a p t e r 7 , U s i n g t h e i n t e g r a t e d d e b u g g e r 101

• The Watch window• The Expression Evaluator dialog box• The Inspect Expression window• The Call Stack window• The Register window

Data evaluation operates at the level of expressions. An expression consists of constants, variables, and values contained in data structures combined with language operators. In fact, almost anything you can use as the right side of an assignment operator can be used as a debugging expression, with the exception of function calls.

Watching expressionsYou 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

Page 102: UG

102 U s e r ’ s G u i d e

2 In the Expression text box, enter the expression you want to watch (or choose a previously entered expression from the drop-down list).

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.

Formatting watch expressionsYou can format the display of a watch expression using the Watch Properties dialog box. By default, the debugger displays integer values in decimal form. However, by checking the Hexadecimal button in the Watch Properties dialog box, you can specify that an integer watch be displayed as hexadecimal. You can also vary the display of the watches using the Display As buttons in the Watch Properties dialog box. For more on these buttons, refer to the online Help.

To format a floating-point expression, click the Floating Point button, then indicate the number of significant digits you want displayed in the Watch window by typing this number in the Significant Digits text box.

If you’re setting up a watch on an element in a data structure (such as an array), you can display the values of consecutive data elements. For example, suppose you have an array of five integers named xarray. Type the number 5 in the Repeat Count text box of the Watch Properties dialog box to see all five values of the array. However, to use a repeat count, the watch expression must represent a single data element.

You can also format watch expressions using the expression format specifiers shown in Table 7.1 on page 104. Format specifier settings override any settings specified in the Watch Properties dialog box. Format specifiers use the following syntax:

expression [,format_specifier]

Disabling a watchIf 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.

Figure 7.4 The Watch Properties dialog box

Page 103: UG

C h a p t e r 7 , U s i n g t h e i n t e g r a t e d d e b u g g e r 103

In the Watch window, the Enable check box lies to the left of each watch listing. When you set a watch, the debugger enables the watch by checking this box. To disable a watch, do one of the following:

• Open the Watch window and uncheck the Enable check box.

• Highlight the watch in the Watch window and choose Disable Watch from the SpeedMenu.

You can also disable all current watches by selecting the Disable All Watches SpeedMenu command. To reenable a watch, recheck its Enable check box, or select it and choose Enable Watch from the SpeedMenu.

Deleting a watchTo 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 and modifying expressionsYou can evaluate expressions using the Expression Evaluator dialog box. The Expression Evaluator dialog box has the advantage that it lets you change the values of variables and items in data structures during the course of your debugging session. This can be useful if you think you’ve found the solution to a bug, and you want to try it out before exiting the debugger, changing the source code, and recompiling the program.

Evaluating expressionsChoose 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

Page 104: UG

104 U s e r ’ s G u i d e

• Function calls• Symbols or macros defined with #define

When you evaluate an expression, the current value of the expression is displayed in the Result field of the dialog box. If you need to, you can format the result by adding a comma and one or more format specifiers to the end of the expression entered in the Expression text box. Table 7.1 details the legal format specifiers.

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

Modifying the values of variablesOnce you’ve evaluated a variable or data structure item, you can modify its value. Modifying the value of data items during a debugging session lets you test different bug hypotheses and see how a section of code behaves under different circumstances.

Table 7.1 Expression format specifiers

Character Types affected Function

H or X Integers Hexadecimal. Shows integer values in hexadecimal with the 0x prefix, including those in data structures.

C Char, strings Character. Shows special display characters for ASCII 0–31. By default, such characters are shown using the appropriate C escape sequences (/n, /t, and so on).

D Integers Decimal. Shows integer values in decimal form, including those in data structures.

Fn Floating point Floating point. Shows n significant digits (where n is in the range of 2–18, and 7 is the default).

nM All Memory dump. Shows n bytes starting at the address of the indicated expression. If n is not specified, it defaults to the size in bytes of the type of the variable.By default, each byte shows as two hex digits. The C, D, H, S, and X specifiers can be used with M to change the byte formatting.

P Pointers Pointer. Shows pointers as seg:ofs instead of the default Ptr(seg:ofs). It tells you the region of memory in which the segment is located, and the name of the variable at the offset address, if appropriate.

R Structures, unions Structure/Union. Shows both field names and values such as (X:1;Y:10;Z:5) instead of (1,10,5).

S Char, strings String. Shows ASCII 0–31 as C escape sequences. Use only to modify memory dumps (see nM above).

Page 105: UG

C h a p t e r 7 , U s i n g t h e i n t e g r a t e d d e b u g g e r 105

To modify the value of a data item,

1 Open the Expression Evaluator dialog box and enter the name of the variable you want to modify into the Expression input box.

2 Click Evaluate to evaluate the data item.

3 Type a value into the New Value text box (or choose a value from the drop down list), then click Modify to update the data item.

Note When you modify the value of a data item through the debugger, the modification is effective for that specific program run only; the changes you make through the Expression Evaluator dialog box do not affect your program source code or the compiled program. To make your change permanent, you must modify your program source code in the Edit window, then recompile your program.

Keep these points in mind when you modify program data values:

• You can change individual variables or elements of arrays and data structures, but you cannot change the entire contents of an array or data structure.

• The expression in the New Value text box must evaluate to a result that is assignment-compatible with the variable you want to assign it to. A good guideline is that if the assignment would cause a compile-time or run-time error, it’s not a legal modification value.

Warning! Modifying values (especially pointer values and array indexes), can have undesirable effects because you can overwrite other variables and data structures. Use caution whenever you modify program values from the debugger.

Inspecting data elementsInspect windows also let you examine and modify data values. Inspect windows are extremely useful because they format the data according to the type of data being viewed; there are different types of Inspect windows for scalars, arrays, structures, functions, and classes with and without member functions.

The easiest way to inspect a data item is to highlight the expression you want to inspect (or just position the text cursor on the token) in the Edit window, and choose Inspect Object from the SpeedMenu (or press Alt+F5). If you inspect expressions using this method, the expression is always evaluated within the scope of the line on which the expression appears.

You can also inspect data expressions using the following method,

1 Choose Debug|Inspect to display the Inspect Expression window.

2 Type in the expression you want to inspect, or choose a previously entered expression from the drop down list.

3 Choose OK to display an Inspector window.

If the execution point is in the scope of the expression you’re inspecting, the value appears in the Inspect window. If the execution point is outside the scope of the

Page 106: UG

106 U s e r ’ s G u i d e

expression, the value is undefined. Figure 7.6 shows two Inspect windows; the one on the left displays a structure Inspect window, the one on the right shows an array.

Figure 7.6 Inspect windows

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.

Examining register valuesWhile debugging, you can display the values of the CPU registers, and the settings of the status flags. To view the Register window, choose View|Register.

Table 7.2 CPU flags in the Register window

Letter in pane Flag name

c Carryz Zeros Signo Overflowp Paritya Auxiliary carryi Interrupt enabled Direction

Page 107: UG

C h a p t e r 7 , U s i n g t h e i n t e g r a t e d d e b u g g e r 107

The Register window SpeedMenu lets you select the format in which to display the values in the registers; choose from Hexadecimal or Decimal. You can also choose to view the 16-bit (word) or 32-bit (double word) registers.

Viewing function callsWhile debugging, it can be useful to know the order of function calls that brought you to your current program location. Using the Call Stack window, you can view the current sequence of function calls. The Call Stack window is also helpful when you want to view the arguments passed to a function call; each function listing in the window is followed by a listing that details the arguments with which the call was made. Use View|Call Stack to display the Call Stack window.

Figure 7.7 Call Stack 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).

Navigating to function callsUsing the Call Stack window, you can view or edit the source code located at a particular function call. Right-clicking a function in the Call Stack window displays the SpeedMenu, from where you can choose either View Source or Edit Source. Each of these commands cause the Edit window to display the selected function; however, Edit Source gives focus to the Edit window so you can modify the source code at that function location. If you select the top function in the Call Stack window, these

Page 108: UG

108 U s e r ’ s G u i d e

commands cause the Edit window to display the location of the execution point in the current function. Selecting any other function call causes the debugger to display the actual function call in the Edit window.

Locating functionsYou 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.

Catching general protection faultsIf a general protection exception (GP exception) occurs while you’re running a program in the IDE, your program halts and the General Protection Exception dialog box appears. If you choose OK to close the dialog box, the debugger displays the code that’s responsible for the GP exception in the Edit window, and the execution point marks the exception.

At this point, you must choose Debug|Terminate Program to prevent your program from crashing. Then you can correct the error that caused the problem before you run your program again.

Sending messages to the Event Log windowIn addition to using the Event Log window to log breakpoint expressions (as described on page 100), you can also log window messages and output messages to the Event Log window. To select the events you want to log,

1 Open the Event Log window by choosing View|Event Log.

2 Choose Set Options on the Event Log window SpeedMenu.

3 Select the Debugger topic, then select the Event Capture options you want:• Window Messages• Output Messages (on by default)• Breakpoints (on by default)

The Event Log window has the following SpeedMenu commands:

Clear Events clears the Event Log window.

Save Events To File displays a dialog box so you can specify a file name. All events that are currently in the Event Log window are saved in that file.

Add Comment prompts you for a line of text that is inserted in the Event Log window as a comment.

Set Options opens the Environment Options dialog box, so you can select Debugger options and set the Event Capture options you want.

Page 109: UG

C h a p t e r 7 , U s i n g t h e i n t e g r a t e d d e b u g g e r 109

Debugging dynamic-link librariesWhen you trace into a DLL used by your application, the debugger automatically loads the symbol table for the DLL. (The DLL must have been compiled with Borland symbolic debug information for you to be able to trace into it.) Because the debugger can load only one symbol table into memory at a time, the debugger unloads the symbol table for the .EXE file when it loads the DLL symbol table. Because of this, you won’t be able to monitor the values of data items in your .EXE file while you’re tracing through the DLL code.

For example, if your executable file MYAPP.EXE uses a function in the file MYDLL.DLL, you can trace into the DLL (if it has debug information) when the DLL function is called. When you step into MYDLL.DLL, its symbol table is loaded by the debugger, and the MYAPP.EXE symbol table is unloaded.

To see which symbol table the debugger is using, choose Debug|Load Symbol Table. The Load Symbol Table dialog box opens, displaying the currently loaded symbol table at the top of the dialog box. Below this is a listing of the other symbol tables available to the debugger.

You can switch between symbol tables to inspect data items that are defined in another module. For example, if you’re stepping in MYDLL.DLL and want to examine the value of a variable that’s defined in MYAPP.EXE, you can do so by loading the MYAPP.EXE symbol table:

1 Choose Debug|Load Symbol Table.2 Choose the symbol table you want to load from the Available Tables list.3 Examine the data items in MYAPP.EXE.

When you’ve finished examining the variables in MYAPP.EXE, you must reload the symbol table for MYDLL.DLL before you can continue stepping in that module.

Debugging in soft and hard modeThe Windows operating system is continually processing and generating window messages. In addition, any program that runs under Windows (such as Turbo C++ for Windows) must send and process window messages. Even actions such as resizing a window, opening a dialog box, or moving the mouse cursor causes your program to generate and process window messages.

Although the generation and handling of window messages is not normally a problem, the debugger must take special care of the messages sent to and generated by the program you’re debugging. The integrated debugger handles the messages sent and received by your program, which frees you to debug your program and use the full functionality of the Windows environment. When the debugger works simultaneously with other Windows programs, the debugger is said to be working in soft mode.

However, during a debugging session, you might need to stop all other Windows programs from executing. When all other Windows programs are halted, the debugger is said to be working in hard mode. When the debugger is in hard mode, you won’t be able to use the functionality of the Windows environment. For example, you won’t be

Page 110: UG

110 U s e r ’ s G u i d e

able to switch to another task or do anything outside the functionality of the debugger and the program you’re debugging—the debugger behaves as if it’s the only program in memory. This is similar to running a program under the DOS environment.

The integrated debugger offers two different debugging modes: smart mode and hard mode. Normally, you’ll use smart mode (checked by default) while debugging programs. When Smart is selected, the debugger chooses hard or soft mode, depending on what is happening in the Windows environment. However, you’ll want to specify hard mode if your program sends intertask messages (such as DDE messages) or if you’re debugging at a very low level. To change debugging modes,

1 Choose Options|Environment to open the Environment Options dialog box and select the Debugger topic.

2 Select either Hard Mode On All Stops or Smart, depending on your needs.

Page 111: UG

C h a p t e r 8 , W i n S i g h t a n d W i n S p e c t o r 111

C h a p t e r

8Chapter 8WinSight and WinSpector

This chapter describes the two utilities WinSight and WinSpector. WinSight is a tool that lets you monitor the windows and window messages of the programs currently running under Windows. WinSpector is a tool that helps you perform postmortem debugging (debugging after your program has ungracefully terminated) of Unrecoverable Application Errors and General Protection Faults.

These utilities can be launched from the Turbo C++ program group using the following two icons:

WinSightWinSight 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

Page 112: UG

112 U s e r ’ s G u i d e

currently active on the desktop. WinSight saves your configuration, so if you open all three views and exit WinSight, the next time you start it, all three views will display.

WinSight has three views: Class List, Window Tree, and Message Trace. You can display these views from left to right or top to bottom by choosing View|Split Horizontal or View|Split Vertical.

You can control the messages traced by WinSight (see page 115) and you can control when messages start and stop tracing as described in the following sections.

Starting and stopping screen updatesTo turn on tracing, choose Start! from the menu (Start! then becomes Stop! on the menu). Normally, all three views are kept current as classes are registered, windows are created and destroyed, and messages are received. However, you can use Messages|Trace Off to suspend tracing of messages only (Class List and Window Tree will continue to update).

Use Stop! and Start! to

• Study a particular situation.• Control (minimize) the machine time WinSight uses when it updates itself constantly.

Turning off message tracingTo turn off tracing of message types, choose Messages|Trace Off. The Message Trace view remains visible, and tracing resumes when you choose Messages|Selected Classes, Selected Windows, or All Windows (provided tracing is on).

The following sections describe how to use the three views to get the information you need to debug an application. Choose Spy|Exit to leave WinSight.

Choosing a viewWinSight 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.

Page 113: UG

C h a p t e r 8 , W i n S i g h t a n d W i n S p e c t o r 113

The Detail window displays the class name, executable module, and other information about the class or window.

Class List viewA class is the name with which the window class was registered with Windows. Sometimes, instead of choosing specific windows to trace, you might want to look at messages for entire classes of windows. WinSight lets you do this with the Class List view.

Using the Class List viewThe Class List view shows all the currently registered window classes. To get details about a class, double-click it or select it and press Enter.

The diamonds next to the classes turn black momentarily whenever the window receives any messages. This gives you an overview of which windows are currently receiving messages. If a hidden child window receives a message, the diamond for the parent changes color. Use the following format:

Class (Module) Function Styles

Class is the name of the class. Some predefined Windows classes have numeric names. For example, the Popup menu class uses the number 32768 as its name. These predefined classes are shown with both the number and a name, such as #32768:PopupMenu. The actual class name is only the number (using the MAKEINTRESOURCE format, which is also used for resource IDs).

Module is the name of the executable module (.EXE or .DLL) that registered the class.

Function is the address of the class window function.

Styles is a list of the cs_ styles for the class. The names are the same as the cs_ definitions in WinTypes, except the cs_ is removed and the name is in mixed case (uppercase and lowercase).

Spying on classesTo 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.

Page 114: UG

114 U s e r ’ s G u i d e

Window Tree viewThe Window Tree view displays a hierarchical outline of all existing windows on the desktop. This display lets you

• Determine what windows are present on the desktop.• View the status of windows, including hidden windows.• See which windows are receiving messages.• Select windows for message tracing.

The lines on the left of the Window Tree view show the tree structure. Each window is connected to its parent, siblings, and children with these lines. When a window receives a message, the diamond next to it (or its parent window if the tree is collapsed) turns black.

The diamond next to each window shows whether the window has any children. If the diamond is blank, the window has no children. If the diamond contains a +, the window has children that are not displayed. To show the next level of children, click the diamond next to the window. To show all the levels of child windows (children of children, and so on), right-click the diamond. If the diamond contains a –, the children are displayed. To hide all of a window’s child windows, click the diamond next to the window.

The format of the window details is as follows:

Handle {Class} Module (Position) "Title"

Handle is the window handle as returned by CreateWindow.

Class is the window class name, as described in the Class List view.

Module is the name of the executable module (.EXE or .DLL) that created the window. Module is the name of the module owning the data segment passed as the hInstance parameter to CreateWindow.

Position is “hidden” if the window is hidden. If the window is visible, Position is indicated by using screen coordinates (for parent windows) or coordinates in the parent’s client area (for child windows). Position uses the following format:

xBegin,yBegin - xEnd,yEnd

Title is the window title or text, as returned by GetWindowText or a wm_GETTEXT message. If the title is the null string, the quotation marks are omitted.

Finding a windowWinSight 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.

Page 115: UG

C h a p t e r 8 , W i n S i g h t a n d W i n S p e c t o r 115

Alternatively, once in Find Window mode, you can select windows in the Window Tree with the mouse or cursor keys, and WinSight will put a thick border around the selected window or windows. If you press Enter, you will see the Window Detail window for the selected window.

Leaving Find Window modeOnce you have located the window you want, you can leave Find Window mode by clicking the mouse button or by pressing the Esc key. This removes the border from the screen, leaving the current window’s description selected in the Window Tree view.

Spying on windowsTo 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.

Choosing messages to traceMessage Trace displays messages received by selected window classes or windows. Messages received via SendMessage are shown twice, once when they are sent and again when they return to show the return value. Dispatched messages are shown once only, since their return value is meaningless. The message display is indented to show how messages are nested within other messages.

Using the Message Trace viewBy default, WinSight traces all messages and displays them in the Message Trace view. WinSight gives you several ways to narrow down the tracing of messages:

• Choose Messages|Selected Classes or Messages|Selected Windows, then select the classes (in the Class List view) or windows (in the Window Tree view) by using the mouse and Shift or Ctrl.

• Choose Message|All Windows.

• Choose Message|Options, then select any or all of fourteen groups of messages. Check All Messages in the Options dialog box to return to tracing all messages.

Page 116: UG

116 U s e r ’ s G u i d e

Other tracing optionsThe Message Trace Options dialog box lets you change the format of the messages in Message Trace. It also lets you trace messages to a file, printer, or an auxiliary monitor or window.

• Normally, the Message Trace view interprets each message’s parameters and displays them in a readable format (Interpret Values is checked). Check Hex Values to view message parameters as hex values of wParam and lParam.

• Information on traced messages usually displays in the Message Trace view. However, you can send messages to a file, printer, or auxiliary monitor by checking Log File in the Message Trace Options dialog box and doing one of the following: • Type a file name to trace to a log file. If the file already exists, messages are

appended to the file.• Type the name of the device (for example, type PRN) for the log file to send output

to the printer port.• Type AUX to output trace messages to an auxiliary monitor or window. To do

this, you must have WINOX.SYS or OX.SYS installed as a device in your CONFIG.SYS file. To stop logging message traces to a file, printer, or auxiliary monitor, uncheck Log File. Use the following format:

Handle ["Title" or {Class}] Message Status

Handle is the window handle receiving the message.

Title is the window’s title. If the title is the null string, the class name is displayed instead, in curly braces.

Message is the message name as defined by Windows. They are displayed in WinSight in all uppercase letters. Known undocumented Windows messages are shown in lowercase. Unknown message numbers (user-defined) are shown as wm_User+0xXXXX if they are greater-than or equal to wm_User or as wm_0xXXXX if they are less than wm_User. Registered message numbers (from RegisterWindowsMessage) are shown with their registered name in single quotes.

Status is one or more of the following:

• Dispatched indicates the message was received via DispatchMessage.

• Sent [from XXXX] indicates the message was received via SendMessage. If it was sent from another window, from XXXX gives that window’s handle. If it was sent from the same window receiving it, this is shown with from self. If it was sent from Windows itself, the “from” phrase is omitted.

• Returns indicates the message was received via SendMessage and is now returning.

• Additional messages might include a numeric return value or text message such as wm_GetText. For sent and dispatched messages, WinSight interprets the parameters and gives a readable display. For messages that have associated data structures (wm_Create, for example) it takes those structures and includes them in the display.

Page 117: UG

C h a p t e r 8 , W i n S i g h t a n d W i n S p e c t o r 117

Table 8.1 Mouse messages

WM_HSCROLL WM_MBUTTONUP WM_RBUTTONDOWNWM_LBUTTONDBLCLK WM_MOUSEACTIVATE WM_RBUTTONUPWM_LBUTTONDOWN WM_MOUSEFIRST WM_SETCURSORWM_LBUTTONUP WM_MOUSELAST WM_VSCROLLWM_MBUTTONDBLCLK WM_MOUSEMOVEWM_MBUTTONDOWN WM_RBUTTONDBLCLK

Table 8.2 Window messages

WM_ACTIVATE WM_GETDLGCODE WM_QUERYNEWPALETTEWM_ACTIVATEAPP WM_GETFONT WM_QUERYOPENWM_CANCELMODE WM_GETMINMAXINFO WM_QUITWM_CHILDACTIVATE WM_GETTEXT WM_SETFOCUSWM_CLOSE WM_GETTEXTLENGTH WM_SETFONTWM_CREATE WM_ICONERASEBKGND WM_SETREDRAWWM_CTLCOLOR WM_KILLFOCUS WM_SETTEXTWM_DDE_FIRST WM_MOVE WM_SHOWWINDOWWM_DESTROY WM_PAINT WM_SIZEWM_ENABLE wm_painticon WM_WINDOWPOSCHANGEDWM_ENDSESSION WM_QUERYDRAGICON WM_WINDOWPOSCHANGINGWM_ERASEBKGND WM_QUERYENDSESSION

Table 8.3 Input messages

WM_CHAR WM_KEYUP WM_SYSKEYDOWNWM_CHARTOITEM WM_MENUCHAR WM_SYSKEYUPWM_COMMAND WM_MENUSELECT WM_TIMERWM_DEADCHAR WM_PARENTNOTIFY WM_VKEYTOITEMWM_KEYDOWN WM_SYSCHAR wm_yomicharWM_KEYLAST WM_SYSDEADCHAR

Table 8.4 System messages

WM_COMPACTING WM_PALETTECHANGED WM_SYSCOLORCHANGEWM_DEVMODECHANGE WM_PALETTEISCHANGING WM_SYSCOMMANDWM_ENTERIDLE WM_POWER WM_TIMECHANGEWM_FONTCHANGE WM_QUEUESYNCH WM_WININICHANGEwm_null WM_SPOOLERSTATUS

Page 118: UG

118 U s e r ’ s G u i d e

Table 8.5 Pen messages

WIN_USER WM_HOOKRCRESULT WM_RCRESULTWM_GLOBALRCCHANGE WM_PENWINFIRST WM_SKBWM_HEDITCTL WM_PENWINLAST

Table 8.6 Initialization messages

WM_INITDIALOG WM_INITMENU WM_INITMENUPOPUP

Table 8.7 Clipboard messages

WM_ASKCBFORMATNAME WM_DESTROYCLIPBOARD WM_RENDERALLFORMATSWM_CHANGECBCHAIN WM_DRAWCLIPBOARD WM_RENDERFORMATWM_CLEAR WM_HSCROLLCLIPBOARD WM_SIZECLIPBOARDWM_COPY WM_PAINTCLIPBOARD WM_UNDOWM_CUT WM_PASTE WM_VSCROLLCLIPBOARD

Table 8.8 DDE messages

WM_DDE_ACK WM_DDE_EXECUTE WM_DDE_REQUESTWM_DDE_ADVISE WM_DDE_INITIATE WM_DDE_TERMINATEWM_DDE_DATA WM_DDE_POKE WM_DDE_UNADVISE

Table 8.9 Nonclient messages

WM_NCACTIVATE WM_NCLBUTTONDOWN WM_NCPAINTWM_NCCALCSIZE WM_NCLBUTTONUP WM_NCRBUTTONDBLCLKWM_NCCREATE WM_NCMBUTTONDBLCLK WM_NCRBUTTONDOWNWM_NCDESTROY WM_NCMBUTTONDOWN WM_NCRBUTTONUPWM_NCHITTEST WM_NCMBUTTONUPWM_NCLBUTTONDBLCLK WM_NCMOUSEMOVE

Table 8.10 Control messages

BM_GETCHECK CBN_SELCHANGE EN_VSCROLLBM_GETSTATE CBN_SELENDCANCEL LB_ADDSTRINGBM_SETCHECK CBN_SETFOCUS LB_DELETESTRINGBM_SETSTATE DM_GETDEFID LB_DIRBM_SETSTYLE DM_SETDEFID LB_FINDSTRING

Page 119: UG

C h a p t e r 8 , W i n S i g h t a n d W i n S p e c t o r 119

BN_CLICKED EM_CANUNDO LB_FINDSTRINGEXACTBN_DISABLE EM_EMPTYUNDOBUFFER LB_GETCARETINDEXBN_DOUBLECLICKED EM_FMTLINES LB_GETCOUNTBN_HILITE EM_GETFIRSTVISIBLELINE LB_GETCURSELBN_PAINT EM_GETHANDLE LB_GETHORIZONTALEXTENTBN_UNHILITE EM_GETLINE LB_GETITEMDATACB_ADDSTRING EM_GETLINECOUNT LB_GETITEMHEIGHTCB_DELETESTRING EM_GETMODIFY LB_GETITEMRECTCB_DIR EM_GETPASSWORDCHAR LB_GETSELCB_FINDSTRING EM_GETRECT LB_GETSELCOUNTCB_FINDSTRINGEXACT EM_GETSEL LB_GETSELITEMSCB_GETCOUNT em_getthumb LB_GETTEXTCB_GETCURSEL EM_GETWORDBREAKPROC LB_GETTEXTLENCB_GETDROPPEDCONTROLRECT EM_LIMITTEXT LB_GETTOPINDEXCB_GETDROPPEDSTATE EM_LINEFROMCHAR LB_INSERTSTRINGCB_GETEDITSEL EM_LINEINDEX LB_MSGMAXCB_GETEXTENDEDUI EM_LINELENGTH LB_RESETCONTENTCB_GETITEMDATA EM_LINESCROLL LB_SELECTSTRINGCB_GETITEMHEIGHT EM_MSGMAX LB_SELITEMRANGECB_GETLBTEXT EM_REPLACESEL LB_SETCARETINDEXCB_GETLBTEXTLEN em_scroll LB_SETCOLUMNWIDTHCB_INSERTSTRING EM_SETFONT LB_SETCURSELCB_LIMITTEXT EM_SETHANDLE LB_SETHORIZONTALEXTENTCB_MSGMAX EM_SETMODIFY LB_SETITEMDATACB_RESETCONTENT EM_SETPASSWORDCHAR LB_SETITEMHEIGHTCB_SELECTSTRING EM_SETRECT LB_SETSELCB_SETCURSEL EM_SETRECTNP LB_SETTABSTOPSCB_SETEDITSEL EM_SETSEL LB_SETTOPINDEXCB_SETITEMDATA EM_SETTABSTOPS LBN_DBLCLKCB_SETITEMHEIGHT EM_SETWORDBREAK LBN_ERRSPACECB_SHOWDROPDOWN EM_UNDO LBN_KILLFOCUSCBN_CLOSEUP EN_CHANGE LBN_SELCANCELCBN_DBLCLK EN_ERRSPACE LBN_SELCHANGECBN_DROPDOWN EN_HSCROLL LBN_SETFOCUSCBN_EDITCHANGE EN_KILLFOCUS STM_GETICONCBN_EDITUPDATE EN_MAXTEXT STM_SETICONCBN_ERRSPACE EN_SETFOCUSCBN_KILLFOCUS EN_UPDATE

Table 8.10 Control messages (continued)

Page 120: UG

120 U s e r ’ s G u i d e

WinSpectorWinSpector 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

Table 8.11 Multimedia messages

MM_ADLIB MM_MIM_CLOSE MM_SNDBLST_MIDIINMM_JOY1BUTTONDOWN MM_MIM_DATA MM_SNDBLST_MIDIOUTMM_JOY1BUTTONUP MM_MIM_ERROR MM_SNDBLST_SYNTHMM_JOY1MOVE MM_MIM_LONGDATA MM_SNDBLST_WAVEINMM_JOY1ZMOVE MM_MIM_LONGERROR MM_SNDBLST_WAVEOUTMM_JOY2BUTTONDOWN MM_MIM_OPEN MM_WAVE_MAPPERMM_JOY2BUTTONUP MM_MOM_CLOSE MM_WIM_CLOSEMM_JOY2MOVE MM_MOM_DONE MM_WIM_DATAMM_JOY2ZMOVE MM_MOM_OPEN MM_WIM_OPENMM_MCINOTIFY MM_MPU401_MIDIIN MM_WOM_CLOSEMM_MICROSOFT MM_MPU401_MIDIOUT MM_WOM_DONEMM_MIDI_MAPPER MM_PC_JOYSTICK MM_WOM_OPEN

Table 8.12 Other messages and messages not documented by Microsoft

wm_alttabactive wm_entersizemove WM_MDIRESTOREwm_begindrag wm_exitmenuloop WM_MDISETMENUWM_COALESCE_FIRST wm_exitsizemove WM_MDITILEWM_COALESCE_LAST wm_filesyschange WM_MEASUREITEMWM_COMMNOTIFY wm_gethotkey WM_NEXTDLGCTLWM_COMPAREITEM wm_isactiveicon wm_nextmenuwm_convertrequest WM_KEYFIRST wm_querydropobjectwm_convertresult wm_lbtrackpoint wm_queryparkiconWM_DELETEITEM WM_MDIACTIVATE wm_sethotkeywm_dragloop WM_MDICASCADE wm_setvisiblewm_dragmove WM_MDICREATE wm_sizewaitwm_dragselect WM_MDIDESTROY wm_syncpaintWM_DRAWITEM WM_MDIGETACTIVE wm_synctaskWM_DROPFILES WM_MDIICONARRANGE WM_SYSTEMERRORwm_dropobject WM_MDIMAXIMIZE wm_systimerwm_entermenuloop WM_MDINEXT wm_testing

Page 121: UG

C h a p t e r 8 , W i n S i g h t a n d W i n S p e c t o r 121

• CPU registers• A disassembly of the machine instructions where the exception occurred• Windows information about the program environment

Before using WinSpector, be sure that TOOLHELP.DLL (from Windows 3.1 or later) is in your search path (TOOLHELP.DLL ships with Windows). TOOLHELP.DLL is a Windows DLL that lets utilities access low-level system information. WinSpector uses TOOLHELP.DLL to log exceptions and to obtain the system information it writes to the log file. Don’t use other exception debugging tools, except for Turbo Debugger, while running with WinSpector.

There are three ways to start WinSpector (it loads minimized):

• Include it in the “load=” section of your WIN.INI file.• Include it in the Startup folder in Windows.• Double-click the WinSpector icon to run WinSpector after you load Windows.

When an exception (UAE or GPF) occurs, WinSpector creates a report in a file called WINSPCTR.LOG (a text file) with information to help you determine what caused the error. WinSpector also creates a file called WINSPCTR.BIN, a binary file that the DFA utility translates into a text file called DFA.OUT (see page 126 for more information on DFA.EXE).

After the exception, WinSpector displays a dialog box with a brief exception report. Click OK to remove the box and read the log file to find the cause of the exception. You can control the output to WINSPCTR.LOG as described in the following section.

Configuring WINSPCTR.LOGThere 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.

Page 122: UG

122 U s e r ’ s G u i d e

ShowSystemInfo= 0 (omit) or 1 (show): Check System Information to add the Task List, the Module List, and information about the USER and GDI heaps to the log file.

LogToStdAux=0 (on) or 1 (off): Check AUX Summary to view an abbreviated form of the information sent to the log file on the AUX device. To use this option, you need a terminal connected to AUX or a device driver, such as OX.SYS, that redirects the AUX device to a second monitor.

PostMortemDump= 1 (show) or 0 (omit): Check PostMortem Dump to generate a WINSPCTR.BIN file. Use DFA.EXE to translate the BIN file into a text file you can read.

ShowStackInfo= 1 (show) or 0 (omit): Check Stack Frame Data to add a verbose stack trace display to the log file. For each stack frame that doesn’t exceed 256 bytes, WinSpector performs a hex dump, starting at the SS:BP for that frame. If there are more than 256 bytes between two successive stack frames, the memory display is omitted for that frame. You can use this data to get the values of the parameters that were passed to the function.

It’s usually easier to let DFA do the hard work of figuring out what your parameters are. However, for those cases where Turbo Debugger information is not available, you might find that a verbose trace supplies helpful information.

ShowUserInfo= 1 (show) or 0 (omit): Check User Comments if you want to add information to the log file about what was happening when the exception occurred. With User Comments checked, WinSpector displays a dialog box immediately after the exception. The comments you type are appended to the log file.

WINSPCTR.LOG referenceEach 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)

Table 8.13 Exception types

Number Name Description

0 Division by zero Occurs during a DIV or an IDIV interaction if the divisor is 0.

Page 123: UG

C h a p t e r 8 , W i n S i g h t a n d W i n S p e c t o r 123

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 sectionThe 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],FF079F:042D JNE 043A079F:042F CMP WORD PTR [BP+06],03079F:0435 MOV DI, 0001

12 Stack fault Usually occurs when there is not enough room on the stack to proceed.13 General protection

fault (GPF)All protection errors that don’t cause another exception cause an exception 13.

Table 8.13 Exception types (continued)

Number Name Description

Page 124: UG

124 U s e r ’ s G u i d e

Stack Trace sectionThe first line of the Stack Trace section in WINSPCTR.LOG identifies the function or procedure that was executing at the time of the exception. Stack Trace information includes the

• Frame number.

• Module name.

• Name of the closest function before the address of the one that caused the exception, plus a number indicating how far away you were from that function. (This information is present only if a .SYM file is present.)

• Logical and physical address for the stack frame.

• Location where your program returns after the call.

When WinSpector lists function names, it looks in the .SYM file for the closest symbol name that appears before the address in the call stack. Since some .SYM files do not contain information for all functions, the function name in the log file is the closest function in the .SYM file with an address preceding the frame address. If the offset field appears to be too high, function names might not be reliable.

The following stack trace information shows some of the functions that were executing at the time BAD, a sample task, caused an exception:

Stack Trace:0 User <no info>

CS:IP 002A:0429 (079F:0429) SS:BP 10FF:18CAC:WIN31SYSTEMUSER.EXE

3 BAD function5(unsigned long, unsigned long, unsigned long) + 0014CS:IP 0001:0184 (1107:0184) SS:BP 10FF:1952C:BINBAD.EXE

Register sectionThe Register section in WINSPCTR.LOG lists the values stored in the standard registers when the exception occurred, as the following example shows:

Registers:AX 0037BX 0000CX 0008DX 10EESI 0037DI 0028

Limits and access rights are given for the CS, DS, ES, and SS registers.

Message Queue sectionThe Message Queue section in WINSPCTR.LOG gives the last message received in the middle of processing. This section also lists any messages that were waiting in the queue at the time of exception. For each message, WinSpector lists the following information:

Page 125: UG

C h a p t e r 8 , W i n S i g h t a n d W i n S p e c t o r 125

• The Window handle that identifies the destination window• The Message ID number that identifies the message• Two parameters that contain additional message information

Note The Message Queue section might not list the last message the program received: Windows could bypass the message queue by using a SendMessage or similar function.

The following Message Queue example shows one message received and one waiting in the queue:

Message Queue:Last message received:

hWnd: 0000 msg: 0001 wParam: 0002 lParam: 00000003Waiting in queue:

hWnd: 0000 msg: 0001 wParam: 0002 lParam: 00000003

Tasks sectionThe 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.EXEModule: NWPOPUP hModule: 142F hTask: 141F hInstance: 13F6

C:BINWINSPCTR.EXEModule: WINSPCTR hModule: 1397 hTask: 1387 hInstance: 135E

C:BINBAD.EXEModule: BAD hModule: 1467 hTask: 1127 hInstance: 10FE

Modules sectionThe 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: 116132Module: KERNEL hModule: 010F reference count: 21

C:WIN31SYSTEMSYSTEM.DRV Date: 03/01/1992 Size: 2304

Page 126: UG

126 U s e r ’ s G u i d e

Module: SYSTEM hModule: 013F reference count: 13

C:CBINWINSPCTR.EXE Date: 06/02/1992 Size: 46256Module: WINSPCTR hModule: 1397 reference count: 1

USER and GDI heap sectionThe USER and GDI (graphics device interface) heap information section in WINSPCTR.LOG shows what percentage of the USER and GDI heaps was available at the time of exception. For example,

USER Free 91%GDI Free 83%

Because Windows has only 64K of internal heap space for applications to share, it’s often helpful to keep track of how the space is used. If you find that USER and GDI are taking up a lot of heap space, check to see if you have deallocated resources you are not using. The Help|About box for Program Manager lists the lower of these values as the amount of free System Resources.

System Information sectionThe System Information section in WINSPCTR.LOG shows the windows version and mode you’re running, including

• CPU type• Largest free block of contiguous linear memory in the system• Total linear address space in pages• Amount of free memory pages in the linear address space• Number of pages in the system swap file

The System Information section for a 486 system might look like this:

System info: Running in enhanced mode under Windows 3.1 debug versionCPU: 80486Largest free memory block: 3457024 bytesTotal linear memory space: 19696 KFree linear memory space : 18212 KSwap file Pages: 0 (0 K)

Processing WinSpector dataDFA is a utility that takes a WINSPCTR.BIN file and Turbo Debugger information (either in the .EXE, .DLL or .TDS files) and translates the binary data into a useful form by generating a file that contains not only stack trace information similar to the log file but also function names, line numbers, and local and global variables.

DFA post-processes Turbo Debugger information that WinSpector gathered at the time of the exception. If you check the PostMortem dump option (see page 122), WinSpector creates a WINSPCTR.BIN file at the time of the exception. You can use DFA.EXE to translate the binary data in WINSPCTR.BIN into usable information stored in a text file called DFA.OUT.

Page 127: UG

C h a p t e r 8 , W i n S i g h t a n d W i n S p e c t o r 127

Because only one WINSPCTR.BIN file is written per Windows session, make sure you run DFA promptly. For example, if you get three UAEs in succession, WinSpector will write three reports to the log file, but binary data will exist for only the first report. It’s best to run DFA immediately after receiving the first UAE. You might then want to rename the DFA.OUT file and delete the WINSPCTR.BIN and WINSPCTR.LOG files before continuing.

DFA outputDFA 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 DFA with WINSPCTR.LOGWhen DFA is used with the WINSPCTR.LOG file alone, it gives minimal stack trace information, such as addresses. If Turbo Debugger information (contained in a .EXE, .DLL, or .TDS file) is present, source file names and line numbers are added to the report.

Using DFA with WINSPCTR.BINWhen used with the WINSPCTR.BIN file, DFA

• Adds stack-based variables to the log, including local variables, parameters passed to the function, structures and arrays.

• Lists variable types, values, and addresses by function.

If Turbo Debugger information is present, for each stack frame, DFA reports

• In section one, the • Source file• Line number• Local variables• Parameters

• In section two, the • Module name for the task with the fault• File names• Logical segments• The segments’ selectors• Whether the segments are data or code segments

Page 128: UG

128 U s e r ’ s G u i d e

• In section three, the• Global variables• Static variables• The variables’ values at the time of the exception

The format is

DFA [option] WINSPCTR.LOG [WINSPCTR.BIN]

When WINSPCTR.LOG (required) is present, you get source file and line numbers. When WINSPCTR.BIN (optional) is present, you get additional variable information.

Other WinSpector toolsWinSpector has three utilities you can use to enhance the information about an exception:

• EXEMAP.EXE creates a .MAP file from a Windows .EXE file. The .MAP file is needed to create a .SYM file, which expands error reporting for the original .EXE.

• TMAPSYM.EXE, used in conjunction with EXEMAP.EXE, creates a .SYM file from a .MAP file.

• BUILDSYM.EXE uses EXEMAP.EXE and TMAPSYM.EXE to create a .SYM file from a Windows .EXE file.

Using EXEMAP.EXEEXEMAP 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.EXETMAPSYM 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.

Table 8.14 DFA options

Option What it does

/O[outputfile] Renames the output file from the DFA.OUT default/D Forces DFA to write a hex dump of the saved data segments

Page 129: UG

C h a p t e r 8 , W i n S i g h t a n d W i n S p e c t o r 129

Constants and line-number information, however, are not included in a TMAPSYM-generated .SYM file.

To create a .SYM file from a .MAP file, type TMAPSYM filename.MAP (you must type the .MAP extension).

Using BUILDSYM.EXEBUILDSYM 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.

Page 130: UG

130 U s e r ’ s G u i d e

Page 131: UG

P a r t I I , U s i n g R e s o u r c e W o r k s h o p 131

P a r t

IIPart IIUsing Resource Workshop

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.

Page 132: UG

132 U s e r ’ s G u i d e

Page 133: UG

C h a p t e r 9 , A n o v e r v i e w o f w o r k i n g w i t h r e s o u r c e s 133

C h a p t e r

9Chapter 9An overview of working

with resourcesResource 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.

Page 134: UG

134 U s e r ’ s G u i d e

What is a resource?A resource is a binary data item that is linked to an .EXE, .DLL, or other binary file. Typically, a resource defines one of the following user interface components:

• A dialog box, which is a pop-up window that uses labels, text boxes, buttons, check boxes, scroll bars, and other controls to give information to and receive information from a user. You can create a dialog box that pops up when a menu command is chosen or when an event occurs in an application. You can also create a dialog box that serves as the main window for an application.

• A menu, which is a list of commands from which a user can choose. Types of menus include standard menus, which appear on an application’s menu bar; floating menus, which can appear anywhere on the screen; and hierarchical (cascading) menus, which can appear when you choose a menu command. Applications often have standard menus that are labeled File, Edit, and Help; these menus contain file manipulation, editing, and online Help commands respectively.

• An accelerator table, which is one or more key combinations that a user can press to perform an action. For example, many applications use Ctrl+X to cut data and Ctrl+V to paste data.

• A string table, which is one or more text strings that can contain descriptions, prompts, error messages, and so on.

• 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 resource can also contain a set of bitmaps that aren’t characters. Although Windows supports both raster fonts, which contain bitmaps for each character, and outline fonts, which contain drawing commands for each character, you can only create raster fonts in Resource Workshop. For more sophisticated font technology, you should consult with a third-party vendor.

A resource can also define

• Version information, which is a block of data that can be used in several Windows API functions, including GetFileVersionInfo and VerInstallFile. Among other information, the version information resource specifies the version number, file type, operating system of an application.

• A custom data type, which is any data that you want to link to an application. For example, you can create a custom data type for blocks of text that exceed the 255-character limit of a string resource, or you can create a custom data type for metafiles, which are files that contain mathematical representations of images.

Page 135: UG

C h a p t e r 9 , A n o v e r v i e w o f w o r k i n g w i t h r e s o u r c e s 135

Why you should link resources to your applicationsBy linking resources to an application, you can keep data separate from code. This separation allows you to easily

• Find and change parts of the application, such as user interface components. For example, if you keep all the strings for the application in a string table, you can easily customize the application for a foreign language: just open the resource script file containing the string table, translate the strings, save the resource script file, and then relink the corresponding resources to the application. You don’t need to search for and change the strings in code.

• Change an application without changing its source files. With Resource Workshop, you can extract, modify, and save resources directly into a binary file, such as an .EXE or .DLL file. You don’t need the original resource script files.

• Share data among your applications. You can include the same resources in any application. You don’t need to recreate resources from scratch.

• Create and edit resources in a graphical environment. With Resource Workshop, you can work with resources just as they appear in the application. You don’t need to compile and run the application to see user interface changes.

Starting Resource WorkshopYou create and edit resources with Resource Workshop. To start Resource Workshop from the IDE, double-click a resource script (.RC) file node or choose Tool|Resource Workshop. To start Resource Workshop from Program Manager, double-click the Resource Workshop icon.

After you’ve started Resource Workshop, you’re ready to create and edit resources by working with resource script, binary, and graphic files.

Working with resource script filesTo create and edit resources, you use resource script files. A resource script file contains one or more sets of ASCII data, called resource scripts, from which binary resources can be generated. Each resource type has a different resource script format; however, you don’t need to know these formats unless you plan to edit a resource script file in a text editor. For information about resource script formats, search online Help for “Editing a resource as text.”

In Resource Workshop, you can create and edit resource scripts using the Dialog, Menu, Accelerator, Graphic, String, and Script editors. Use the Graphic editor to work with

To See

Create or edit a resource script file “Working with resource script files” on page 135Edit resources in a binary file “Working with binary files” on page 142Create or edit a graphic file “Working with graphic files” on page 143

Page 136: UG

136 U s e r ’ s G u i d e

bitmaps, cursors, icons, and fonts; use the Script editor to work with raw resource scripts, including resource scripts for version information and custom data types.

Unlike a text editor, most Resource Workshop editors are graphical; they allow you to work with resources just as they appear in an application. When you save your work in Resource Workshop, you can create a resource script file automatically. The file contains resource scripts that correspond to the resources you define in the Resource Workshop editors.

In addition to resource scripts, a resource script file can contain one or more identifiers. An identifier is a unique name or number that you can use in code to refer to a resource. In Resource Workshop, you can have identifiers created automatically when you add new resources, or you can create identifiers manually. For more information about automatically creating identifiers, see the section “Setting general environment options” on page 144.

Note You can’t refer to a resource in code unless the resource has a corresponding identifier.

The following sections show how to

• Create a new resource script file• Edit an existing resource script file• Generate binary resources from a resource script file

Creating a resource script fileTo create a resource script file,

1 Choose File|New Project.

2 Select RC.

3 Choose OK.

The Add File To Project dialog box appears.

4 If you want to store identifiers in a separate file, type the name of a resource header file in the File Name box, and choose OK. (Just like standard C header files, the resource header file can contain identifiers.) Otherwise, choose Cancel.

You can add resource header files later by using the File|Add To Project command. For more information, see the section “Adding an identifier” on page 140.

5 Choose File|Save Project.

6 In the File Name box, type a name for the new resource script file.

7 Choose OK.

Now you have an empty resource script file to which you can add resource scripts and identifiers.

Editing an existing resource script fileTo edit an existing resource script file,

Page 137: UG

C h a p t e r 9 , A n o v e r v i e w o f w o r k i n g w i t h r e s o u r c e s 137

1 Choose File|Open Project.

2 In the File Type box, choose RC resource script.

3 In the File Name box, type the resource script file name. Or select the file name using the Files and Directories boxes.

4 Choose OK.

5 Add, edit, or remove resource scripts and identifiers from the resource script file. These procedures are described in the following sections.

6 Choose File|Save Project.

Adding resource scriptsYou can add resource scripts to a resource script file directly or indirectly. When you add resource scripts to a resource script file directly, the corresponding data is included in the current resource script file. When you add resource scripts indirectly, you can access the corresponding data from the current resource script file, but the data is stored in a separate resource script file.

If you want to keep your resource scripts together, you should add them directly to a single resource script file. On the other hand, if you want to share resource scripts among several resource script files, you should add the resource scripts indirectly to each file.

Adding a new resource script indirectlyTo add a new resource script indirectly,

1 Create or open the resource script file.

2 Choose File|Add To Project.

3 In the File Type box, choose RC Resource Script.

4 Type a name for the new resource script file. The file name must be unique from other files in the current directory.

5 Choose OK.

A dialog box asks whether you want to create a new resource script file.

6 Choose Yes.

Adding one or more existing resource scripts indirectlyTo add one or more existing resource scripts indirectly,

1 Open the resource script file.

2 Choose File|Add To Project.

3 In the File Type box, type the name of the file that contains the resource script(s). Or select the file using the Files and Directories boxes. You can specify a resource script, binary, or graphic file. All resource scripts in the file will be added indirectly to the current resource script file.

Page 138: UG

138 U s e r ’ s G u i d e

4 Choose OK.

Note If a file contains more resource scripts than you need, you can use the Resource|Save Resource As command to separate some resource scripts into new files. Then you can add the new files indirectly to the current resource script file.

Adding a new resource script directlyTo add a new resource script directly,

1 Create or open the resource script file.

2 Choose Resource|New.

3 In the Resource Type box, select a resource type.

4 Choose the resource script file to which you want to add the new resource script. You can choose the current resource script file or any file containing resource scripts that have been added indirectly to the current project.

5 Choose OK.

6 If you’re embedding a definition for a graphic, choose Source. You can also add the graphic to the current resource script file by choosing Binary, but this choice adds the new graphic indirectly.

7 If you’re embedding a definition for a bitmap or icon, specify size and color options, and then choose OK. If you don’t know which size and color options to specify, accept the default values. For information about changing the size and color options, see “Changing the properties of a bitmap” on page 196 or “Changing the properties of an icon” on page 197.

Adding an existing resource script directlyTo add an existing resource script directly, copy or move the resource script from one file to another.

To copy or move a resource script,

1 Open the file that contains the resource script. (You might want to save the current file first.)

2 In the Project window, select the resource script.

3 Choose Edit|Copy (to copy the resource script) or Edit|Cut (to move the resource script).

4 Open the file to which you want to copy or move the resource script.

5 Choose Edit|Paste.

Note You can only paste a resource script into a file with a compatible format. For example, you can’t paste an icon script into a bitmap file.

Editing a resource scriptYou can edit a resource script by using one of the Resource Workshop editors or by specifying memory or language options.

Page 139: UG

C h a p t e r 9 , A n o v e r v i e w o f w o r k i n g w i t h r e s o u r c e s 139

To edit a resource script in a Resource Workshop editor,

1 In the Project window, double-click the resource script.

2 Follow the instructions in the appropriate chapter of this book (see the following table).

Specifying memory optionsEach resource script includes information about how the resource is handled in memory.

To specify memory options for a resource script,

1 In the Project window, select the resource script.

2 Choose Resource|Memory Options.

3 Select or deselect the following memory options:

4 Choose OK.

Specifying a language versionFor a Win32 application, you can create resources with different versions for each language, such as French, German, Spanish, and so on. A Win32 application automatically uses the resources that correspond to the system on which it runs. For example, a Win32 application running on a French system automatically uses the French versions of resources. (To set the system language, use the International settings in the Windows Control Panel.)

Note You can use Win32 resources with Borland C++, but not with Turbo C++.

For information about working with See

Dialog boxes Chapter 10Menus and accelerators Chapter 11Strings Chapter 12Bitmaps, icons, cursors, and fonts Chapter 13Version information and custom data types Chapter 14

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.

Page 140: UG

140 U s e r ’ s G u i d e

To specify a language version for a Win32 resource script,

1 In the Project window, select the resource script.

2 Choose Resource|Language.

3 Choose a major language or Neutral. (A resource with a Neutral language version works on all systems.)

A major language is a language with one or more dialects. For example, the English major language has dialects for Australia, Canada, New Zealand, the United Kingdom, and the United States.

4 Choose a minor language or Neutral.

A minor language is a particular dialect within a major language.

5 Choose OK.

Removing a resource scriptTo delete a resource script from a resource script file,

1 In the Project window, select the resource script.2 Press Del.

Adding an identifierIf 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.

Page 141: UG

C h a p t e r 9 , A n o v e r v i e w o f w o r k i n g w i t h r e s o u r c e s 141

Depending on how you want to organize identifiers and which identifiers you’ve already defined, you might want to add a new or existing resource header file to the current resource script file.

To add a new or existing resource header file to the current resource script file,

1 Choose File|Add To Project.

2 In the File Type box, choose RH, H C Header.

3 In the File Name box, type the name of the new or existing resource header file.

4 Choose OK.

5 If you’re adding a new resource header file, a dialog box warns you that the resource header file doesn’t currently exist. Choose Yes to create the new resource header file.

Editing an identifierYou 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 identifierIf 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.

Page 142: UG

142 U s e r ’ s G u i d e

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.

Generating binary resources from a resource script fileAfter you add one or more resource scripts and identifiers to a resource script file, you can compile the resource script file into one or more binary resources, link the binary resources to an application, and then refer to the resources in the application’s code by using the corresponding identifiers.

To generate resources from a resource script file, include the resource script file as a node in an IDE application project. The next time you compile the application, the resource scripts in the resource script file are automatically compiled and linked to the application. For more information about adding a node to an IDE application project, see “Adding source nodes to your project” on page 24.

Note To refer to resources in code, you must include the corresponding resource header file(s) in your C or C++ source files.

Working with binary filesIn Resource Workshop, you can edit resources in a compiled resource script file (.RES), .EXE, .DLL, or other binary file. You can also create a .RES file directly.

Creating a .RES fileTo create a .RES file,

1 Create or open a resource script file. For information about resource script files, see “Working with resource script files” on page 135.

2 Choose File|Save File As.

3 In the File Type box, choose RES Resource Object.

4 In the File Name box, type a file name for the binary resource file.

5 Choose OK.

Editing resources in a binary fileIn Resource Workshop, you can edit the resources in a binary file even if you don’t have the resource script files from which the resources were generated.

To edit resources in a binary file,

1 Choose File|Open Project.

2 In the File type box, choose the type of binary file that you want to edit.

Page 143: UG

C h a p t e r 9 , A n o v e r v i e w o f w o r k i n g w i t h r e s o u r c e s 143

3 In the File name box, type the binary file name. Or select the file name using the Files and Directories boxes.

4 Choose OK.

5 In the Project window, double-click a resource that you want to edit.

6 Edit the resource by using one of the Resource Workshop editors.

7 Choose File|Save Project.

The resources are automatically recompiled and relinked to the original binary file.

Note When working with binary files, you can’t add resource scripts indirectly or create identifiers. However, you can save a binary file as a resource script file by using the File|Save File As command.

Working with graphic filesA graphic file is a bitmap (.BMP), icon (.ICO), cursor (.CUR), or font (.FNT) file. You can add a graphic file to a resource script file to create a graphic resource, which you can then use in an application. For more information about adding a graphic file to a resource script file, see the section “Adding resource scripts” on page 137.

You can also use graphic files in many applications besides Resource Workshop. For example, you can include bitmaps in most word-processor documents.

Creating a graphic fileTo create a graphic file,

1 Choose File|New Project.

2 Select a graphic file type.

3 Choose OK.

4 If you’re creating a bitmap or icon file, specify size and color options, and then choose OK. If you don’t know which size and color options to specify, accept the default values. For information about changing the size and color options, see the section “Changing the properties of a bitmap” on page 196 or “Changing the properties of an icon” on page 197.

5 Choose File|Save Project.

6 In the File Name box, type a name for the new graphic file.

7 Choose OK.

You can also create a graphic file by opening a binary or resource script file that contains a graphic, selecting the graphic in the Project window, and then saving the graphic in a graphic file using the Resource|Save Resource As command.

Page 144: UG

144 U s e r ’ s G u i d e

Editing a graphic fileTo edit a graphic file,

1 Choose File|Open project.

2 In the File Type box, choose the graphic file type.

3 In the File Name box, type the graphic file name. Or select the file name using the Files and Directories boxes.

4 Choose OK.

5 Use the graphic editing tools, which are described in Chapter 13, “Working with graphics,” on page 187.

6 Choose File|Save Project.

Customizing Resource WorkshopYou can customize Resource Workshop by specifying which information appears in the Project window, and by setting general environment options.

Specifying which information appears in the Project windowIf there is an open file in Resource Workshop, you can specify which information appears in the Project window by using the commands in the following table:

Setting general environment optionsTo set general environment options,

1 Choose File|Preferences.

Use this command To

View|By Type or View|By File Group resource scripts by type (dialog boxes, menus, accelerators, and so on), or by file (first file, second file, and so on).

View|Show Identifiers Show the identifiers in the current resource script file.View|Show Resources Show the resource scripts in the current resource script file.View|Show Items Show individual items in resource scripts, such as the individual

commands on menus, strings in a string table, and accelerators in an accelerator table.

View|Show Unused Types Show placeholders in the Project window for resource types that have not been added to the current resource script file.

View|Show Vertical Preview, View|Show Horizontal Preview, or View|Hide Preview

Hide the Preview pane of the Project window or display the Preview pane horizontally or vertically. (The Preview pane shows a miniature version of the selected resource as it appears in the corresponding Resource Workshop editor.)

Page 145: UG

C h a p t e r 9 , A n o v e r v i e w o f w o r k i n g w i t h r e s o u r c e s 145

2 Set any of the following options:

3 Choose OK.

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 Management

Whether or not identifiers are automatically created when you add new 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++.

Page 146: UG

146 U s e r ’ s G u i d e

Page 147: UG

C h a p t e r 1 0 , W o r k i n g w i t h d i a l o g b o x e s 147

C h a p t e r

10Chapter 10Working with dialog boxes

A dialog box is a pop-up window that uses labels, text boxes, buttons, check boxes, scroll bars, and other controls to give information to and receive information from a user. You can create a dialog box that pops up when a menu command is chosen or when an event occurs in an application. You can also create a dialog box that serves as the main window of an application.

Like other resources, you define a dialog box with a resource script. This chapter describes how to edit and test a dialog box resource script, and how to use the corresponding resource in an application.

Editing a dialog box resource scriptYou edit a dialog box resource script by using the Dialog editor.

To start the Dialog editor,

1 Create a resource script file and add a dialog box resource script. Or open a resource script file that contains a dialog box resource script.

2 If the Dialog editor doesn’t start automatically, double-click a dialog box resource script in the Project window.

Page 148: UG

148 U s e r ’ s G u i d e

The Dialog editor appears. It contains a dialog box template, Tools palette, and Alignment palette.

The Tools palette has the following tools:

The Alignment palette has the following tools:

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

Dialog editor window

Alignment palette

Dialog box template

Tools palette

Selector

Tab Set

Set Groups

Set Order

Test

Duplicate

Undo

Push Button

Horizontal Scroll Bar

List Box

Group Box

Edit Box

Icon

Rectangle

Radio Button

Vertical Scroll Bar

Check Box

Combo Box

Static Text

Frame

Custom Control

Borland Group Box

Horizontal Line

Vertical Line

Borland Push Button

Borland Radio Button

Borland Check Box

Borland Static Text

Align Left Sides

Align Centers Horizontally

Center in Dialog Box Horizontally

Align Right Sides

Align Top Sides

Align Centers Vertically

Center in Dialog Box Vertically

Align Bottom Sides

Page 149: UG

C h a p t e r 1 0 , W o r k i n g w i t h d i a l o g b o x e s 149

• Setting the Windows classes of controls• Setting control properties

To customize the Dialog editor, see “Customizing the Dialog editor” on page 169.

Setting dialog box propertiesTo set the properties of a dialog box, double-click its title bar or outer edge, and then use the Window Style dialog box. You can set any of the properties described in the following sections.

Class propertyYou 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 propertyLike 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 propertyYou 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.

Page 150: UG

150 U s e r ’ s G u i d e

Style propertiesYou can turn the following style properties on or off:

Frame Style propertyYou can set the Frame Style property to one of the following values:

Font propertiesYou can set the Font Name and Font Size properties by choosing the Font button, selecting a font name and size, and then choosing OK.

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 barBorder A single, thin border without a title barCaption A single, thin border and a title bar where a caption can be displayed (default)No border No border or title bar

Page 151: UG

C h a p t e r 1 0 , W o r k i n g w i t h d i a l o g b o x e s 151

Extended Style propertyIf you’re creating resources for a Win32 application (see page 169), you can set the Extended Style property to one of the following values:

Common propertiesIn addition, you can set any of the common properties for the dialog box, which are described page 160.

Moving and resizing a dialog boxYou can move or resize a dialog box just as you would move or resize a control. For more information, see page 155.

If you set the Type property of the dialog box to Overlapped, you can let Windows control the position of the dialog box on the screen. Select the dialog box, choose Align|Size, select the Set by Windows box, and then choose OK.

Adding a standard control to a dialog boxTo add a standard control to a dialog box,

1 In the Tools palette, select the control. (The controls are described in a table in this section.)

2 Drag the mouse in the dialog box template.

If you select a control from the Tools palette and then change your mind about placing it, press Esc.

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.

Page 152: UG

152 U s e r ’ s G u i d e

You can add any of the following controls:

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.

Edit box A box in which the user can edit text.

List box A box that contains a list of items from which the user can choose.

Combo box A box in which a user can type or select an item.

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.

Page 153: UG

C h a p t e r 1 0 , W o r k i n g w i t h d i a l o g b o x e s 153

The advantages of using Borland controlsBorland controls add a three-dimensional effect to your dialog boxes, giving more visual impact. Borland controls work like standard Windows controls, but they provide you with an additional level of control over keyboard focus and tab movement. To use the full capabilities of a Borland control, you must select the Parent Notify property using the Style window for the control. For more information, see “Setting common properties using the Style window” on page 161.

A Borland control can send the following messages to your dialog box:

Working with custom controlsIn addition to standard and Borland controls, you can add custom controls to a dialog box template. A custom control is any other window class that you want to add to your dialog box. You can create your own custom controls or buy custom controls from a third-party vendor.

The Borland Visual Solutions Pack, which is sold separately, contains many custom controls, including

• A WYSIWYG word processor with separate status bar, button bar, and ruler controls. All four controls are integrated and interface seamlessly, requiring minimal programming.

• A full-featured spreadsheet with multiple worksheets, and a calculation engine that includes a comprehensive set of worksheet functions.

• Twelve database controls that let you add sophisticated database front-ends quickly and with virtually no coding. These controls provide substantial database functionality, including visual generation of simple or master-detail forms, binding fields to database columns, and performing queries by form.

• Notebook tabs that help you organize user interface components into folders or other groupings.

Installing a control library (.DLL or .VBX)Custom controls are stored in .DLL or Visual Basic custom control (.VBX) files. Before you can use custom controls in Resource Workshop, you must install them.

To install custom controls,

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.

Page 154: UG

154 U s e r ’ s G u i d e

1 Choose File|Install Control Library.

2 In the File Name box, type the name of the .DLL or .VBX file. Or select the file using the Files and Directories boxes.

3 Choose OK.

Now you can add the controls contained in that .DLL or .VBX file to your dialog box.

Adding a custom control to a dialog boxIf a custom control is recognized by Resource Workshop, its icon appears in a column on the right side of the Tools palette. You can add the custom control to your dialog box by selecting it, and then dragging the mouse in the dialog box template.

However, if a custom control is not recognized by Resource Workshop, its icon does not appear in the Tools palette, and you’ll need to follow these steps to add the custom control to your dialog box:

1 Click the Custom Control tool or choose Control|Custom.

2 In the Class box, choose the custom control.

Resource Workshop displays a sample of the custom control you’ve selected in the middle of the dialog box.

3 Choose OK.

4 In the dialog box template, drag the mouse where you want to place the custom control.

An icon representing the custom control appears in the dialog box template.

Creating custom controlsTo create custom controls, you must design and store them in dynamic-link library (.DLL) files. The process of creating custom controls is described in the BWCC reference in online Help (BWCC.HLP).

Selecting controlsMany 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.

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.

CustomControl

tool

Selectortool

Page 155: UG

C h a p t e r 1 0 , W o r k i n g w i t h d i a l o g b o x e s 155

3 Drag a rectangle around the controls you want to select. Depending on the current state of the Selection Rectangle Surrounds check box in the Options|Preferences dialog box, the selection rectangle must either entirely surround the controls or just touch them.

A selection frame appears around the controls you select.

You can also perform the following selection actions:

Moving controlsYou 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 controlsYou 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.

To Perform this action

Add or remove a single control from a selected group

Shift+click the control.

Select all the controls in a dialog box

Choose Edit|Select All.

Move the selection frame Press Tab (to select the next control in the tab order) or Shift+Tab (to select the previous control in the tab order).If the current selection includes more than one control, the selection frame moves to the control that precedes or follows the highest one in the current selection. However, if the current selection includes controls selected with Shift+click, the selection frame moves to the control that precedes or follows the last control you selected. For more information about the tab order, see “Setting the tab order of controls” on page 157.

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.

Page 156: UG

156 U s e r ’ s G u i d e

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.

Fine-tuning the size of controlsYou can use the keyboard and mouse together to fine-tune the size of a control:

1 Select the control and move the mouse pointer over an edge or corner of the control.

The cursor becomes a double-headed arrow.

2 Hold down the left mouse button and press an arrow key. Each time you press the arrow key, the selection frame moves a single pixel or dialog unit.

Moving and resizing controls at the same timeYou can specify the position and size of a control at the same time:

1 Select the control.

2 Choose Align|Size or hold down the Alt key while double-clicking the mouse.

The Size Controls dialog box appears.

3 To set the position of the upper left corner of the control, specify its X- and Y-coordinates in pixels or dialog units. The coordinates 0,0 place the control in the upper left corner of the dialog box, directly below the title bar.

4 To set the control’s width and height, specify its CX- and CY-values in pixels or dialog units.

Vertical size options Description

No Change Prevents vertical size change.Shrink to Smallest Reduces height of controls to match the least tall of the selected controls.Grow to Largest Increases height of controls to match the tallest of the selected controls.Height of Size Box Resizes controls so they are as tall as the selection frame.Height of Dialog Resizes controls so they are as tall as the dialog box.

Page 157: UG

C h a p t e r 1 0 , W o r k i n g w i t h d i a l o g b o x e s 157

Grouping and ungrouping controlsYou can group controls to let the user move among them using the arrow keys.

To group controls,

1 Click the Set Groups tool or choose Options|Set Groups.2 Click a control that is not surrounded by a shaded outline.

To ungroup controls,

1 Click the Set Groups tool or choose Options|Set Groups.2 Click a control that is surrounded by a shaded outline.

You can also set the Group property using the Style window. For more information about the Style window, see “Setting common properties using the Style window” on page 161.

Note You mark only the first control in each group with the Group attribute. Controls are included in the group according to the order in which they are added to the dialog box. For example, if you add seven controls to your dialog box and then turn on the Group property of the first and fifth controls, the first four controls are included in the first group, and the remaining controls are included in the second group.

Setting the tab order of controlsYou can specify the order in which users can tab to the controls in a dialog box.

To specify the tab order of the controls in your dialog box,

1 Select the controls whose tab order you want to change. To specify the order for all controls in the dialog box, don’t select any controls.

2 Click the Set Order tool. Or choose Options|Set Order.

Each control you selected is numbered to show its current place in the overall order. Note the Next Item prompt at the bottom of the Dialog editor. It tells you the number that will be assigned to the next control you select.

3 Click the controls to which you want to assign numbers.

While assigning new order numbers, you can “step back” by re-clicking the last control you just clicked. The order changes to its previous number. You can continue to backtrack by clicking the controls in the reverse order that you originally clicked them.

4 When you’re done assigning numbers, click the Selector tool to return to selection mode.

Aligning controlsYou 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.

SetGroups

tool

Set Ordertool

Page 158: UG

158 U s e r ’ s G u i d e

Aligning controls with the Align|Align commandTo align your controls with the Align|Align command,

1 Select the controls you want to align.

A selection frame surrounds all the selected controls. The individual controls you can align are shaded.

2 Choose Align|Align. The Align Controls dialog box appears.

3 Choose the Vertical Alignment and Horizontal Alignment options you want, and then choose OK.

Aligning controls with the Alignment paletteYou can also align controls using the Alignment palette. Select the controls you want to align and then choose a tool from the Alignment palette.

The Space Equally option is not in the Alignment palette. However, you can use the Align Controls dialog box as explained in the previous section, or you can space controls equally by stretching the selection frame.

To space controls equally by stretching the selection frame,

1 Select the controls you want to space equally.

A selection frame surrounds your selected controls.

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.

Page 159: UG

C h a p t e r 1 0 , W o r k i n g w i t h d i a l o g b o x e s 159

2 Stretch the selection frame by holding down the Ctrl key while dragging the edge of the selection frame in the direction you want to space your controls:• To space the controls equally in the horizontal direction, stretch the right or left

border of the selection frame.• To space the controls equally in the vertical direction, stretch the top or bottom

border of the selection frame.

If you stretch a corner of the selection frame, the Form Controls into an Array dialog box appears, ready for you to arrange your controls in rows and columns.

Aligning controls with the gridTo align controls with the grid,

1 Choose Align|Grid. The Set Grid Attributes dialog box appears.

2 Specify the width and height of a grid cell (in dialog units).

3 Select the Grid Type:• Absolute. Snaps the control to the nearest grid line.• Relative. Moves the control only in increments of the grid width horizontally and

the grid height vertically. Therefore, if a control was not placed on a grid line originally, you will not be able to move it to a grid line with this option selected. For example, if you set the grid to be 4x4 and have a control with a position of (1,1), when you move the control, it will only go to positions that are 4 units away in either dimension. Possible coordinates would be (5,5), (5,9), (9,5), and so on.

4 Select the Show Grid option and choose OK.

5 Align controls by moving them around in the dialog box template. (You can move controls by dragging them or by selecting them and pressing the arrow keys.)

Aligning controls in columns and rowsThe Align|Array command arranges controls in columns and rows, aligning them horizontally or vertically, spacing them evenly horizontally or vertically, and renumbering them so they are all in sequence.

To use the Align|Array command

1 Select the controls you want to arrange in columns and rows.

The selection frame surrounds the selected controls. The individual controls that will be affected by the Array command are indicated by shaded outlines.

2 If necessary, enlarge or reduce the size of the selection frame to enclose the area you want to fit the columns and rows into. For example, if you make the selection frame larger, the Array command will move the controls out to the new boundaries set by the selection frame.

3 Choose Align|Array or click the Duplicate tool.

4 Under Array Layout, specify the number of rows and columns you want.

5 Under Order, select how to order the controls in this group.Duplicate

tool

Page 160: UG

160 U s e r ’ s G u i d e

6 After you’ve chosen the options for the array, choose OK.

Note For multiple selected controls, the Duplicate tool has the same effect as Align|Array. When only a single control is selected, it has the same effect as Edit|Duplicate.

Undoing actionsYou 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.

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.

Setting the Windows class of a controlIf you’re an advanced Windows programmer, you may want to set the Windows class of a control.

For information about creating Window classes, search Win32 Online Help (WIN32.HLP) for “Windows Classes.”

To set the Windows class of a control,

1 Hold down Ctrl and double-click the control.2 In the Class box, type the name of a Windows class.

Note In the Generic Control Style window, you can also specify a caption, control ID, and style. If you type anything next to Info, the dialog box won’t be compatible with the Microsoft Resource Compiler.

Setting common properties using the Properties windowThe standard controls share common properties that you can set using the Properties window.

To set a common property using the Properties window,

1 Select the control.2 In the Properties window, select the property.3 In the Properties window text box, type a value for the property.

Note If the Properties window is not visible, choose Options|Show Properties.

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.

Undo tool

Page 161: UG

C h a p t e r 1 0 , W o r k i n g w i t h d i a l o g b o x e s 161

Setting common properties using the Style windowIn addition to the common properties that you can set in the Properties window, each control has additional properties that you can set only in the Style window.

To set a common property using the Style window,

1 Double-click the control. The Style window appears.2 In the Attributes group, set any of the properties described in the following table.

Setting the unique properties of a controlIn addition to the common properties described in the previous two sections, each standard control has unique properties that you can set in the Style window. The unique properties of each control are described in the following sections.

ID source / Control ID The identifier for the control. For more information about identifiers, see “Creating a resource script file” on page 136. For information about special identifiers for Push button controls, see the section “Push button properties” on page 162.

ID Value The unique number for the control.Left The distance of the control from the left edge of its parent window in dialog

units or pixels.Tab Stop Whether the user can use the Tab key to select the control.Top The distance of the control from the top edge of its parent window in dialog

units or pixels.Visible Whether the control is visible.Width The width of the control in dialog units or pixels.

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 Underlining

The No Character Underline check box turns off character underlining. You can 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.

Property Description

Page 162: UG

162 U s e r ’ s G u i d e

Push button propertiesThe push button control has unique properties for type and control ID.

Type propertyYou can set the Type property to one of the following values:

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:

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 propertyJust 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:

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 the bitmap represents the button in this state

Use this offset for VGA and higher resolutions

Use this offset for EGA and monochrome resolutions

Standard 1000 2000Pressed 3000 4000Keyboard focus 5000 6000

Control ID Value Meaning

IDOK 1 OKIDCANCEL 2 CancelIDABORT 3 Abort

Page 163: UG

C h a p t e r 1 0 , W o r k i n g w i t h d i a l o g b o x e s 163

Note If you’re using the Borland push button control, the appropriate caption is set automatically when you specify a predefined control ID.

Radio button propertiesThe radio button control has a unique Type property that you can set to Normal or Auto. If you set the type to Auto, Windows automatically selects or unselects the button; your application doesn’t have to do the painting.

Check box propertiesThe check box control has a unique Type property that you can set to one of the following values:

Static text propertiesThe static text control has a unique Type property. You can set the Type property to one of the following values:

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.

IDRETRY 4 RetryIDIGNORE 5 IgnoreIDYES 6 YesIDNO 7 No

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.

Control ID Value Meaning

Page 164: UG

164 U s e r ’ s G u i d e

Group box propertiesThe Borland group box control has a unique Type property that you can set to Normal (group) Shade or Raised Shade. If you set the Type property to Normal Shade, the surface of the group box appears to go inward; otherwise, the surface of the group box appears to go outward.

Scroll bar propertiesThe scroll bar control has a unique Alignment property that you can set to any of the following values:

Edit box propertiesThe edit box control has several unique properties, which are described in the following sections.

Case propertyYou can set the Case property to one of the following values:

Windows 3.1 Style propertyYou can set the Windows 3.1 Style property to one of the following values:.

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.

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.

Page 165: UG

C h a p t e r 1 0 , W o r k i n g w i t h d i a l o g b o x e s 165

Line propertyYou can set the Line property to one of the following values:

Miscellaneous Boolean propertiesYou can turn the following properties on or off:

List box propertiesThe list box control has the following unique properties, which you can turn on or off:

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

Page 166: UG

166 U s e r ’ s G u i d e

Combo box propertiesThe combo box control has several unique properties, which are described in the following sections.

Type propertyYou can set the Type property to one of the following values:

Miscellaneous Boolean propertiesYou can turn the following properties on or off:

Multi Column Creates a list box in which the text wraps from column to column. The user scrolls the list box horizontally to display additional text. If you turn this option on, the application must send the LB_SETCOLUMNWIDTH message to set the width of all columns in pixels.

Pass Keyboard Input Passes what the user types to the application.Extend Select (used with multiple-select boxes)

Lets the user select more than one item in a list.

Has Strings Specifies list box contents. If you’ve chosen either the Fixed or Variable Owner Drawing option, the list box stores text for each list item with the LB_INSERTSTRING or LB_ADDSTRING message. The list box can also retrieve list items from the message LB_GETTEXT.

Scroll Bar Always (Windows 3.1 only)

Specifies list box attributes. The list box always displays a vertical scroll bar, regardless of the number of items it contains. The windows.h constant for this style is LBS_DISABLENOSCROLL.

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.

Property Description

Page 167: UG

C h a p t e r 1 0 , W o r k i n g w i t h d i a l o g b o x e s 167

Icon propertiesTo place an iconic static control in your dialog box,

1 In the Tools palette, click the Icon tool.

2 In the dialog box template, drag where you want the icon to appear.

The icon control appears in the dialog box template.

3 Double-click the icon control.

4 In the Caption box, type the identifier for an icon resource. For information about creating an icon resource, see Chapter 13, “Working with graphics,” on page 187.

5 Select the Number option.

6 Choose OK.

The icon appears in your dialog box.

Frame propertiesThe frame control has a unique Type property, which you can set to any of the following values:

Rectangle propertiesThe rectangle control has a unique Type property, which you can set to any of the following values:

Line propertiesThe line 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.

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.

Page 168: UG

168 U s e r ’ s G u i d e

• Horizontal dip• Vertical dip• Horizontal bump• Vertical bump

A dip appears to be etched into the surface of the dialog box; a bump appears to be raised above the surface of the dialog box.

Testing a dialog box resourceTo see the effect of any changes you’ve made to the dialog box resource, select the Test tool or choose Options|Test Dialog.

You can press Tab and the arrow keys to see how you can move around your dialog box, or you can type text to see how text is scrolled in an edit text control. Check to see if your controls are in the order you want them.

When you test a dialog box, the status line at the bottom of the Dialog editor says Test.

Testing two dialog boxes at the same timeTo test two dialog boxes at the same time,

1 In the Project window, double-click the name of the first dialog box. The Dialog editor starts and displays that dialog box.

2 Click the Test tool or choose Options|Test Dialog.

3 Click the Minimize button of the Dialog editor twice. (The first click switches focus from the dialog box to the Dialog editor window.) Your dialog box is now floating and modeless; you can move it like any other window.

4 Return to the Project window and double-click the name of the second dialog box you want to view. A second Dialog editor starts up.

5 Again, click the Test tool or choose Options|Test Dialog in the second Dialog editor.

6 Click the Minimize button of the second Dialog editor twice.

Now you have two floating dialog boxes that you can test at the same time.

Returning to Edit modeTo leave test mode and return to edit mode, do one of the following:

• In the dialog box, choose OK or Cancel.

• Choose Options|Test Dialog again.

• Press Enter.

• Click the Selector twice. (The first click switches focus from the dialog box to the Dialog editor.)

Test tool

Page 169: UG

C h a p t e r 1 0 , W o r k i n g w i t h d i a l o g b o x e s 169

Customizing the Dialog editorYou can customize the Dialog editor by choosing Options|Preferences and specifying any of the following options:

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.

Option Settings and Descriptions

StatusLine Units Determines the unit of measurement the status line uses to display information:Dialog. Uses the dialog unit as the unit of measurement on the status line. In a dialog unit, y equals 1/8 of the font height, and x equals 1/4 of the font width.Screen. Uses pixels as the unit of measurement on the status line.

Selection Border Lets you change the appearance of the frame that surrounds selected controls:Thick frame. The selection frame is thick, like the standard frame around a Windows application or dialog box window (default).Handles. The selection frame is a rectangular outline with handles (small squares) at each corner and at the midpoint of each side.

Drawing Type Determines how elements of your dialog box are displayed in the Dialog editor:Draft. Draws each control as a rectangle with its control ID in the center. This option also lets you see how much space is occupied by the control’s selection frame.Normal. Draws standard Windows controls as they will appear at run time. Drawing of custom controls is determined by the Draw Custom Controls as Frames check box, described shortly.WYSIWYG (the default option). With this option selected, Resource Workshop creates the dialog and control child windows and the controls draw themselves. This option is slowest, but the most accurate. Installable custom controls draw themselves.

Selection Rules Determines how controls are selected. If you’re working with closely spaced controls, use these options for greater precision and to avoid selecting controls inadvertently:Select Near Border. If this option is checked, you must click on the control’s border. If it is not checked, you can click anywhere inside the control’s border.Selection Rectangle Surrounds. If this option is checked, you must entirely surround the control (or controls) with the selection rectangle. If it is not checked, the selection rectangle need only touch the control (or controls).

Page 170: UG

170 U s e r ’ s G u i d e

Using a dialog box resource in an applicationYou can program a dialog box with OWL or the Windows API.

Programming a dialog box with OWLTo program a dialog box with OWL, use the TDialog class. For example, the following code shows how to create and display a modal dialog box.

TDialog dialog1(GetApplication()->GetMainWindow(), IDD_DIALOG1);dialog1.Execute();

In the preceding code, dialog1 is the name of the dialog box class, and IDD_IDENTIFIER1 is the identifier for the dialog box resource.

For more information about programming dialog boxes with OWL, see the ObjectWindows Programmer’s Guide.

Programming a dialog box with the Windows APITo program a dialog box with the Windows API, use the DialogBox function. For example, the following code shows how to create and display a dialog box.

HINSTANCE hInst;HWND hwndParent;DLGPROC dlgProc;dlgProc = (DLGPROC) MakeProcInstance(ResModeDlgProc, hInst);DialogBox(hInst, MAKEINTRESOURCE(IDD_RESDEMODIALOG), hwndParent, dlgProc);FreeProcInstance((FARPROC) dlgProc);

For more information about programming dialog boxes with the Windows API, search the Windows 3.1 SDK Help file (WIN31WH.HLP) for “Dialog Boxes.”

Page 171: UG

C h a p t e r 1 1 , W o r k i n g w i t h m e n u s a n d a c c e l e r a t o r t a b l e s 171

C h a p t e r

11Chapter 11Working with menus and

accelerator tablesA menu is a list of actions that a user can perform. The types of menus you can add to an application include standard menus, which appear on an application’s menu bar; floating menus, which can appear anywhere on the screen; and hierarchical (cascading) menus, which appear when you choose a menu item. Applications often have standard menus that are labeled File, Edit, and Help; these menus contain file manipulation, editing, and online Help commands, respectively.

An accelerator table contains one or more combination of keys that a user can press to perform an action. For example, many applications use Ctrl+X to cut data and Ctrl+V to paste data.

Like other resources, you define a menu or accelerator with a resource script. This chapter shows how to edit a resource script for a menu or accelerator table, assign an accelerator to a menu item, and use the corresponding resources in an application. This chapter also shows how to customize the Menu and Accelerator editors.

Editing a menu resource scriptYou edit menu resources by using the Menu editor.

To start the Menu editor,

1 Add a new menu resource script to a resource script file. Or open a resource script file that contains a menu resource script.

2 If the Menu editor doesn’t start automatically, double-click a menu in the Project window.

The Menu editor appears. It contains three panes:

• The Attribute pane is where you edit existing menus and menu commands.

Page 172: UG

172 U s e r ’ s G u i d e

• The Test pane displays your menu and lets you test it.

• The Outline pane shows the menus, menu items, and separators in pseudocode. To see the complete code with all parameters for each statement, edit the resource script file with a text editor. For more information, search online Help for “Editing a Resource as Text.”

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.

Adding a menu or separator to the menu barYou can add a predefined menu, custom menu, or separator to the menu bar. With a separator, you can place menus to the far right or on different lines of the menu bar.

Adding a predefined menuTo add a predefined menu to the menu bar,

Test pane

Attribute pane

Outline pane

Page 173: UG

C h a p t e r 1 1 , W o r k i n g w i t h m e n u s a n d a c c e l e r a t o r t a b l e s 173

1 In the Outline pane, select a line between the POPUP and End Popup lines of a menu; this menu will immediately follow the predefined menu. (You can’t add a predefined menu as a cascading menu.)

2 Choose one of the following commands:

Adding a custom menuTo add a custom menu to the menu bar,

1 In the Outline pane, select the line that will immediately precede the menu. If you select a line inside an existing menu (between the POPUP and End Popup lines), the new menu becomes a cascading menu.

2 Choose Menu|New Popup. Or press Ctrl+P.

3 In the Attributes pane, type the menu name in the Item text box.

To associate the menu with a shortcut key, include an ampersand (&) in the menu name. The letter following the ampersand will be underlined, and the user will be able to select the menu by pressing Alt plus the underlined letter. If you want an ampersand character to appear in the menu name, use two ampersands (&&).

You can also use the tab character (\t) and the right-align character (\a) in the menu name.

Now you can test your menu in the Test pane.

Adding a separatorTo 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:

Adding a menu item or separator to a menuTo add a menu item to a menu,

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.

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.

Page 174: UG

174 U s e r ’ s G u i d e

1 In the Outline pane, select the menu item that will immediately precede the new menu item.

2 Choose Menu|New Menu Item. Or press Ins.

The new menu item appears.

3 In the Attributes pane, type the name of the new menu item in the Item box.

To associate the menu item with a shortcut key, include an ampersand (&) in the menu item name. The letter following the ampersand will be underlined, and the user will be able to select the menu item by pressing Alt plus the underlined letter. If you want an ampersand character to appear in the menu item name, use two ampersands (&&).

You can also use the tab character (\t) and the right-align character (\a) in the menu item name.

To add a vertical separator to a menu,

1 In the Outline pane, select the menu item that will immediately follow the separator.2 In the Attributes pane, choose one of the following options:

To add a horizontal separator to a menu,

1 Select the menu item that will immediately follow the separator.2 Choose Menu|New Menu Item. Or press Ins.3 In the Attributes pane, choose Separator in the Item Type group.

Setting the initial state of a menu or menu itemTo set the initial state of a menu or menu item,

1 In the Outline pane, select the menu or menu item.

2 In the Attributes pane, choose one of the following options:

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

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.

Page 175: UG

C h a p t e r 1 1 , W o r k i n g w i t h m e n u s a n d a c c e l e r a t o r t a b l e s 175

represent an option that can be turned on or off. You can check or uncheck the menu item in code with the CheckMenuItem function.

Changing the identifier for a menu itemAn identifier is automatically assigned to each menu item that you create. You can change the identifier for the current menu item by typing a name or value in the Item ID box, or by using the Resource|Identifiers command. For more information about creating and editing identifiers, see “Creating a resource script file” on page 136.

Associating Help text with a menu itemYou might want to associate Help text with a menu item so that you can easily display information about the menu item in the status bar of an application.

To associate Help text with a menu item,

1 In the Outline pane, select the menu item.2 In the Attributes box, type the text into the Item Help box.

The Help text is automatically added to a string table in the current resource script file. (If one doesn’t already exist, a string table is automatically added to the current resource script file.)

Assigning an accelerator to a menu itemYou can assign an accelerator to a menu item in Key Value or Manual mode.

In Key Value mode, any key or key combination you press is automatically assigned to the menu item. You don’t have to manually type the key name, select a key type (ASCII or virtual), or select combination keys (Alt, Shift, and Ctrl).

In Manual mode, you provide all the information that defines the accelerator. You must decide whether to use an ASCII or virtual key. (In general, an ASCII key is an alphanumeric character or punctuation mark, and a virtual key is a function key, arrow key, or an editing key, such as Home or PgDn.) If it’s a virtual key, you must type the correct identifier for the key as it is defined in the windows.h file. You must also select the appropriate Key Type radio button (ASCII or Virtual Key) and select the appropriate combination of the Alt, Shift, and Ctrl check boxes.

To assign an accelerator to a menu item in Key Value mode,

1 In the Outline pane, select the menu item.

2 Choose Menu|Accelerator Key Value.

3 Press the keyboard combination for the accelerator.

4 Press Esc.

5 Select the Invert option if you want the corresponding menu to flash when the user presses the accelerator key.

Page 176: UG

176 U s e r ’ s G u i d e

To assign an accelerator to a menu item in Manual mode,

1 In the Outline pane, select the menu item.

2 In the Key box in the Attributes pane, specify an ASCII or virtual key.

To specify an ASCII key, type the key in quotation marks. Typically you don’t use a single ASCII character as an accelerator key; instead you combine the character with the Alt or Ctrl keys. To add the Ctrl key, precede the ASCII key with a caret (^). For example, type "^P" to assign Ctrl+P to the menu item. To add the Alt key, select the Alt option in step 4.

To specify a virtual key, type the identifier for the key in uppercase letters. The identifiers for virtual keys all start with VK_ and are defined in the windows.h file. You can combine the virtual key with the Alt, Shift, and Ctrl keys in step 4.

3 In the Key type group, choose ASCII or Virtual Key, depending on the key you specified in step 2.

4 Select any of the following options:

The accelerator is automatically added to an accelerator table in the current resource script file. For more information about accelerator tables, see the section “Customizing the Menu editor” on page 178.

Copying, moving, or removing a menu, menu item, or separatorYou can use the commands on the Edit menu to copy, move, or remove the current menu, menu item, or horizontal separator.

Note You can’t remove the last menu, menu item, or horizontal separator from a menu. However, you can remove the menu resource script by selecting the script in the Project window and pressing Del.

You can’t copy or move a vertical separator, but you can remove it.

To remove a vertical separator,

1 In the Outline pane, select the menu or menu item that follows the separator.2 In the Attributes pane, choose No break.

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.

Page 177: UG

C h a p t e r 1 1 , W o r k i n g w i t h m e n u s a n d a c c e l e r a t o r t a b l e s 177

Checking for duplicate identifiersTo check for duplicate identifiers, choose Menu|Check Duplicates.

If two menu items have the same identifier, the message “Duplicate command value found” appears, and the second menu item with a duplicate identifier appears in the Attributes pane.

Creating a resource script for a floating menuA floating menu can be displayed anywhere on the screen; it is not tied to a menu bar.

To create a resource script for a floating menu,

1 Using the File|Add To Project command, add a menu resource indirectly to the current resource script file. For more information, see “Adding a new resource script indirectly” on page 137.

2 In the Outline pane, select the name of the resource. (The name is centered on the first line.)

3 Press the Ins key to add at least one menu item at the top of the outline.

4 Remove the default menu.

5 Add, edit, or remove menu items. These procedures are described in the previous sections.

6 Using the Resource|Save resource as command, save the menu resource script in a new resource script file.

Note To see how the resource will appear at run time, choose View|View As Popup. When you view the menu in the Test Menu pane, it will still appear tied to the menu bar, but as long as your code uses the TrackPopupMenu function correctly, the menu will float at run time.

Page 178: UG

178 U s e r ’ s G u i d e

Customizing the Menu editorYou can use the following commands to customize the menu editor:

Editing an accelerator table resource scriptYou can create accelerators for menu items using the Menu or Accelerator editors. However, you must use the Accelerator editor to remove accelerators and to create accelerators that are not linked to menu items.

To start the Accelerator editor,

1 Add a new resource script for an accelerator table to a resource script file. Or open a resource script file that contains a resource script for an accelerator table.

2 If the Accelerator editor doesn’t start automatically, double-click an accelerator table in the Project window.

The Accelerator editor appears. It contains two panes:

• The Attribute pane is where you edit existing accelerators.

• The Outline pane shows you, in outline script form, all the accelerators defined in the table. The top line of this outline is the name of the accelerator table. The lines below

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.

Page 179: UG

C h a p t e r 1 1 , W o r k i n g w i t h m e n u s a n d a c c e l e r a t o r t a b l e s 179

it are accelerator entries, which have three parts: the keyboard combination, the identifier for the accelerator, and virtual or ASCII indicator.

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

Adding an accelerator resourceTo add an accelerator resource to the accelerator table,

1 In the Outline pane, select the accelerator resource that will immediately precede the new accelerator resource.

2 Choose Accelerator|New Item. Or press Ins.

When you add an accelerator resource, the editing focus automatically switches to the Attribute pane.

Changing the identifier for an accelerator resourceAn identifier is automatically assigned to each accelerator resource that you create. In the Attributes pane, you can change the identifier for the current accelerator resource by typing a name or value in the Command box, or by using the Resource|Identifiers

Outline pane

Attribute pane

Page 180: UG

180 U s e r ’ s G u i d e

command. For more information about creating and editing identifiers, see “Working with resource script files” on page 135.

If you type the identifier for a menu item in the Command box, the accelerator is assigned to the menu item.

Changing the keyboard combination for an accelerator resourceYou can change the keyboard combination for an accelerator resource in Key Value or Manual mode. These modes are described in the “Assigning an accelerator to a menu item” on page 175.

To change a keyboard combination for an accelerator resource in Key Value mode,

1 In the Outline pane, select the accelerator resource. You can use the mouse or keyboard (Ctrl ↑ or Ctrl ↓).

2 Choose Accelerator|Key Value.

3 Press the new keyboard combination for the accelerator.

4 Select the Invert option if you want the corresponding menu to flash when the user presses the accelerator key. If the accelerator key is not assigned to a menu item, then the Invert option is ignored.

To change the keyboard combination for an accelerator resource in Manual mode,

1 In the Outline pane, select the accelerator resource. You can use the mouse or keyboard (Ctrl ↑ or Ctrl ↓).

2 In the Command box in the Attributes pane, type an ASCII or virtual key.

For more information about ASCII and virtual keys, see the section “Assigning an accelerator to a menu item” on page 175.

3 In the Key type group, choose ASCII or Virtual Key, depending on the key you specified in step 2.

4 In the Modifiers group, select or deselect the Alt, Shift, Control, and Invert options.

For more information about these options, see the section “Assigning an accelerator to a menu item” on page 175.

Copying, moving, or removing an accelerator resourceYou can use the commands on the Edit menu to copy, move, or remove the current accelerator resource.

Note You can’t remove the last accelerator resource from an accelerator table. However, you can remove the resource script for the accelerator table by selecting the script in the Project window and pressing Del.

Page 181: UG

C h a p t e r 1 1 , W o r k i n g w i t h m e n u s a n d a c c e l e r a t o r t a b l e s 181

Checking for duplicate keyboard combinationsTo check for duplicate keyboard combinations, choose Accelerator|Check Dup Keys.

If two accelerator resources use the same keyboard combination, the message “Duplicate key value found” appears, and the second of the accelerator resources with duplicate keyboard combinations is highlighted in the Outline pane.

Customizing the Accelerator editorYou can customize the Accelerator editor by changing the identifier prefix that is automatically assigned to new accelerators.

To change the identifier prefix that is automatically assigned to new accelerators,

1 Choose Accelerator|Change Identifier Prefix.2 Type the new identifier prefix.3 Choose OK.

Using menu and accelerator resources in an applicationYou can program menus and accelerators with OWL or the Windows API.

Programming menus and accelerators with OWLTo program menus and accelerators with OWL, use the TMenu class and the LoadAccelerators function. For example, the following code shows how to associate a menu and accelerators with the main window.

GetMainWindow()->AssignMenu(IDM_MENU1);LoadAccelerators(IDD_ACCELERATORS1);

In the above code, IDM_MENU1 and IDD_ACCELERATORS1 are the identifiers for the menu and accelerator table respectively.

For more information about programming menus and accelerators with OWL, see the ObjectWindows Programmer’s Guide.

Programming menus and accelerators with the Windows APITo program menus and accelerators with the Windows API, use the LoadMenu and LoadAccelerators functions. For example, the following code shows how to associate a menu and accelerators with the main window.

HMENU hMenu;hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDD_MENU1)LoadAccelerators(hInst, MAKEINTRESOURCE(IDD(ACCELERATORS1)

In the preceding code, IDM_MENU1 and IDD_ACCELERATORS1 are the identifiers for the menu and accelerator table respectively.

Page 182: UG

182 U s e r ’ s G u i d e

For more information about menus and accelerators with the Windows API, search the Windows 3.1 SDK Help file (WIN31WH.HLP) for “Menu Functions” and “Accelerator Resource.”

Page 183: UG

C h a p t e r 1 2 , W o r k i n g w i t h s t r i n g t a b l e s 183

C h a p t e r

12Chapter 12Working with string tables

A string table contains descriptions, prompts, error messages, and other text that your application displays.

Like other resources, you define a string table with a resource script. This chapter shows how to edit a string table resource script, and use the corresponding resource in an application. This chapter also shows how to customize the String editor.

Editing a string table resource scriptYou edit a string table resource script by using the String editor.

To start the String editor,

1 Add a new string table resource script to a resource script file. Or open a resource script file that contains a string table resource script.

2 If the String editor doesn’t start automatically, double-click a string table in the Project window.

The String editor appears. It is similar to a three-column spreadsheet.

After you start the String editor, you can edit the string resource script by

• Adding a string resource• Changing the characters of a string resource• Changing the identifier for a string resource• Copying, moving, or removing a string resource

To customize the String editor, see “Customizing the String editor” on page 185.

Adding a string resourceTo add a string resource,

Page 184: UG

184 U s e r ’ s G u i d e

1 Select the line containing the string resource that will immediately precede the new string resource.

2 Choose String Table|New Item. Or press Ins.

3 In the String column, type up to 255 characters. You can also use any of the C-type escape sequences, including \n (newline), \t (tab), \r (carriage return),\\ (backslash), and \” (double quote).

4 Press Enter.

Changing the characters of a string resourceTo change the characters of a string resource,

1 In the String column, select the characters.

2 Type the new characters. You can also use any of the C-type escape sequences, including \n (newline), \t (tab), \r (carriage return), \\ (backslash), and \” (double quote).

3 Press Enter.

Changing the identifier for a string resourceTo change the identifier for a string resource,

1 In the Source ID column, select the identifier.2 Type a new identifier.3 Press Enter.

Note You can’t directly change the identifier in the ID Value column; however, any integer that you type into the Source ID column is automatically copied into the ID Value column.

You can also change the identifier for a string resource by using the Resource|Identifiers command. For more information about identifiers, see “Working with resource script files” on page 135.

Grouping string resources to maximize memory efficiencyString resources are linked to an application in 16-resource segments. String resources with identifier values from 0 to 15 are in the first segment, string resources with identifier values from 16 to 31 are in the second segment, and so on.

When an application uses a string resource, it loads all the string resources in the corresponding segment. Therefore, you can maximize the memory efficiency of an application by grouping related string resources together.

For example, suppose you’ve created six string resources for the title screen of an application. If you arrange these string resources into six different segments, the application could load over 24000 bytes of unused string resources, depending on the sizes of the string resources in each segment, when the title screen is displayed. On the

Page 185: UG

C h a p t e r 1 2 , W o r k i n g w i t h s t r i n g t a b l e s 185

other hand, if you group the six string resources into one segment, the application will load no more than 4100 bytes of string resources when the title screen is displayed.

Copying, moving, or removing a string resourceYou can use the commands on the Edit menu to copy, move, or remove a string resource. You can also perform these actions with the shortcut menu. To display the shortcut menu, right-click on a string resource.

Note You remove all but the last string from a string table. You can remove the string table resource script by selecting it in the Project window and pressing Del.

Customizing the String editorYou can customize the String editor by changing the identifier prefix that is automatically assigned to new string resources.

To change the identifier prefix that is automatically assigned to new string resources,

1 Choose String Table|Change Identifier Prefix.2 Type the new identifier prefix.3 Choose OK.

Using a string resource in an applicationTo include a string resource in an application, use the LoadString function. For example, the following code shows how to copy a string resource into a variable.

char messageText[255];LoadString(IDS_STRING1, messageText, sizeof(messageText));

In the above code, IDS_STRING1 is the identifier for the string.

For more information about using strings in an applications, search the Windows 3.1 SDK Help file (win31wh.hlp) for “String-Manipulation Functions.”

Page 186: UG

186 U s e r ’ s G u i d e

Page 187: UG

C h a p t e r 1 3 , W o r k i n g w i t h g r a p h i c s 187

C h a p t e r

13Chapter 13Working with graphics

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.

Editing a resource script for a graphicYou edit a resource script for a graphic by using the Graphic editor.

To start the Graphic editor,

1 Add a new resource script for a graphic to a resource script file.

Or open a resource script file that contains a resource script for a graphic.

Or create or open a graphic file.

2 If the Graphic editor doesn’t start automatically, double-click a graphic in the Project window.

Page 188: UG

188 U s e r ’ s G u i d e

3 If you’re editing a resource script for an icon or cursor that contains more than one image, double-click an image in the Image window. (The Image window has the identifier for the icon or cursor in its caption.)

The Graphic editor appears. It contains a Tools palette and Colors palette.

The Tools palette contains the drawing tools.

The Colors palette shows the available colors.

To customize the Graphic editor, see “Customizing the Graphic editor” on page 199.

Colors paletteDrawing AreaTools palette

First pane

Second pane

Drawing Area

Pick Rectangle

Zoom

Pen

Airbrush

Line

Empty Rectangle

Empty Rounded Rectangle

Empty Ellipse

Paintbrush Shape

Pen Style

Scissors

Eraser

Paintbrush

Paint Can

Text

Filled Rectangle

Filled Rounded Rectangle

Filled Ellipse

Airbrush Shape

Pattern

Page 189: UG

C h a p t e r 1 3 , W o r k i n g w i t h g r a p h i c s 189

Choosing colorsYou can draw or paint with up to 256 different colors, which you can choose from a palette of over 16 million colors. However, the maximum number of colors that you can use at a given time depends on the type of graphic that you’re editing and the capabilities of your display device and driver. For example, if you’re editing a cursor or font, you can use black and white only. And if you’re editing a bitmap or icon, the maximum number of colors you can use is specified in the Colors property of the bitmap or icon. For information about changing the Colors property of a bitmap or icon, see the sections “Changing the properties of a bitmap” on page 196 and “Changing the properties of an icon” on page 197.

To view the capabilities of your display device and driver,

1 Edit a bitmap or icon.2 Choose Bitmap|Size And Attributes or Icon|Size And Attributes.3 Choose Device Info.

You can choose a foreground and background color. The foreground color is the color you draw with the left mouse button; the background color is the color you draw with the right mouse button.

To select the foreground color, click a color in the Colors palette.

To select the background color, right-click a color in the Colors palette.

In the Colors palette, the current foreground and background colors are denoted by the letters FG and BG respectively. The letters FB denote a color that is both the foreground and background color.

Choosing a color that represents a transparent or inverted areaWhen you’re editing an icon or cursor, you can choose the colors that represent transparent and inverted areas.

• A transparent area “drops out” at run time, allowing the color behind the icon or cursor to show through. Transparency is especially useful in cursors, where you rarely use the entire image area.

• The inverted area reverses the color behind the icon or cursor at run time. You can use an inverted area to make part of an icon or cursor visible at all times, regardless of the color beneath it.

Choosing a pen styleThe pen style affects the width of a line or shape border and whether a line or shape border is solid, dashed, or dotted.

To choose a pen style,

1 In the Tools palette, click the Pen Style tool.2 Choose a pen style.3 Click OK.

Page 190: UG

190 U s e r ’ s G u i d e

The pen style appears in the Pen Style tool.

Choosing a brush shapeYou can choose a brush shape for the Paintbrush or Airbrush tool.

To choose a brush shape,

1 Select the Paintbrush Shape or Airbrush Shape tool.2 Select a brush shape.3 Choose OK.

The brush shape appears in the Paintbrush Shape or Airbrush Shape tool.

Choosing a paint patternThe paint pattern affects the interior of a filled shape and the painting styles of the Airbrush and Paintbrush tools.

To choose a paint pattern,

1 Select the Paint Pattern tool.2 Select a paint pattern.3 Choose OK.

The paint pattern appears in the Paint Pattern tool.

Drawing and paintingYou can draw and paint with the Pen, Paintbrush, and Airbrush tools. The output of the Pen tool depends on the current pen style; the output of the Paintbrush and Airbrush tools depends on the current brush shape and paint pattern.

The Airbrush tool differs from the Paintbrush tool in that if you drag it slowly, the Airbrush tool paints a thick pattern, but it you drag it quickly, it paints a scattered, thinner pattern.

The size of the area covered by the Airbrush and Paintbrush tools is proportionate to the size of the Drawing Area. Therefore, you can zoom out to paint a larger area, and zoom in to paint 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.

To draw or paint,

1 In the Tools palette, select the Pen, Paintbrush, or Airbrush tool.

2 In the Drawing Area, move the cursor to where you want to start drawing, and then click and hold down the left mouse button (for the foreground color) or the right mouse button (for the background color).

3 Drag the cursor around the drawing area.

4 When you’re done drawing or painting, release the mouse button.Drawingtools

Page 191: UG

C h a p t e r 1 3 , W o r k i n g w i t h g r a p h i c s 191

Drawing a lineTo draw a line,

1 In the Tools palette, select the Line tool.

2 In the Drawing Area, move the cursor to where you want the line to start, 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 line with a 0-, 45-, or 90-degree angle, hold down Shift.

4 Move the cursor to where you want the line to end, and then release the mouse button.

Drawing a shapeYou 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.

4 Move the cursor to the opposite corner of the shape, and then release the mouse button.

Filling an area with colorYou can fill any area that is bounded by one or more different colors.

To fill an area with color,

1 In the Tools palette, select the Paint Can tool.

2 In the Drawing Area, move the crosshairs into the area that you want to fill, and then click the left mouse button (for the foreground color) or the right mouse button (for the background color).

Note Because of problems inherent in some display drivers, the Paint Can tool doesn’t always work properly. To solve this problem, you can use an alternative flood-filling algorithm that’s more reliable, but slower. To enable this algorithm, add the following line to the [RWS_Icon] section of the WORKSHOP.INI file:

RWS_OwnFloodFill=1

The following example shows an edited RWS_Icon section:

Line tool

Filledshape

tools

Paint Cantool

Page 192: UG

192 U s e r ’ s G u i d e

[RWS_Icon]RWS_OwnFloodFill=1PercentLeft=69ZoomLeft=8ZoomRight=1bVert=1

Adding textTo 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.

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

2 In the Drawing Area, move the cursor to a corner of the area you want to select, and then click and hold down the mouse button.

Text tool

Eraser tool

PickRectangle

tool

Page 193: UG

C h a p t e r 1 3 , W o r k i n g w i t h g r a p h i c s 193

3 Move the cursor to the opposite corner of the area you want to select and then release the mouse button.

To select a non-rectangular area,

1 In the Tools palette, select the Scissors tool.

2 In the Drawing Area, move the cursor to a boundary of the area you want to select, and then click and hold down the mouse button.

3 Draw a closed shape around the area you want to select, and then release the mouse button.

Aligning an areaYou 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.

Moving or resizing an areaTo move an area,

1 Select the area.2 Drag the area to a new location.

To move or resize an area,

1 Select the area.2 Choose Options|Size.3 To move the area, specify new pixel coordinates for the Top and Left sides.4 To resize the area, specify a new height and width.5 Click OK.

Note Any area left open is filled with the current background color.

Copying or removing an areaTo copy or remove an area, select the area, and then use the Edit|Copy, Edit|Paste, and Edit|Duplicate commands. (The Edit|Duplicate command is equivalent to choosing Edit|Copy and Edit|Paste.)

Note Any area left open is filled with the current background color.

Scissorstool

Page 194: UG

194 U s e r ’ s G u i d e

Zooming in on or out from a graphicTo zoom in on a graphic,

• In the Tools palette, double-click the Zoom tool. Or press Ctrl+Z. Or choose View|Zoom In.

To zoom in on a particular area of a graphic,

1 Select the Zoom tool.

2 In the Drawing Area, move the cursor to a corner of the area, and then click and hold down the mouse button.

3 Move the cursor to the opposite corner of the area and then release the mouse button.

To zoom out from a graphic,

• In the Tools palette, hold down Shift and then double-click the Zoom tool. Or press Ctrl+O. Or choose View|Zoom Out.

To view the actual size of a graphic,

• Press Ctrl+A. Or choose View|Actual size.

Moving a graphic around in the Drawing AreaIf a graphic is too large for the Drawing Area, you can move the graphic around to see its other parts.

To move a graphic around in the Drawing Area,

1 Hold down Ctrl.

The cursor becomes the Hand tool.

2 Drag the graphic to a new position.

You can also move a graphic around with the scroll bars on the right and bottom sides of the Drawing Area.

Note You can’t use the Hand tool and the Text tool at the same time.

Viewing an icon or cursor in another resolutionTo simulate the appearance of an icon or cursor in another screen resolution, choose the appropriate command from the View menu.

If you’re creating this type of icon or cursor

You can view the icon or cursor in this resolution By choosing this command

A 16x16 or 16x32 icon or a cursor with 1 bit per pixel

EGA/VGA View|EGA/VGA Resolution

Zoom tool

Page 195: UG

C h a p t e r 1 3 , W o r k i n g w i t h g r a p h i c s 195

To view the actual size of an icon or cursor, choose View|Actual Size.

Testing an icon or cursorTo test an icon or cursor, choose the Icon |Test or Cursor|Test command. When you test an icon, the Edit window for the icon is minimized and represented by the test icon. When you test a cursor, the Resource Workshop cursor becomes the test cursor.

To stop testing an icon, restore its Edit window by double-clicking the icon.

To stop testing a cursor, click anywhere.

Adding or removing an image from an icon or cursorIn general, you create a new icon resource for each icon design (called simply an icon), and you don’t put different icons in the same icon resource. However, it’s likely you’ll want to put different color formats of the same icon in one icon resource. These color variations on the same icon are called images. For example, if you want a 2-color and a 16-color version of the same design, you can store both versions in the same icon resource.

The reason the icon resource supports different color formats is that Windows picks a color format based on the ability of the display hardware to support the format. Windows picks a 2-color format for a monochrome display driver and a 16-color format for a standard Windows VGA driver.

To add a new image to an existing icon or cursor,

1 In the Project window, double-click the icon or cursor.

2 Choose Images|New Image.

3 If you’re creating a new icon image, specify the size and maximum number of colors. If you don’t know which size and color options to specify, accept the default values. For information about changing the size and color options, see the section “Changing the properties of an icon” on page 197.

4 If you’re creating a new cursor image, specify the bits per pixel. If you don’t know which option to specify, accept the default values. For information about changing the bits per pixel option, see the section “Changing the properties of a cursor” on page 196.

5 Choose OK.

To remove an image from an icon or cursor,

A 32x32 icon or a cursor with 4 bits per pixel

CGA View|CGA Resolution

A 64x64 icon or a cursor with 8 bits per pixel

CGA or VGA View|CGA Resolution or View|EGA/VGA Resolution

If you’re creating this type of icon or cursor

You can view the icon or cursor in this resolution By choosing this command

Page 196: UG

196 U s e r ’ s G u i d e

1 In the Image window for the icon or cursor, select the image that you want to remove.

2 Press Del.

Changing the properties of a bitmapYou can change the following properties of a bitmap:

• The height and width• Whether the bitmap is stored in a compressed format• The maximum number of colors for the bitmap• Whether the bitmap is stored in the Windows or OS/2 format

To change the properties of a bitmap,

1 Choose Bitmap|Size and Attributes.

2 To change the size of the bitmap, type the new height and width in the appropriate boxes.

3 If you changed the height or width, but you don’t want to stretch or compress the current bitmap into the new area, deselect the Stretch Current Bitmap box.

4 To save a 16- or 256-color bitmap in a compressed format, choose RLE 4 (for 16-color bitmaps) or RLE 8 (for 256-color bitmaps).

Note Some display drivers do not support RLE compression. Also, the RLE compression algorithm can increase the size of bitmaps that don’t have many adjacent pixels with the same color. For example, RLE compression might increase the size of a scanned photograph. Therefore, you should use RLE compression with caution.

5 In the Colors group, choose the maximum number of colors for the bitmap. Depending on the capabilities of your display device and driver, you might be limited to two or sixteen colors.

6 In the Format group, choose an operating system format for the bitmap. You can use the Windows or OS/2 formats.

7 Choose OK.

Changing the properties of a cursorYou can set the hot spot of a cursor. The hot spot is a single pixel from which the x- and y-coordinates of the cursor are determined. The location of the hot spot should be evident from the cursor image; for example, an arrow-shaped cursor should have its hot spot at the tip of the arrow.

Before you add a hot spot to a cursor, you should determine the exact coordinates for the hot spot. To pinpoint the coordinates, you can zoom in on the cursor, place a drawing tool over the pixel you want, and then note the coordinates in the status bar.

To set the hot spot,

Page 197: UG

C h a p t e r 1 3 , W o r k i n g w i t h g r a p h i c s 197

1 Choose Cursor|Set Hot Spot.2 Type the x- and y-coordinates for the hot spot.3 Choose OK.

Changing the properties of an iconYou can change the size of and the maximum number of colors for an icon:

1 Choose Icon|Size and Attributes.

2 In the Size box, choose the size of the icon in pixels.

3 In the Colors box, choose the maximum number of colors for the icon. Depending on the capabilities of your display device and driver, you may be limited to two or sixteen colors.

4 Choose OK.

Changing the properties of a fontYou can change the following properties of a font:

• General properties, such as copyright and version information• The height and width of the characters• The number of characters• The ANSI codes for the characters

Changing the general properties of a fontTo change the general properties of a font,

1 Choose Font|Header.

2 Specify any of the following options:

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

Page 198: UG

198 U s e r ’ s G u i d e

Changing the height and width of the characters in a fontTo change the height and width of characters in a font,

1 Choose Font|Font Size.

2 In the Width box, type the width of the font. Type 0 if the width of the characters in the font can vary. (Variable-width fonts usually take less space and are more pleasing to the eye than fixed-width fonts.)

3 In the Height box, type the height of the font.

4 If you typed 0 for the width, type the maximum width of the characters in the font.

5 If you changed the height or width of the font, and you want to stretch or compress the existing characters into the new area, select the Stretch Current Characters box.

6 Choose OK.

If you use the Font|Font Size command to specify that the width of characters in a font can vary, you can change the width of each character in the font.

To change the width of a single character in a font,

1 Select the character in the right border of the Edit window.

2 Choose Font|Font Character Width.

3 Type a new width for the character.

4 If you want to stretch or compress the existing character into the new area, select the Stretch Current Char box.

5 Choose OK.

Changing the ANSI codes of the characters in a fontThe ANSI values to which you map a set of bitmapped images are arbitrary, but must be in the range 0 to 255. These ANSI values become important when you load the font in

Char Set Defines the character set. The value can be 0 through 255. 0, 2, and 255 have the following predefined meanings: ANSI, the default Windows character set (0); Symbol, used for math and scientific formulas (2); OEM, a machine-specific character set (255).

Horz Res Horizontal number of pixels per logical inch on your video display.Vert Res Vertical number of pixels per logical inch on your video display.Points Type size. A point is 1/72 of an inch. A character is measured from the top of the

ascender to the bottom of the descender. The value you enter here should not include space for diacritical marks.

Internal Leading

The space in pixels reserved for diacritical marks.

External Leading

The additional space in pixels between lines of characters.

Ascent The height in pixels of the character above the baseline.

Option Description

Page 199: UG

C h a p t e r 1 3 , W o r k i n g w i t h g r a p h i c s 199

your program and display the bitmaps; you use the ANSI value that corresponds to a bitmap to display it, the same as you would use an ANSI value to display a character.

To change the ANSI codes of the characters in a font,

1 Choose Font|Font Size.

2 In the First box, type the ANSI code for the first character in the font.

3 In the Last box, type the ANSI code for the last character in the font.

4 In the Default box, type the ANSI code for the character that appears first when you load the font into the Graphic editor.

5 In the Break box, type the ANSI code for the break character. (The break character, typically a space, is used to pad justified lines.)

6 Choose OK.

Changing the number of characters in a fontTo change the number of characters in a font, change the ANSI code for the first or last character in the font. (This procedure is described in the previous section.) The number of characters in the font equals the difference between the ANSI codes of the first and last characters.

Editing a specific character in a fontWhen you load a font into the Graphic editor, the first character of the font appears automatically in the Edit window. To bring another character into the Edit window, click the character in the right border of the Edit window.

For more information about fonts, see the section “Changing the properties of a font” on page 197.

Customizing the Graphic editorYou can customize the Graphic editor by

• Adding or removing a second pane from the Edit window

• Hiding or showing the Colors and Tools palettes

• Changing a color on the Colors palette

• Specifying whether the Colors palette is saved when you exit Resource Workshop

• Specifying whether a grid appears in the Drawing Area when you zoom in on a graphic

Adding or removing a second pane from the Edit windowIn the Graphic editor, you can look at two different views of the image you’re creating or editing. You can split the window vertically or horizontally to show the two views

Page 200: UG

200 U s e r ’ s G u i d e

side-by-side or one view above the other. You can also choose how to zoom in on or out from each view.

To split the window, choose View|Split Horizontal or View|Split Vertical.

When the window is split, one of the panes is active. The active pane is the one in which you’re working. To make a pane active, click it.

To see more of one pane than the other, move the cursor to the line that splits the images (the separator bar) and, when the cursor becomes a double arrow, drag the separator bar.

To use a single-pane view, drag the separator bar to the far left or right (for a vertical split) or to the top or bottom (for a horizontal split).

If you add a second pane to the Edit window, you can specify whether changes are reflected in the inactive pane while you draw or paint or when you release the mouse button after drawing or painting.

To specify when changes are reflected in the inactive pane,

1 Choose Options|Editor Options.2 Select or deselect the Draw on Both Images box.3 Choose OK.

Hiding or showing the Tools and Colors palettesTo hide the Tools or Colors palette, double-click the System menu in the upper left corner of the palette.

You can also hide the Tools or Colors palette by choosing the Hide Toolbox or Hide Palette command. The name of the menu where you’ll find this command depends on the type of resource you’re currently editing. For example, if you’re editing an icon, the Hide Palette command is in the Icon menu. If you’re editing a cursor, the menu is in the same position on the menu bar, but it is called the Cursor menu.

To show the Tools or Colors palette, choose the Show Palette or Show Toolbox command on the appropriate menu.

Changing a color on the Colors paletteTo change a color on the Colors palette,

1 In the Colors palette, double-click the color.

2 In the Red, Green, and Blue boxes, type values from 0 to 255 to indicate the intensities of each color. (The colors are mixed together to form the new color.)

3 To return the color to its default value, choose Default (if your display device and drive doesn’t support 256 colors) or System (if your display device and driver does support 256 colors).

4 Choose OK.

Note You can’t change the Colors palette when you’re editing a font or cursor.

Page 201: UG

C h a p t e r 1 3 , W o r k i n g w i t h g r a p h i c s 201

Specifying whether the Colors palette is savedTo specify whether the Colors palette is saved when you exit Resource Workshop,

1 Choose Options|Editor Options.

2 Select or deselect the Save with default colors box. (If you deselect the box, any changes you make to the Colors palette will be saved when you exit Resource Workshop.)

3 Choose OK.

Specifying whether a grid appears when you zoom inTo specify whether a grid appears in the Drawing Area when you zoom in on a graphic,

1 Choose Options|Editor Options.2 Select or unselect the Grid on Zoomed Windows box.3 Choose OK.

Note The grid may not appear if you’re using 256 colors.

Using a graphic resource in an applicationYou can include graphics in an application using OWL or the Windows API.

Programming a bitmap with OWLTo program a bitmap with OWL, use the TBitmap, TDip, TDibDC, and TClientDC classes. For example, the following code displays a bitmap in the center of the main window.

TBitmap bitmap1(GetInstance(), IDB_BITMAP1);TDib dib1(bitmap1);TDibDC DibDC1(dib1);TClientDC mainWindowDC(GetMainWindow()->HWindow);int centerX = GetMainWindow()->Attr.W / 2;int centerY = GetMainWindow()->Attr.H / 2;int bitmapX = bitmap1.Width();int bitmapY = bitmap1.Height();mainWindowDC.BitBlt(centerX-bitmapX/2, centerY-bitmapY/2, bitmapX, bitmapY, dibDC1, 0, 0,

SRCCOPY);

In the preceding code, IDB_BITMAP1 is the identifier for the bitmap.

For more information about programming a bitmap with OWL, see the ObjectWindows Programmer’s Guide.

Page 202: UG

202 U s e r ’ s G u i d e

Programming an icon with OWLTo program an icon with OWL, use the TFrameWindow::SetIcon function. For example, the following code assigns an icon to the main window.

GetMainWindow()->SetIcon(this, IDC_ICON1);

In the preceding code, IDC_ICON1 is the identifier for the icon.

For more information about programming an icon with OWL, see the ObjectWindows Programmer’s Guide.

Programming a cursor with OWLTo program a cursor with OWL, use the TWindow::SetCursor function. For example, the following code assigns a cursor to the main window.

GetMainWindow()->SetCursor(this, IDC_CURSOR1);

In the preceding code, IDC_CURSOR1 is the identifier for the cursor.

For more information about programming a cursor with OWL, see the ObjectWindows Programmer’s Guide.

Programming a bitmap with the Windows APITo program a bitmap the Windows API, use the LoadBitmap, GetObject, GetDC, CreateCompatibleDC, BitBlt, DeleteDC, and ReleaseDC functions. For example, the following code displays a bitmap in the window represented by the HWnd variable.

HINSTANCE hInst;HWND hWnd;HDC hDC, hDCMemory;HBITMAP hBitmap, hTempBitmap;BITMAP bitmap;// Get the bitmap resource and its handle.hBitmap = LoadBitmap(hInst, MAKEINTRESOURE(IDB_BITMAP1);// Get the bitmap data.GetObject(hBitmap, sizeof(BITMAP), &bitmap);// Get the device context of the target window.hDC = GetDC(hWnd);// Create a compatible memory device contexthDCMemory = CreateCompatibleDC(hDC);// Copy the bitmap into the memory device context.hTempBitmap = SelectObject(hDCMemory, hBitmap);// Copy the bitmap into the device context of the target window.BitBlt(hDC, 0, 0, bitmap.bmWidth, bitmap.bmHeight, hDCMemory, 0, 0, SRCCOPY);// Clean up and exit.SelectObject(hDCMemory, hTempBitmap);DeleteDC(hDCMemory);ReleaseDC(hWnd, hDC);

In the preceding code, IDB_BITMAP1 is the identifier for the bitmap.

Page 203: UG

C h a p t e r 1 3 , W o r k i n g w i t h g r a p h i c s 203

For more information about programming a bitmap with the Windows API, search the Windows 3.1 SDK Help file (WIN31WH.HLP) for “Bitmap Functions.”

Programming an icon with the Windows APITo program an icon with the Windows API, use the LoadIcon function. For example, the following code loads an icon resource into a variable.

HICON hIcon;hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDD_ICON1)

In the preceding code, IDD_ICON1 is the identifier for the icon.

For more information about programming an icon with the Windows API, search the Windows 3.1 SDK Help file (WIN31WH.HLP) for “Icon Functions.”

Programming a cursor with the Windows APITo program a cursor with the Windows API, use the LoadCursor and SetCursor functions. For example, the following code changes the active cursor.

HCURSOR hCursor;hCursor = LoadCursor(hInst, MAKEINTRESOURCE(IDD_CURSOR1)SetCursor(hCursor)

In the preceding code, IDD_CURSOR1 is the identifier for the cursor.

For more information about programming a cursor with the Windows API, search the Windows 3.1 SDK Help file (WIN31WH.HLP) for “Cursor Functions.”

Page 204: UG

204 U s e r ’ s G u i d e

Page 205: UG

C h a p t e r 1 4 , W o r k i n g w i t h v e r s i o n i n f o r m a t i o n a n d c u s t o m d a t a t y p e s 205

C h a p t e r

14Chapter 14Working with version information

and custom data typesYou can define your own resource types to contain data that doesn’t fit into one of the standard resource types described in Chapters 10–13. For example, to create a string that’s longer than 255 characters, you can define your own resource type and store your long strings there.

You can also include metafiles in your project as user-defined resources. A metafile is a graphic—in source form, it’s made up of a collection of Graphics Device Interface (GDI) calls. Metafiles are easier to scale and more device-independent than standard bitmaps, and often require less memory than a bitmap resource.

Like other resources, you define version information or a custom data type in a resource script. This chapter describes how to edit resource scripts for version information and custom data types, and how to use the corresponding resources in an application.

Creating a custom data typeTo create a custom data type,

1 Choose Resource|New.2 Choose New Type.3 Type the name of the new data type.4 Choose OK.5 Choose Yes to create a new identifier.6 Type a value for the identifier.7 In the File box, choose a header file in which to store the identifier.8 Choose OK.

Page 206: UG

206 U s e r ’ s G u i d e

Editing a resource script for version informationor 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.

Editing a resource script for version informationA resource script for version information has the following syntax:

versionID VERSIONINFO fixed-info {

block-statements}

The versionID parameterThe version ID parameter is the resource identifier. It must be set to 1.

The fixed-info parameterThe fixed-info parameter specifies version information about the file to which the version information resource is linked. It consists of the following statements:

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.

Page 207: UG

C h a p t e r 1 4 , W o r k i n g w i t h v e r s i o n i n f o r m a t i o n a n d c u s t o m d a t a t y p e s 207

The block-statements parameterThe block-statements parameter specifies string or variable information about the file to which the version information resource is linked.

A string information blockA string information block has the following syntax:

BLOCK "StringFileInfo" {

BLOCK "lang-charset" VALUE "string-name", "value" ƒ}

}

A string information block has the following parameters:

A variable information blockA variable information block has the following syntax:

BLOCK "VarFileInfo" {

VALUE "Translation",langID, charsetID

ƒ}

A variable information block has the following parameters.

FILETYPE filetype A file type. Use any of the filetype constants, which are described in the constants section. All other values are reserved.

FILESUBTYPE subtype The function of a file. The subtype parameter is 0 unless the FILETYPE statement is FILETYPE VFT_DRV, VFT_FONT, or VFT_VXD. Use any of the subtype constants, which are described in the section “Constants” on page 208.

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.

Parameter Description

Page 208: UG

208 U s e r ’ s G u i d e

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

fileflagsYou can specify the following constants for the fileflags parameter:

fileosYou can specify the following constants for the fileos parameter:

filetypeYou can specify any of the following constants for the filetype 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.

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.

Constant Description

VFT_UNKNOWN File type is unknown to Windows. VFT_APP File contains an application. VFT_DLL File contains a dynamic-link library.

Page 209: UG

C h a p t e r 1 4 , W o r k i n g w i t h v e r s i o n i n f o r m a t i o n a n d c u s t o m d a t a t y p e s 209

subtypeIf the FILETYPE statement specifies VFT_DRV, you can specify any of the following constants for the subtype parameter:

If the FILETYPE statement specifies VFT_FONT, you can specify any of the following constants for the subtype parameter:

If the FILETYPE statement specifies VFT_VXD, you can’t specify a value for the subtype statement.

langIDYou can specify any of the following constants for the langID parameter:

VFT_DRV File contains a device driver. If you use this constant, include a more specific description of the driver in FILESUBTYPE.

VFT_FONT File contains a font. If you use this constant, include a more specific description of the font file in FILESUBTYPE.

VFT_VXD File contains a virtual device. If you use this constant, include a more specific description of the device in FILESUBTYPE.

VFT_STATIC_LIB File contains a static-link library.

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.

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.

Constant Description Constant Description

0x0401 Arabic 0x0418 Romanian 0x0402 Bulgarian 0x0419 Russian 0x0403 Catalan 0x041A Croato-Serbian (Latin)

Constant Description

Page 210: UG

210 U s e r ’ s G u i d e

charsetIDYou can specify any of the following constants for the charsetID parameter:

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

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 Constant Description

Page 211: UG

C h a p t e r 1 4 , W o r k i n g w i t h v e r s i o n i n f o r m a t i o n a n d c u s t o m d a t a t y p e s 211

string-nameYou can specify any of the following constants for the string-name parameter:

Editing a resource script for a custom data typeA resource script for a custom data type has the following syntax:

resource-name type-ID [load-type] [memory-option] filename{

block-statements}

The resource-name parameterThe resource-name parameter sets the identifer for the resource.

The type-ID parameterThe type-ID parameter sets the resource type. You must set the type-ID to a number greater than 255. (Numbers 1 to 255 are reserved by Windows for predefined resource types and future expansion.)

The load-type parameterThe way in which the resource is loaded into memory. You can set the load-type parameter to

• PRELOAD, which means the resource is loaded when its application starts.• LOADONCALL, which means the resource is loaded when it is needed.

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.

Page 212: UG

212 U s e r ’ s G u i d e

The filename parameterThe 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.

The block-statements parameterYou can specify string or variable blocks. For more information, see the section “Editing a resource script for version information” on page 206.

Entering data in a resource scriptHere are some guidelines for specifying data between the begin ({) and end (}) parameters:

• The data can include any combination of numeric values and strings.

• You can use hexadecimal, octal, or decimal notation to represent numeric values.• Use 0x (a zero followed by the letter x) or $ (a dollar sign) as the leading characters

for hexadecimal notation. This notation supports only 16-bit values. If you want to use an odd number of hexadecimal values, use the hexstring data type (described in the next bullet).

• Use 0o (a zero followed by the letter o) or just 0 (zero) as the leading characters for octal notation.

• You can also represent hexadecimal values by using a hexstring of hexadecimal values enclosed in single quotation marks. The compiler ignores any spaces you insert to make the hex codes more readable. For example, you could represent the ASCII values of the characters in the word string as '73 74 72 69 6E 67' and the hex number 06E07A as '06E07A'.

• If you include text strings in your resource, enclose the strings in quotation marks, like this: "string". Strings aren’t automatically null terminated. To terminate a string with a null character, type \0 (backslash zero) at the end of the string.

For example, here’s what a resource script might look like:

RESTYPE_1 RESTYPE{

"This is a string."0xFFAA 0o7076 01077'54 68 69 73 20 69 73 0D 0A 73 6F 6D 65 20 73 61''6D 70 6C 65 0D 64 61 74 61 2E'

}

Compiling a resource scriptYou can compile a resource script by choosing Compile|Compile Now or by pressing Alt+F9.

Page 213: UG

C h a p t e r 1 4 , W o r k i n g w i t h v e r s i o n i n f o r m a t i o n a n d c u s t o m d a t a t y p e s 213

If there’s a compilation error, Resource Workshop displays an error message. Read the error message and click OK when you’re done. Resource Workshop puts you back into the Script editor so that you can fix the error.

Using a version information resource in an applicationTo include a version information resource in an application, use any of the version functions. For information about the version functions, search the Windows 3.1 SDK Help file (WIN31WH.HLP) for “Version Functions (3.1).”

For example, the following code loads the loads version information data into variables.

LPBYTE companyName;char appFileName[255];BYTE versionInfoData[1024];DWORD versionInfoHandle;UINT dwSize;UINT vSize;LPBYTE translationBlock;char blockName[255]'GetModuleFileName(hInst, appFileName, sizeof(appFileName));dwSize = (UINT) ::GetFileVersionInfoSize(appFileName, &versionInfoHandle);if (dwSize) {

::GetFileVersionInfo(appFileName, versionInfoHandle, dwSize, versionInfoData);strcpy(blockName, "\\VarFileInfo\\Translation");::VerQueryValue(versionInfoData, blockName, (void FAR* FAR*) &translationBlock,

&vSize);*(DWORD *)translationBlock = MAKELONG(HIWORD(*(DWORD *)translationBlock), LOWORD(*(DWORD *)translationBlock));wsprintf(blockName, "\\StringFileInfo\\%081x\\CompanyName", *(DWORD *)translationBlock);::VerQueryValue(versionInfoData, blockName (void FAR* FAR*) &companyName, &vSize);

}

Using a resource for a custom data type in an applicationTo include a custom data type resource in an application, use the FindResource, LockResource, and UnlockResource functions. For example, the following code loads and unloads a resource for a custom data type.

HRSRC hRCData;HGLOBAL hRCDataMem;BYTE * pRCDataMem;// Get a handle for the resource.hRCData = FindResource(hInst, MAKEINTRESOURCE(IDR_CUSTOM1);// Load the resource into global memory.hRCDataMem = LoadResource(hInst, hRCData);// Lock the resource into memory so it can be used.pRCDataMem = (BYTE*)LockResource(hRCDataMem);// Replace this line with code that uses the resource.// Unlock and free the memory used by the resource.

Page 214: UG

214 U s e r ’ s G u i d e

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).”

Page 215: UG

A p p e n d i x A , U s i n g E a s y W i n 215

A p p e n d i x

AAppendix AUsing EasyWin

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”

Example C program Example C++ program

#include <stdio.h>int main (){printf("Hello DOS!\n");return 0;

}

#include <iostream.h>int main(){cout << "Hello DOS!\n";return 0;

}

Page 216: UG

216 U s e r ’ s G u i d e

Windows program. For example, you might want to add printf functions to your program code to help you debug your Windows program.

To use EasyWin from within a Windows program, make a call to the _InitEasyWin function before doing any standard input or output. For example,

#include <windows.h>#include <stdio.h>

#pragma argsusedint PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine, int cmdShow){

_InitEasyWin();

/* Normal windows setup */printf("Hello, Windows!\n");return 0;

}

Note You can find the prototype for _InitEasyWin in stdio.h and iostream.h.

Added functionsEasyWin 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.

clreolclrscrgotoxy

(conio.h)(conio.h)(conio.h)

wherexwherey

(conio.h)(conio.h)

fgetchargetchgetchargetchegetskbhitperror

(stdio.h)(stdio.h)(stdio.h)(stdio.h)(stdio.h)(conio.h)(errno.h)

printfputchputcharputsscanfvprintfvscanf

(stdio.h)(conio.h)(stdio.h)(stdio.h)(stdio.h)(stdio.h)(stdio.h)

Page 217: UG

A p p e n d i x B , P r e c o m p i l e d h e a d e r s 217

A p p e n d i x

BAppendix BPrecompiled headers

Turbo C++ can generate and subsequently use precompiled headers for your projects. Precompiled headers can greatly speed up compilation times.

How they workWhen compiling large C and C++ programs, the compiler can spend up to half of its time parsing header files. When the compiler parses a header file, it enters declarations and definitions into its symbol table. If ten of your source files include the same header file, this header file is parsed ten times, producing the same symbol table every time.

Precompiled header files cut this process short. During one compilation, the Turbo C++ compiler creates and stores an image of the symbol table on disk. This file is called BCDEF.CSM by default, and is stored in the same directory as the compiler. Then, if the header file is used again, the compiler reloads BCDEF.CSM from disk, instead of parsing all the header files again. Directly loading the symbol table from disk is over ten times faster than parsing the text of the header files.

Precompiled headers are used only if the following compilations use one or more of the same header files, the same compiler options, defined macros and so on, as the first compilation.

If, while compiling a source file, Turbo C++ discovers that the first #includes are identical to those of a previous compilation (of the same source or a different source), it loads the binary image for those #includes and parses the remaining #includes.

For a given module, either all or none of the precompiled headers are used: if compilation of any included header file fails, the precompiled header file isn’t updated for that module.

Page 218: UG

218 U s e r ’ s G u i d e

DrawbacksWhen using precompiled headers, BCDEF.CSM can become very big because it contains symbol table images for all sets of includes encountered in your sources. If you don’t have sufficient disk space, you’ll get a warning saying the write failed because of the precompiled headers. To fix this, free more disk space and retry the compile. For information on reducing the size of the BCDEF.CSM file, see “Optimizing precompiled headers” on page 219.

If you’re using large macros in a makefile in addition to using precompiled headers, there is a limit of 4K on the macro size.

If a header contains any code, it can’t be precompiled. For example, although C++ class definitions can appear in header files, you should ensure that only inline member functions are defined in the header and heed warnings such as “Functions containing reserved word are not expanded inline.”

Using precompiled headersYou can control the use of precompiled headers in any of the following ways:

• From within the IDE, using the Project Options dialog box. The IDE bases the name of the precompiled header file on the project name, creating PROJECT.CSM.

• From the command line, using the following options: –H=filename, –Hc, –H”filename” and –Hu (see “Precompiled headers” on page 48 for more information).

• From within your code, using the pragmas hdrfile and hdrstop (see the Turbo C++ Programmer’s Guide).

Setting file namesThe compiler uses just one file to store all precompiled headers. The default file name is BCDEF.CSM. You can explicitly set the name with the –H=filename command-line option or the #pragma hdrfile directive.

Caution! If you notice that your .CSM file is smaller than it should be, the compiler might have run out of disk space when writing to the .CSM file. When this happens, the compiler deletes the .CSM to make room for the .OBJ file, then starts creating a new (and therefore shorter) .CSM file. If this happens, free up some disk space before compiling.

Establishing identityTo 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

Page 219: UG

A p p e n d i x B , P r e c o m p i l e d h e a d e r s 219

• Use header files with identical time stamps; these header files can be included either directly or indirectly

In addition, the following options settings must be identical to those used when the precompiled header was generated:

• Memory model, including SS != DS (–mx)• Underscores on externs (–u)• Maximum identifier length (–iL)• Target DOS (default) or Windows (–W or –Wx)• DOS overlay-compatible code (–Y)• Virtual table control (–Vx and –Vmx)• Expand intrinsic functions inline (–Oi)• Templates (–Jx)• String literals in code segment (–dc, 16-bit only)• Debugging information (–v, –vi, and –R)• Far variables (–Fx)• Generate word alignment (–a)• Pascal calls (–p)• Treat enums as integers (–b)• Default char is unsigned (–K)• Language compliance (–A)• C++ compile (–P)

Optimizing precompiled headersFor the most efficiently compiled precompiled headers, follow these rules:

• Arrange your header files in the same sequence in all source files.

• Put the largest header files first.

• Prime BCDEF.CSM with often-used initial sequences of header files.

• Use #pragma hdrstop to terminate the list of header files at well-chosen places. This lets you make the list of header files in different sources look similar to the compiler.

For example, given the two source files ASOURCE.C and BSOURCE.C, both of which include windows.h and myhdr.h,

\* ASOURCE.C *\#include <windows.h>#include "myhdr.h"#include "xxx.h"<...>

\* BSOURCE.C *\#include "yyy.h"#include <string.h>#include "myhdr.h"#include <windows.h><...>

Page 220: UG

220 U s e r ’ s G u i d e

you would rearrange the beginning of BSOURCE.C to

\* Revised BSOURCE.C *\#include <windows.h>#include "myhdr.h"#include "yyy.h"#include <string.h><...>

Note that windows.h and myhdr.h are in the same order in BSOURCE.C as they are in ASOURCE.C. You could also make a new source called PREFIX.C containing only the header files, like this:

\* PREFIX.C*\#include <windows.h>#include "myhdr.h"

If you compile PREFIX.C first (or insert a #pragma hdrstop in both ASOURCE.C and BSOURCE.C after the #include "myhdr.h" statement), the net effect is that after the initial compilation of PREFIX.C, both ASOURCE.C and BSOURCE.C will be able to load the symbol table produced by PREFIX.C. The compiler will then only need to parse xxx.h for ASOURCE.C and yyy.h and string.h for BSOURCE.C.

Page 221: UG

A p p e n d i x C , E r r o r m e s s a g e s 221

A p p e n d i x

CAppendix CError messages

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 classesMessages fall into three categories: fatal errors, errors, and warnings.

Fatal errorsFatal 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.

Page 222: UG

222 U s e r ’ s G u i d e

ErrorsErrors can be generated by the compiler, the linker, and the librarian. In addition, errors can be generated by your program at run time.

Errors generated by the compiler indicate program syntax errors, command-line errors, and disk or memory access errors. Compiler errors don’t cause the compilation to stop—the compiler completes the current phase of the compilation and then stops and reports the errors encountered. The compiler attempts to find as many real errors in the source program as possible during each phase (preprocessing, parsing, optimizing, and code-generating).

Errors generated by the linker don’t cause the linker to delete the .EXE or .MAP files. However, you shouldn’t execute any .EXE file that was linked with errors. Linker errors are treated like fatal errors.

Run-time errors are usually caused by logic errors in your program code. If you receive a run-time error, you must fix the error in your source code and recompile the program for the fix to take effect.

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

Help compiler messagesThe Help compiler displays messages when it encounters errors or warnings while building the Help resource file. Messages generated during the processing of the project file begin with the letter P and are followed by an error number. Messages that occur during the processing of the RTF topic file(s) begin with the letter R and are followed by an error number.

Whenever possible, the Help compiler displays the topic number and/or the file name that contains the error. If you’ve numbered your topics, the topic number is given with an error message that refers to that topic’s sequential position in your RTF file (first, second, and so on). These numbers might be identical to the page number shown by your word processor. In your Help source files, topics are separated by hard page breaks even though there are no “pages” in the Help system.

Messages beginning with the word “Error” are fatal errors. Errors are always reported, and no usable Help resource file will result from the build. Messages beginning with the word “Warning” are less serious in nature. A build with warnings produces a valid Help resource file that loads under Windows, but the file might contain operational errors.

Page 223: UG

A p p e n d i x C , E r r o r m e s s a g e s 223

Message listingsMessages are written with the message class first, followed by the source file name and line number where the error was detected, and finally with the text of the message itself.

Some messages include a symbol (such as a variable, file name, or module) that is taken from your program. Symbols in the message explanations are shown in italics to indicate that they’re variable in nature.

Be aware that the compiler generates messages as they are detected. Because C and C++ don’t force any restrictions on placing statements on a line of text, the true cause of the error might be one or more lines before or after the line number mentioned in the error message.

Message explanations‘)’ missing in macro invocation MAKE error

A left parenthesis is required to invoke a macro.

( expected Compiler errorA left parenthesis was expected before a parameter list.

) expected Compiler errorA right parenthesis was expected at the end of a parameter list.

, expected Compiler errorA comma was expected in a list of declarations, initializations, or parameters.

: expected after private/protected/public Compiler errorWhen used to begin a private/protected/public section of a C++ class, these reserved words must be followed by a colon.

< expected Compiler errorThe 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 errorA new-style cast (for example, dynamic_cast) is missing a closing “>”.

@ seen, expected a response-files name Librarian errorThe response file is not given immediately after @.

{ expected Compiler errorA left brace ( { ) was expected at the start of a block or initialization.

} expected Compiler errorA right brace ( } ) was expected at the end of a block or initialization.

16-bit segments not supported in module module Linker error16-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 errorUse 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 errorAn object file that contains 80386 32-bit records was encountered, and the /3 option had not been used.

Abnormal program termination Run-time errorThe program called abort because there wasn’t enough memory to execute. This can happen as a result of memory overwrites.

Page 224: UG

224 U s e r ’ s G u i d e

Access can only be changed to public or protected Compiler errorA C++ derived class can modify the access rights of a base class member, but only to public or protected. A base class member cannot be made private.

Added file filename does not begin correctly, ignored Librarian warningThe librarian has decided that the file being added is not an object module, so it will not try to add it to the library. The library is created anyway.

Address of overloaded function function doesn’t match type Compiler errorA variable or parameter is assigned/initialized with the address of an overloaded function, and the type of the variable/parameter doesn’t match any of the overloaded functions with the specified name.

Alias alias defined in module module is redefined Linker warningAn ALIAS definition record specified a public symbol substitute that was already defined by another ALIAS. The second public symbol substitute will be used. ALIAS records are generated by the assembler when the ALIAS directive is used.

module already in LIB, not changed! Librarian warningAn attempt to use the + action on the library has been made, but there is already an object with the same name in the library. If an update of the module is desired, the action should be +–. The library has not been modified.

Ambiguity between function1 and function2 Compiler errorBoth of the named overloaded functions could be used with the supplied parameters. This ambiguity is not allowed.

Ambiguous member name name Compiler errorA structure member name used in inline assembly must be unique. If it is defined in more than one structure all of the definitions must agree in type and offset within the structures. The member name in this case is ambiguous. Use the syntax (struct xxx).yyy instead.

Ambiguous Override of Virtual Base Member func1: func2 Compiler errorA virtual function in a virtual base class was overridden with two or more different functions along different paths in the inheritance hierarchy.

Ambiguous operators need parentheses Compiler warningThis warning is displayed whenever two shift, relational, or bitwise-Boolean operators are used together without parentheses. Also, an addition or subtraction operator that appears unparenthesized with a shift operator will produce this warning. Programmers frequently confuse the precedence of these operators.

Ambiguous override of virtual base member base_function: derived_function Compiler errorThis error message is issued when a virtual function that is defined in a virtual base class is overridden with different functions having two derived classes in the same inheritance hierarchy. For example,

struct VB{

virtual f();};

struct A:virtual VB{

virtual f();};

struct B:virtual VBvirtual f();

};

Page 225: UG

A p p e n d i x C , E r r o r m e s s a g e s 225

struct D:A,B{} //errors here

The previous code will be flagged with the following errors:

Error: Ambiguous override of virtual base member VB::f():A::f()Error: Ambiguous override of virtual base member VB::f():B::f()

Application load & execute error 0001 Compiler errorApplication load & execute error FFE0 Compiler error

There was insufficient extended memory available for the protected-mode command-line tool to load.

Array allocated using new may not have an initializer Compiler errorWhen initializing a vector (array) of classes, you must use the default constructor (the constructor that has no arguments).

Array bounds missing ] Compiler errorYour source file declared an array in which the array bounds were not terminated by a right bracket.

Array must have at least one element Compiler errorANSI C and C++ require that an array be defined to have at least one element (objects of zero size are not allowed). An old programming trick declares an array element of a structure to have zero size, then allocates the space actually needed with malloc. You can still use this trick, but you must declare the array element to have (at least) one element if you are compiling in strict ANSI mode. Declarations (as opposed to definitions) of arrays of unknown size are still allowed.For example,

char ray[]; /* definition of unknown size -- illegal */char ray[0]; /* definition of 0 size -- illegal */extern char ray[]; /* declaration of unknown size -- ok */

Array of references is not allowed Compiler errorIt is illegal to have an array of references because pointers to references are not allowed and array names are coerced into pointers.

Array size for ‘delete’ ignored Compiler warningWith the latest specification of C++, it is no longer necessary to specify the array size when deleting an array; to allow older code to compile, Turbo C++ ignores this construct and issues this warning.

Array size too large Compiler errorThe declared array is larger than 64K.

Array variable identifier is near Compiler warningWhenever you use either the –Ff or –Fm command-line options to set threshold limit, global variables larger than the threshold size are automatically made far by the compiler. However, when the variable is an initialized array with an unspecified size, its total size is not known when the decision whether to make it near or far has to be made by the compiler, and so it is made near. If the number of initializers given for the array causes the total variable size to exceed the data size threshold, the compiler issues this warning. If problems are caused by having the variable made near (for example, if the linker reports a group overflow due to too much global data), you must make the offending variable explicitly far by inserting the keyword far immediately to the left of the variable name in its definition.

Assembler stack overflow Compiler errorThe assembler ran out of memory during compilation. Review the portion of code flagged by the error message to ensure that it uses memory correctly.

Assembler statement too long Compiler errorInline assembly statements cannot be longer than 480 bytes.

Assigning type to enumeration Compiler warningAssigning an integer value to an enum type. This is an error in C++, but is reduced to a warning to give existing programs a chance to work.

Assignment to this not allowed, use X::operator new instead Compiler errorIn early versions of C++, the only way to control allocation of a class of objects was to use the this parameter inside a constructor. This practice is no longer allowed because a better, safer, and more general technique is to instead define a member function operator new.

Page 226: UG

226 U s e r ’ s G u i d e

Attempt to export non-public symbol symbol Linker errorThis error usually occurs when a .DEF file specifies an EXPORT for a symbol that you either forgot to define or misspelled.

Attempt to grant or reduce access to identifier Compiler errorA C++ derived class can modify the access rights of a base class member, but only by restoring it to the rights in the base class. It cannot add or reduce access rights.

Attempting to return a reference to a local object Compiler errorIn a function returning a reference type, you attempted to return a reference to a temporary object (perhaps the result of a constructor or a function call). Because this object will disappear when the function returns, the reference will then be illegal.

Attempting to return a reference to local variable identifier Compiler errorThis C++ function returns a reference type, and you are trying to return a reference to a local (auto) variable. This is illegal because the variable referred to disappears when the function exits. You can return a reference to any static or global variable, or you can change the function to return a value instead.

Automatic data segment exceeds 64K Linker errorThe sum of the DGROUP physical segment, local heap, and stack exceeds 64K. Fix this by specifying smaller values for the HEAPSIZE and STACKSIZE statements in the module definition file or by decreasing the size of the near data in DGROUP. The map file shows the sizes of the component segments in DGROUP. The /s TLINK command-line option is useful for determining how much each module contributes to DGROUP.

Bad call of intrinsic function Compiler errorYou have used an intrinsic function without supplying a prototype, or you supplied a prototype for an intrinsic function that was not what the compiler expected.

Bad character in parameters –> char Linker errorOne of the following characters (or any control character other than horizontal tab, linefeed, carriage return, or Ctrl+Z) was encountered in the command line or in a response file:

" * < = > ? [ ] |

Bad define directive syntax Compiler errorA macro definition starts or ends with the ## operator, or contains the # operator that is not followed by a macro argument name.

Bad field list in debug information in module module Linker errorThis is typically caused by bad debug information in the OBJ file. Borland Technical Support should be informed.

Bad file name filename Linker errorAn invalid file name was passed to the linker.

Bad file name format in include directive Compiler errorInclude file names must be surrounded by quotes (“filename.h”) or angle brackets (<filename.h>). The file name was missing the opening quote or angle bracket. If a macro was used, the resulting expansion text is incorrect; that is, it is not surrounded by < > or “ ”.

Bad filename format in include statement MAKE errorInclude file names must be surrounded by quotes or angle brackets. The file name was missing the opening quote or angle bracket.

Bad file name format in line directive Compiler errorLine directive file names must be surrounded by quotes (“filename.h”) or angle brackets (<filename.h>). The file name was missing the opening quote or angle bracket. If a macro was used, the resulting expansion text is incorrect; that is, it is not surrounded by quote marks.

Bad GCD type in GRPDEF, extended dictionary aborted Librarian warningBad GRPDEF type encountered, extended dictionary aborted Librarian warning

The librarian has encountered an invalid entry in a group definition (GRPDEF) record in an object module while creating an extended dictionary. The only type of GRPDEF record that the librarian (and linker) supports is segment index type. If any other type of GRPDEF is encountered, the librarian won’t be able to create an extended dictionary. It’s possible that an object module created by products other than Borland tools can create GRPDEF records of other types. It’s also possible for a corrupt object module to generate this warning.

Page 227: UG

A p p e n d i x C , E r r o r m e s s a g e s 227

Bad header in input LIB Librarian errorWhen adding object modules to an existing library, the librarian has determined that it has a bad library header. Rebuild the library.

Bad ifdef directive syntax Compiler errorAn #ifdef directive must contain a single identifier (and nothing else) as the body of the directive.

Bad LF_POINTER in module module Linker errorThis is typically caused by bad debug information in the OBJ file. Borland Technical Support should be informed.

Bad macro output translator MAKE errorInvalid syntax for substitution within macros.

Bad object file filename near file offset offset Linker errorThe linker has found a bad OBJ file. This is usually caused by a translator error.

Bad object file record Linker errorBad object file file near file offset offset Linker error

An ill-formed object file was encountered. This is most commonly caused by naming a source file or by naming an object file that was not completely built. This can occur if the machine was rebooted during a compile, or if a compiler did not delete its output object file when a Ctrl+Break was pressed.

Bad OMF record type type encountered in module module Librarian errorThe librarian encountered a bad Object Module Format (OMF) record while reading through the object module. The librarian has already read and verified the header records on the module, so this usually indicates that the object module has become corrupt in some way and should be re-created.

Bad syntax for pure function definition Compiler errorPure virtual functions are specified by appending “= 0” to the declaration. You wrote something similar, but not quite the same.

Bad undef directive syntax Compiler errorAn #undef directive must contain a single identifier (and nothing else) as the body of the directive.

Bad undef statement syntax MAKE errorAn !undef statement must contain a single identifier and nothing else as the body of the statement.

Bad version number in parameter block Linker errorThis error indicates an internal inconsistency in the IDE. If it occurs, exit and restart the IDE. This error does not occur in the standalone version.

Base class class contains dynamically dispatchable functions Compiler errorCurrently, dynamically dispatched virtual tables do not support the use of multiple inheritance. This error occurs because a class that contains DDVT functions attempted to inherit DDVT functions from multiple parent classes.

Base class class is also a base class of class Compiler warningA class inherits from the same base class both directly and indirectly. It is best to avoid this non-portable construct in your program code.

Base class class is inaccessible because also inclass Compiler warningIt is not legal to use a class as both a direct and indirect base class because the members are automatically ambiguous. Try making the base class virtual in both locations.

Base class class is included more than once Compiler errorA C++ class can be derived from any number of base classes, but can be directly derived from a given class only once.

Base class class is initialized more than once Compiler errorIn a C++ class constructor, the list of initializations following the constructor header includes base class class more than once.

Base initialization without a class name is now obsolete Compiler errorEarly versions of C++ provided for initialization of a base class by following the constructor header with just the base class constructor parameter list. It is now recommended that you include the base class name: this makes the code much clearer, and is required when there are multiple base classes.Old way:

derived::derived(int i) : (i, 10) { ... }

Page 228: UG

228 U s e r ’ s G u i d e

New way:

derived::derived(int i) : base(i, 10) { ... }

Bit field cannot be static Compiler errorOnly ordinary C++ class data members can be declared static, not bit fields.

Bit field too large Compiler errorThis error occurs when you supply a bit field with more than 32 bits.

Bit fields must be signed or unsigned int Compiler errorIn ANSI C, bit fields can only be signed or unsigned int (not char or long, for example).

Bit fields must be signed or unsigned int Compiler warningIn ANSI C, bit fields cannot be of type signed char or unsigned char. When not compiling in strict ANSI mode, the compiler allows such constructs, but flags them with this warning.

Bit fields must contain at least one bit Compiler errorYou cannot declare a named bit field to have 0 (or less than 0) bits. You can declare an unnamed bit field to have 0 bits, a convention used to force alignment of the following bit field to a byte boundary (or word boundary, if you select Word Alignment). In C++, bit fields must have an integral type; this includes enumerations.

Bit fields must have integral type Compiler errorIn C++, bit fields must have an integral type; this includes enumerations.

Body has already been defined for function function Compiler errorA function with this name and type was previously supplied a function body. A function body can be supplied only once.

Both return and return with a value used Compiler warningThe current function has return statements with and without values. This is legal in C, but is almost always an error. Possibly a return statement was omitted from the end of the function.

Call of nonfunction Compiler errorThe name being called is not declared as a function. This is commonly caused by incorrectly declaring the function or by misspelling the function name.

Call to function function with no prototype Compiler warningThe “Prototypes required” warning was enabled and you called function function without first giving a prototype for it.

Call to undefined function function Compiler errorYour source file declared the current function to return some type other than void in C++ (or int in C), but the compiler encountered a return with no value. This is usually some sort of error. int functions are exempt in C because in old versions of C there was no void type to indicate functions that return nothing.

virtual can only be used with member functionsA data member has been declared with the virtual specifier. Only member functions can be declared virtual.

Can’t grow LE/LIDATA record buffer Librarian errorCommand-line error. See the message Out of memory reading LE/LIDATA record from object module.

Can’t inherit non-RTTI class from RTTI base class Compiler errorCan’t inherit RTTI class from non-RTTI base class Compiler error

When virtual functions are present, the RTTI attribute of all base classes must match that of the derived class.

Cannot access an inactive scope Compiler errorYou have tried to evaluate or inspect a variable local to a function that is currently not active. (This is an integrated debugger expression evaluation message.)

Cannot add or subtract relocatable symbols Compiler errorThe only arithmetic operation that can be performed on a relocatable symbol in an assembler operand is addition or subtraction of a constant. Variables, procedures, functions, and labels are relocatable symbols. Assuming that Var is a variable and Const is a constant, then the instructions

MOV AX,Const+Constand

MOV AX,Var+Const

Page 229: UG

A p p e n d i x C , E r r o r m e s s a g e s 229

are valid, but the following is not:

MOV AX,Var+Var

Cannot allocate a reference Compiler errorAn attempt to create a reference using the new operator has been made; this is illegal because references are not objects and cannot be created through new.

identifier cannot be declared in an anonymous union Compiler errorThe compiler found a declaration for a member function or static member in an anonymous union. Such unions can contain data members only.

function1 cannot be distinguished from function2 Compiler errorThe parameter type lists in the declarations of these two functions do not differ enough to tell them apart. Try changing the order of parameters or the type of a parameter in one declaration.

Cannot call main from within the program Compiler errorC++ does not allow recursive calls of the function main.

Cannot call near class member function with a pointer of type type Compiler errorMember functions of near classes (classes are near by default in the tiny, small, and medium memory models) cannot be called using far or huge member pointers. (Note that this also applies to calls using pointers to members.) Either change the pointer to be near, or declare the class as far.

Cannot cast from type1 to type2 Compiler errorA cast from type type1 to type type2 is not allowed. In C, a pointer can be cast to an integral type or to another pointer. An integral type can be cast to any integral, floating, or pointer type. A floating type can be cast to an integral or floating type. Structures and arrays cannot be cast to or from. You cannot cast from a void type.C++ checks for user-defined conversions and constructors, and if one cannot be found, then the preceding rules apply (except for pointers to class members). Among integral types, only a constant zero can be cast to a member pointer. A member pointer can be cast to an integral type or to a similar member pointer. A similar member pointer points to a data member if the original does, or to a function member if the original does; the qualifying class of the type being cast to must be the same as or a base class of the original.

Cannot convert type1 to type2 Compiler errorAn assignment, initialization, or expression requires the specified type conversion to be performed, but the conversion is not legal.

Cannot create instance of abstract class class Compiler errorAbstract classes—those with pure virtual functions—cannot be used directly, only derived from.

Cannot create pre-compiled header: code in header Compiler warningOne of the headers contained a non-inline function body.

Cannot create pre-compiled header: initialized data in header Compiler warningOne of the headers contained a global variable definition. In a C header, this message indicates that a global variable was initialized. In C++ header, this message indicates that a variable was not declared “extern.”

Cannot create pre-compiled header: header incomplete Compiler warningThe pre-compiled header ended in the middle of a declaration. This often happens when there is a missing “}” in a class definition that is located in a header file.

Cannot create pre-compiled header: write failed Compiler warningThe compiler could not write to the pre-compiled header file. This is usually due to a full disk or a disk that is write protected.

Cannot define a pointer or reference to a reference Compiler errorIt is illegal to have a pointer to a reference or a reference to a reference.

Cannot find class::class(class &) to copy a vector Compiler errorWhen a C++ class class1 contains a vector (array) of class class2, and you want to construct an object of type class1 from another object of type class1, there must be a constructor class2::class2(class2&) so that the elements of the vector can be constructed. This constructor, called a copy constructor, takes just one parameter (a reference to its class).Usually the compiler supplies a copy constructor automatically. However, if you have defined a constructor for class class2 that has a parameter of type class2& and has additional parameters with default values, the copy constructor cannot be created by the compiler. (This is because class2::class2(class2&) and class2::class2(class2&, int = 1) cannot be distinguished.) You must redefine this constructor so that not all parameters have default values. You can then define a copy constructor or let the compiler create one.

Page 230: UG

230 U s e r ’ s G u i d e

Cannot find class::operator=(class&) to copy a vector Compiler errorWhen a C++ class class1 contains a vector (array) of class class2, and you want to copy a class of type class1, there must be an assignment operator class2::operator=(class2&) so that the elements of the vector can be copied. Usually the compiler supplies such an operator automatically. However, if you have defined an operator= for class class2, but not one that takes a parameter of type class2&, the compiler will not supply it automatically—you must supply one.

Cannot find default constructor to initialize array element of type class Compiler errorWhen declaring an array of a class that has constructors, you must either explicitly initialize every element of the array, or the class must have a default constructor (it will be used to initialize the array elements that don’t have explicit initializers). The compiler will define a default constructor for a class unless you have defined any constructors for the class.

Cannot find default constructor to initialize base class class Compiler errorWhenever a C++ derived class class2 is constructed, each base class class1 must first be constructed. If the constructor for class2 does not specify a constructor for class1 (as part of class2’s header), there must be a constructor class1::class1() for the base class. This constructor without parameters is called the default constructor. The compiler will supply a default constructor automatically unless you have defined any constructor for class class1; in that case, the compiler will not supply the default constructor automatically—you must supply one.

Cannot find default constructor to initialize member identifier Compiler errorWhen a C++ class class1 contains a member of class class2, and you want to construct an object of type class1 but not from another object of type class1, there must be a constructor class2::class2() so that the member can be constructed. This constructor without parameters is called the default constructor. The compiler supplies a default constructor automatically unless you’ve defined a constructor for class class2. If you have, the compiler won’t supply the default constructor automatically—you must supply one.

Cannot find MAKE.EXE MAKE errorThe MAKE command-line tool cannot be found. Be sure that MAKE.EXE is in either the current directory or in a directory contained in your directory path.

Cannot generate COM file: data below initial CS:IP defined Linker errorThis error results from trying to generate data or code below the starting address (usually 100) of a .COM file. Be sure that the starting address is set to 100 by using the (ORG 100H) instruction. This error message should not occur for programs written in a high-level language. If it does, ensure that the correct startup (C0x) object module is being linked in.

Cannot generate COM file: invalid initial entry point address Linker errorYou used the /Tdc or /t option, but the program starting address is not equal to 100H, which is required with .COM files.

Cannot generate COM file: program exceeds 64K Linker errorYou used the /Tdc or /t option, but the total program size exceeds the .COM file limit.

Cannot generate COM file: segment-relocatable items present Linker errorYou used the /Tdc or /t option, but the program contains segment-relative fixups, which are not allowed with .COM files.

Cannot generate COM file: stack segment present Linker errorYou used the /Tdc or /t option, but the program declares a stack segment, which is not allowed with .COM files.

Cannot generate function from template function template Compiler errorA call to a template function was found, but a matching template function cannot be generated from the function template.

Cannot have a non-inline function in a local class Compiler errorCannot have a static data member in a local class Compiler error

All members of classes declared local to a function must be entirely defined in the class definition. This means that such local classes cannot contain any static data members, and all of their member functions must have bodies defined within the class definition.

Cannot have multiple paths for implicit rule MAKE errorYou can have only one path for each of the extensions in an implicit rule; for example, {path}.c.obj. Multiple path lists are allowed only for dependents in an explicit rule.

Cannot have path list for target MAKE errorYou can only specify a path list for dependents of an explicit rule. For example,

Page 231: UG

A p p e n d i x C , E r r o r m e s s a g e s 231

{path1;path2}prog.exe: prog.obj # Invalidprog.exe: {path1;path2}prog.obj # Valid

Cannot initialize a class member here Compiler errorIndividual members of structs, unions, and C++ classes cannot have initializers. A struct or union can be initialized as a whole using initializers inside braces. A C++ class can be initialized only by the use of a constructor.

Cannot initialize type1 with type2 Compiler errorYou are attempting to initialize an object of type type1 with a value of type type2, which is not allowed. The rules for initialization are essentially the same as for assignment.

Cannot modify a const object Compiler errorThis indicates an illegal operation on an object declared to be const, such as an assignment to the object.

Cannot overload ‘main’ Compiler errormain is the only function that cannot be overloaded.

function cannot return a value Compiler errorA function with a return type void contains a return statement that returns a value; for example, an int.

identifier cannot start a parameter declaration Compiler errorAn undefined ‘identifier’ was found at the start of an argument in a function declarator. This error usually occurs because the wrong header file was used. If that isn’t the cause, check to see if the type name is misspelled or if the type declaration is missing.

identifier cannot start an argument declaration Compiler errorUndefined identifier found at the start of an argument in a function declarator. This error usually occurs because the wrong header file was used. If that isn’t the cause, check to see if the type name is misspelled or if the type declaration is missing.

Cannot take address of main Compiler errorIn C++ it is illegal to take the address of the main function.

Cannot throw type —ambiguous base class base Compiler errorIt is not legal to throw a class that contains more than one copy of a (nonvirtual) base class.

Cannot use tiny or huge memory model with Windows Compiler errorYou must use the small, medium, compact, or large memory models when compiling Windows programs.

Cannot write a string option MAKE errorthe –W MAKE option writes a character option to MAKE.EXE. If there’s any string option (for example, –Dxxxx=”My_foo” or –Uxxxxx), this error message is generated.

Cannot write GRPDEF list, extended dictionary aborted Librarian errorThe librarian cannot write the extended dictionary to the tail end of the library file. This usually indicates lack of space on the disk.

Case bypasses initialization of a local variable Compiler errorIn C++ it is illegal to bypass the initialization of a local variable in any way. In this instance, there is a case label that can transfer control past this local variable.

Case outside of switch Compiler errorThe compiler encountered a case statement outside a switch statement. This is often caused by mismatched braces.

Case statement missing : Compiler errorA case statement must have a constant expression followed by a colon. The expression in the case statement either is missing a colon or has an extra symbol before the colon.

catch expected Compiler errorIn a C++ program, a try block must be followed by at least one catch block.

Character constant must be one or two characters long Compiler errorCharacter constants can be only one or two characters long.

Character constant too long MAKE errorA char constant in an expression is too long.

Circular dependency exists in makefile MAKE errorThe makefile indicates that a file needs to be up-to-date before it can be built. Take, for example, the explicit rules

Page 232: UG

232 U s e r ’ s G u i d e

filea: filebfileb: filecfilec: filea

This implies that filea depends on fileb, which depends on filec, and filec depends on filea. This is illegal because a file cannot depend on itself, indirectly or directly.

Class class may not contain pure functions Compiler errorThe class being declared cannot be abstract; it therefore cannot contain any pure functions.

Class member member declared outside its class Compiler errorC++ class member functions can be declared inside the class declaration only. Unlike nonmember functions, they cannot be declared multiple times or at other locations.

Class class is abstrace because of member = 0 Compiler errorThis message is always issued in conjunction with the message “Cannot create instance of abstract class class,” and is intended to make it easier to figure out why a particular class is found to be abstract by the compiler.For example, consider the following example of an attempt to instantiate an abstract class:

struct VB{

virtual void f() = 0;virtual void g() = 0;virtual void h() = 0;

};

struct D1 : virtual VB{

void f();};

struct D2 : virtual VB{

void h();};

struct DD : D1, D2{}

v; // error: 'DD' is an abstract classThe 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 warningThe 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 errorYour implicit rule is missing a colon at the end.

.c.obj: # Correct

.c.obj # Incorrect

Command arguments too long MAKE errorThe arguments to a command were more than the 511-character limit imposed by DOS.

Command syntax error MAKE errorThis message occurs if

Page 233: UG

A p p e n d i x C , E r r o r m e s s a g e s 233

The first rule line of the makefile contained any leading whitespace.An implicit rule did not consist of .ext.ext:.An explicit rule did not contain a name before the : character.A macro definition did not contain a name before the = character.

Command too long MAKE errorThe length of a command has exceeded 512 characters. You might want to use a response file.

Common segment exceeds 64K Linker errorThe program had more than 64K of near uninitialized data. Try declaring some uninitialized data as far.

Compiler could not generate copy constructor for class class Compiler errorThe compiler cannot generate a needed copy constructor due to language rules.

Compiler could not generate default constructor for class class Compiler errorThe compiler cannot generate a needed default constructor due to language rules.

Compiler could not generate operator= for class class Compiler errorThe compiler cannot generate a needed assignment operator due to language rules.

Compiler stack overflow Compiler errorThe compiler ran out of memory during compilation. Review the portion of code flagged by the error message to ensure that it uses memory correctly.

Compiler table limit exceeded Compiler errorOne of the compiler’s internal tables overflowed. This usually means that the module being compiled contains too many function bodies. Making more memory available to the compiler will not help with such a limitation; simplifying the file being compiled is usually the only remedy.

Compound statement missing } Compiler errorThe compiler reached the end of the source file and found no closing brace. This is often caused by mismatched braces.

Condition is always false Compiler warningCondition is always true Compiler warning

The compiler encountered a comparison of values where the result is always true or false. For example,

void proc(unsigned x) {if (x >= 0) { } /* always 'true' */

}

Conflicting type modifiers Compiler errorThis occurs when a declaration is given that includes, for example, both near and far keywords on the same pointer. Only one addressing modifier can be given for a single pointer, and only one language modifier (cdecl, pascal, or interrupt) can be given for a function.

symbol conflicts with module module Linker warningThis indicates an inconsistency in the definition of symbol; TLINK found one virtual function and one common definition with the same name.

Constant expression required Compiler errorArrays must be declared with constant size. This error is commonly caused by misspelling a #define constant.

Constant is long Compiler warningThe compiler encountered either a decimal constant greater than 32767 or an octal (or hexadecimal) constant greater than 65535 without a letter l or L following it. The constant is treated as a long.

Constant member member in class without constructors Compiler errorA class that contains constant members must have at least one user-defined constructor; otherwise, there would be no way to initialize such members.

Constant member member is not initialized Compiler warningThis C++ class contains a constant member member, which does not have an initialization. Constant members can only be initialized; they cannot be assigned to.

Constant out of range in comparison Compiler warningYour source file includes a comparison involving a constant subexpression that was outside the range allowed by the other subexpression’s type. For example, comparing an unsigned quantity to –1 makes no sense. To get an unsigned

Page 234: UG

234 U s e r ’ s G u i d e

constant greater than 32767 (in decimal), you should either cast the constant to unsigned or append a letter u or U to the constant.When this message is issued, the compiler still generates code to do the comparison. If this code ends up always giving the same result, such as comparing a char expression to 4000, the code still performs the test.

Constant variable variable must be initialized Compiler errorThis C++ object is declared const, but is not initialized. Because no value can be assigned to it, it must be initialized at the point of declaration.

Constructor cannot be declared const or volatile Compiler errorA constructor has been declared as const and/or volatile, and this is not allowed.

Constructor cannot have a return type specification Compiler errorC++ constructors have an implicit return type used by the compiler, but you cannot declare a return type or return a value.

Conversion may lose significant digits Compiler warningFor an assignment operator or some other circumstance, your source file requires a conversion from long or unsigned long to int or unsigned int type. Because int type and long type variables don’t have the same size, this kind of conversion can alter the behavior of a program.

Conversion of near pointer not allowed Compiler errorA near pointer cannot be converted to a far pointer in the expression evaluation box when a program is not currently running. This is because the conversion needs the current value of DS in the user program, which doesn’t exist.

Conversion operator cannot have a return type specification Compiler errorThis C++ type conversion member function specifies a return type different from the type itself. A declaration for conversion function operator cannot specify any return type.

Conversion to type will fail for members of virtual base class Compiler errorThis warning can occur when a member pointer (whose class contains virtual bases) is cast to another member-pointer type and you use the –Vv option. This error indicates that if the member pointer being cast happens to point (at the time of the cast) to a member of class, the conversion cannot be completed, and the result of the cast will be a NULL member pointer.

Could not allocate memory for per module data Librarian errorThe librarian has run out of memory.

Could not create list file filename Librarian errorThe librarian could not create a list file for the library. This could be due to lack of disk space.

Could not find a match for argument(s) Compiler errorNo C++ function could be found with parameters matching the supplied arguments.

Could not find file filename Compiler errorThe compiler is unable to find the file supplied on the command line.

Could not get procedure address from DLL filename Linker errorThe linker was not able to get a procedure from the specified DLL. Check to make sure that you have the correct DLL version.

Could not load DLL filename Linker errorThe linker was not able to load the specified DLL. Check to make sure the DLL is on your path.

Could not write output Librarian errorThe librarian could not write the output file.

Couldn’t alloc memory for per module data Librarian errorThe librarian has run out of memory.

filename couldn’t be created, original won’t be changed Librarian warningAn attempt has been made to extract an object (an ‘*’ action) but the librarian cannot create the object file to extract the module into. Either the object already exists and is read only, or the disk is full.

Couldn’t build command line to RLINK.EXE Linker errorThe command line that was generated by the command line linker was longer than 128 bytes. RLINK.EXE was not run on the EXE. Shorten the file names passed in the .RES file list, put in fewer .RES files, or run RLINK separately.

Page 235: UG

A p p e n d i x C , E r r o r m e s s a g e s 235

Couldn’t exec RLINK.EXE Linker errorThe command-line linker could not spawn RLINK.EXE to bind resources. Check to make sure that RLINK.EXE is on your path.

Couldn’t get LE/LIDATA record buffer Librarian errorCommand-line error. See the message Out of memory reading LE/LIDATA record from object module.

Couldn’t get procedure address from dll dll Linker errorThe linker wasn’t able to get a procedure from the specified DLL. Check to make sure you have the correct version of the DLL.

Couldn’t load dll dll Linker errorThe linker wasn’t able to load the specified DLL. Check to make sure the DLL is on your path.

Cycle in include files: filename MAKE errorThis error message is issued if a makefile includes itself in the make script.

Debug info switch ignored for .COM files Linker warningTurbo C++ does not include debug information for .COM files.

Debug information enabled, but no debug information found in OBJs Linker warningNo part of the application was compiled with debug information, but you requested that debug information be turned on in the link.

Debug information in module module will be ignored Linker warningObject files compiled with debug information now have a version record. The major version of this record is higher than what TLINK currently supports and TLINK did not generate debug information for the module in question.

Debugging information overflow; try fewer modules with debug info Linker errorToo many modules containing debugging information are included in the link. Recompile your program with fewer modules marked for debug information. This message is generated when you have more than 64K of types or symbols in a single .OBJ file, or if you get more than 64K modules, source files (including .h files), scopes, logical debug segments, classes, or optimized variables in the link.

Declaration does not specify a tag or an identifier Compiler errorThis declaration doesn’t declare anything. This might be a struct or union without a tag or a variable in the declaration. C++ requires that something be declared.

Declaration is not allowed here Compiler errorDeclarations cannot be used as the control statement for while, for, do, if, or switch statements.

Declaration missing ; Compiler errorYour source file contained a declaration that was not followed by a semicolon.

Declaration syntax error Compiler errorYour source file contained a declaration that was missing some symbol or had some extra symbol added to it.

Declaration terminated incorrectly Compiler errorA declaration has an extra or incorrect termination symbol, such as a semicolon placed after a function body. A C++ member function declared in a class with a semicolon between the header and the opening left brace also generates this error.

Declaration was expected Compiler errorA declaration was expected here but not found. This is usually caused by a missing delimiter such as a comma, semicolon, right parenthesis, or right brace.

Declare operator delete (void*) or (void*, size_t) Compiler errorDeclare the operator delete with a single void* parameter or with a second parameter of type size_t. If you use the second version, it will be used in preference to the first version. The global operator delete can be declared using the single-parameter form only.

Declare operator delete[] (void*) or (void*, size_t) Compiler errorDeclare the operator delete with one of the following:

A single void* parameterA second parameter of type size_t

If you use the second version, it will be used in preference to the first version. The global operator delete can be declared using the single-parameter form only.

Page 236: UG

236 U s e r ’ s G u i d e

Declare type type prior to use in prototype Compiler warningWhen a function prototype refers to a structure type that has not previously been declared, the declaration inside the prototype is not the same as a declaration outside the prototype. For example,

int func(struct s *ps);struct s { /* ... */ };

Because there is no struct s in scope at the prototype for func, the type of parameter ps is a pointer to undefined struct s, and is not the same as the struct s that is later declared. This results in warning and error messages about incompatible types, which would be mysterious without this warning message. To fix the problem, you can move the declaration for struct s ahead of any prototype that references it, or add the incomplete type declaration struct s; ahead of any prototype that references struct s. If the function parameter is a struct, rather than a pointer to struct, the incomplete declaration is not sufficient; you must then place the struct declaration ahead of the prototype.

Default argument value redeclared Compiler errorWhen a parameter of a C++ function is declared to have a default value, this value can’t be changed, redeclared, or omitted in any other declaration for the same function.

Default argument value redeclared for parameter parameter Compiler errorWhen a parameter of a C++ function is declared to have a default value, this value cannot be changed, redeclared, or omitted in any other declaration for the same function.

Default expression may not use local variables Compiler errorA default argument expression is not allowed to use any local variables or other parameters.

Default outside of switch Compiler errorThe compiler encountered a default statement outside a switch statement. This is most commonly caused by mismatched braces.

Default value missing Compiler errorWhen a C++ function declares a parameter with a default value, all of the following parameters must also have default values. In this declaration, a parameter with a default value was followed by a parameter without a default value.

Default value missing following parameter parameter Compiler errorAll parameters following the first parameter with a default value must also have defaults specified.

Define directive needs an identifier Compiler errorThe first non-whitespace character after a #define must be an identifier. The compiler found some other character.

symbol defined in module module is duplicated Linker errorThere is a conflict between two symbols (either public or communal). This usually means that a symbol is defined in two modules. An error occurs if both are encountered in the .OBJ file(s), because TLINK doesn’t know which is valid. A warning results if TLINK finds one of the duplicated symbols in a library and finds the other in an .OBJ file; in this case, TLINK uses the one in the .OBJ file.

Delete array size missing ] Compiler errorThe array specifier in an operator is missing a right bracket.

Destructor cannot be declared const or volatile Compiler errorA destructor has been declared as const and/or volatile, and this is not allowed.

Destructor cannot have a return type specification Compiler errorIt is illegal to specify the return type for a destructor.

Destructor for class is not accessible Compiler errorThe destructor for this C++ class is protected or private, and cannot be accessed here to destroy the class. If a class destructor is private, the class cannot be destroyed, and thus can never be used. This is probably an error. A protected destructor can be accessed only from derived classes. This is a useful way to ensure that no instance of a base class is ever created, but only classes derived from it.

Destructor for class required in conditional expression Compiler errorIf the compiler must create a temporary local variable in a conditional expression, it has no good place to call the destructor, because the variable might or might not have been initialized. The temporary variable can be explicitly created, as with classname (val, val), or implicitly created by some other code. Recast your code to eliminate this temporary value.

Destructor name must match the class name Compiler errorIn a C++ class, the tilde (~) introduces a declaration for the class destructor. The name of the destructor must be the same as the class name. In your source file, the tilde (~) preceded some other name.

Page 237: UG

A p p e n d i x C , E r r o r m e s s a g e s 237

Divide error Run-time errorYou’ve tried to divide an integer by zero. You can trap this error with the signal function. Otherwise, Turbo C++ calls abort and your program terminates.

Division by zero Compiler errorYour source file contained a division or remainder operator in a constant expression with a zero divisor.

Division by zero Compiler warningA division or remainder operator expression had a literal zero as a divisor.

Division by zero MAKE errorA division or remainder operator in an !if statement has a zero divisor.

do statement must have while Compiler errorYour source file contained a do statement that was missing the closing while keyword.

filename does not exist—don’t know how to make it MAKE errorThere is a nonexistent file name in the build sequence, and no rule exists that would allow the file name to be built.

DOS error, ax = number Linker errorThis error occurs if a DOS call returned an unexpected error. The ax value printed is the resulting error code. This could indicate a TLINK internal error or a DOS error. The only DOS calls TLINK makes in which this error could occur are read, write, seek, and close.

DOSSEG directive ignored in module Linker warningThis warning indicates that the DOSSEG directive is no longer supported by the linker.

do-while statement missing ( Compiler errorIn a do statement, the compiler found no left parenthesis after the while keyword.

do-while statement missing ) Compiler errorIn a do statement, the compiler found no right parenthesis after the test expression.

do-while statement missing ; Compiler errorIn a do statement test expression, the compiler found no semicolon after the right parenthesis.

DPMI programs must use the large memoy model Compiler errorThe command-line compiler generates this messae when you’re attmepting to create a DPMI program; DPMI programs require that you use the large memory model.

Duplicate case Compiler errorEach case of a switch statement must have a unique constant expression value.

filename (linenum): Duplicate external name in exports Linker warningTwo export functions listed in the EXPORTS section of a module definition file defined the same external name. For example,

EXPORTSAnyProc=MyProc1AnyProc=MyProc2

Duplicate file %s in list, not added! Librarian errorWhen building a library module, you specified an object file more that once.

Duplicate handler for type1, already had type2 Compiler errorIt’s illegal to specify two handlers for the same type.

filename (linenum): Duplicate internal name in exports Linker warningTwo export functions listed in the EXPORTS section of the module definition file defined the same internal name. For example,

EXPORTSAnyProc1=MyProcAnyProc2=MyProc

filename (linenum): Duplicate internal name in imports Linker warningTwo import functions listed in the IMPORTS section of the module definition file defined the same internal name. For example,

Page 238: UG

238 U s e r ’ s G u i d e

IMPORTSAnyProc=MyMod1.MyProc1AnyProc=MyMod2.MyProc2

Duplicate ordinal for exports: string (ordval1) and string (ordval2) Linker errorTwo exports have been found for the same symbol, but with differing ordinal values. You must use the same ordinal value or remove one of the exports.

Empty LEDATA record in module module Linker warningThis warning can happen if the translator emits a data record containing data. If this should happen, report the occurrence to the translator vendor; there should be no bad side effects from the record.

Enum syntax error Compiler errorAn enum declaration did not contain a properly formed list of identifiers.

Error changing file buffer size Librarian errorThe librarian is attempting to adjust the size of a buffer used while reading or writing a file, but there is not enough memory. It is likely that quite a bit of system memory will have to be freed up to resolve this error.

Error directive: message Compiler errorThe text of the #error directive being processed in the source file is displayed.

Error directive: message MAKE errorMAKE has processed an #error directive in the source file, and the text of the directive is displayed in the message.

Error opening filename Librarian errorlibrarian cannot open the specified file for some reason.

Error opening filename for output Librarian errorlibrarian cannot open the specified file for output. This is usually due to lack of disk space for the target library, or a listing file. This error occurs when the target file exists but is marked as a read-only file.

Error renaming filename to filename Librarian errorThe librarian builds a library into a temporary file and then renames the temporary file to the target library file name. If there is an error, usually due to lack of disk space, this message is posted.

Error writing output file Compiler errorA DOS error that prevents Turbo C++ from writing an .OBJ, .EXE, or temporary file. Check the output directory and make sure that this is a valid directory. Also check that there is enough free disk space.

_ _except or _ _finally expected following _ _try Compiler errorIn C, a _ _try block must be followed by an _ _except or _ _finally handler block.

Exception handling not enabled Compiler errorA ‘try’ block was found with the exception handling disabled.

Exception handling variable may not be used here Compiler errorAn attempt has been made to use one of the exception handling values that are restricted to particular exception handling constructs, such as GetExceptionCode().

Exception specification not allowed here Compiler errorFunction pointer type declarations are not allowed to contain exception specifications.

Explicit stacks are ignored for PE images Linker warningWindows 32-bit applications are PE format applications, which do not have explicit stacks. The stack segment will be linked into the image, but it will not be used as the application stack. Instead, the stack size parameter will be used to set the stack size, and the operating system will allocate a stack for the application.

Export symbol is duplicated Linker warningThis warning occurs if two different symbols with the same name are exported by the use of _export. The linker cannot determine which definition it should export, and therefore uses the first symbol.

Expression expected Compiler errorAn expression was expected here, but the current symbol cannot begin an expression. This message can occur where the controlling expression of an if or while clause is expected or where a variable is being initialized. It is often due to an accidentally inserted or deleted symbol in the source code.

Page 239: UG

A p p e n d i x C , E r r o r m e s s a g e s 239

Expression of scalar type expected Compiler errorThe not (!), increment (++), and decrement (– –) operators require an expression of scalar type. Only types char, short, int, long, enum, float, double, long double, and pointer types are allowed.

Expression syntax Compiler errorThis is a catchall error message when the compiler parses an expression and encounters a serious error. This is most commonly caused by two consecutive operators, mismatched or missing parentheses, or a missing semicolon on the previous statement.

Expression syntax error in !if statement MAKE errorThe expression in an !if statement is badly formed—it contains a mismatched parenthesis, an extra or missing operator, or a missing or extra constant.

reason—extended dictionary not created Librarian warningThe librarian could not produce the extended dictionary because of the reason given in the warning message.

Extended dictionary not found in library library, extended dictionaries ignored Linker warningThe /E option for TLINK requires that all libraries in the link have extended dictionaries. When a library without an extended dictionary is encountered during a link operation in which the /E option is specified, the linker abandons extended dictionary processing and proceeds to link with a default link.

Extern variable cannot be initialized Compiler errorThe storage class extern applied to a variable means that the variable is being declared but not defined here—no storage is being allocated for it. Therefore, you can’t initialize the variable as part of the declaration.

Extern symbol was not qualified with _ _import in modulemodule Linker warningWindows 32-bit applications which reference imported symbols need to make indirections to get to the data. For calls, this is handled automatically by the linker. For references to imported DATA, the compiler must generate an indirection, or the application will function incorrectly. The compiler knows to generate the indirection when the symbol is qualified with _ _import. If the linker sees a segment relative reference to a symbol that is imported, and if the symbol was not qualified with _ _import, you will get this message.

Extra argument in template class name template Compiler errorA template class name specified too many actual values for its formal parameters.

Extra parameter in call Compiler errorA call to a function, via a pointer defined with a prototype, had too many arguments given.

Extra parameter in call to function Compiler errorA call to the named function (which was defined with a prototype) had too many arguments given in the call.

Failed to locate DPMI server (DPMI16BI.OVL) Compiler errorFailed to locate protected mode loader (DPMILOAD.EXE) Compiler error

Make sure that DPMI16BI.OVL and DPMILOAD.EXE are somewhere on your path or in the same directory as the protected mode command-line tool you were attempting to use.

Failed read from filename Linker errorThe linker was unable to read from the file.

Failed write to filename Linker errorThe Linker was unable to write to the file.

_ _far16 may only be used with _ _pascal or _ _cdecl Compiler errorWhen you use _ _far16 to make calls to functions or reference data in a 16-bit DLL, such functions and data can be modified only by _ _pascal or _ _cdecl.

File must contain at least one external declaration Compiler errorThis compilation unit was logically empty, containing no external declarations. ANSI C and C++ require that something be declared in the compilation unit.

Filename too long Compiler errorThe file name given in an #include directive was too long for the compiler to process. Path names must be no longer than 260 characters.

File name too long MAKE errorThe path name in an !include directive overflowed MAKE’s internal buffer (512 bytes).

filename file not found Librarian warningThe command-line librarian attempted to add a nonexisting object but created the library anyway.

Page 240: UG

240 U s e r ’ s G u i d e

filename file not found Librarian errorThe IDE creates the library by first removing the existing library and then rebuilding. If any objects do not exist, the library is considered incomplete and TLIB generates this error. If the IDE reports that an object does not exist, either the source module has not been compiled or there were errors during compilation. Rebuilding your project should resolve the problem or indicate where the errors have occurred.

filename (linenum): File read error Linker errorA DOS error occurred while TLINK read the module definition file. This usually means that a premature end of file occurred.

Fixup to zero length segment in module module Linker errorA reference has been made past the end of an image segment. This reference would end up accessing an invalid address, and has been flagged as an error.

Fixup overflow at address, target = address Linker warningThese messages indicate an incorrect data or code reference in an object file that TLINK must fix up at link time.The cause is often a mismatch of memory models. A near call to a function in a different code segment is the most likely cause. These errors can also result if you generate a near call to a data variable or a data reference to a function. In either case the symbol named as the target in the error message is the referenced variable or function. The reference is in the named module, so look in the source file of that module for the offending reference.In an assembly language program, a fixup overflow frequently occurs if you have declared an external variable within a segment definition, but this variable actually exists in a different segment.If this technique does not identify the cause of the failure, or if you are programming in assembly language or in a high-level language other than Turbo C++, there might be other possible causes for this message. Even in Turbo C++, this message could be generated if you are using different segment or group names than the default values for a given memory model.

Fixup to zero length segment in module module Linker errorThis error usually occurs if you make a reference to a segment that doesn’t contain any data. If the segment isn’t grouped with other segments, the result is a zero-length physical segment, which cannot exist. The linker therefore cannot make a reference to it.

Floating point error: Divide by 0. Run-time errorFloating point error: Domain. Run-time errorFloating point error: Overflow. Run-time error

These fatal errors result from a floating-point operation for which the result is not finite.“Divide by 0” means the result is +INF or -INF exactly, such as 1.0/0.0.“Domain” means the result is NAN (not a number).“Overflow” means the result is +INF (infinity) or -INF with complete loss of precision, such as assigning

1e200*1e200 to a double.

Floating point error: Partial loss of precision. Run-time errorFloating point error: Underflow. Run-time error

These exceptions are masked by default, and the error messages do not occur. Underflows are converted to zero and losses of precision are ignored. They can be unmasked by calling _control87.

Floating point error: Stack fault. Run-time errorThe floating-point stack has been overrun. This error does not normally occur and might be due to assembly code using too many registers or to a misdeclaration of a floating-point function.These floating-point errors can be avoided by masking the exception so that it doesn’t occur, or by catching the exception with signal. See the functions _control87 and signal for details.

for statement missing ( Compiler errorIn a for statement, the compiler found no left parenthesis after the for keyword.

for statement missing ) Compiler errorIn a for statement, the compiler found no right parenthesis after the control expressions.

for statement missing ; Compiler errorIn a for statement, the compiler found no semicolon after one of the expressions.

Friends must be functions or classes Compiler errorA friend of a C++ class must be a function or another class.

Page 241: UG

A p p e n d i x C , E r r o r m e s s a g e s 241

Function call missing ) Compiler errorThe function call argument list had some sort of syntax error, such as a missing or mismatched right parenthesis.

Function calls not supported Compiler errorIn integrated debugger expression evaluation, calls to functions (including implicit conversion functions, constructors, destructors, overloaded operators, and inline functions) are not supported.

Function defined inline after use as extern Compiler errorFunctions cannot become inline after they have already been used. Either move the inline definition forward in the file or delete it entirely.

Function definition cannot be a Typedef’ed declaration Compiler errorIn ANSI C a function body cannot be defined using a typedef with a function Type.

Function function cannot be static Compiler errorOnly ordinary member functions and the operators new and delete can be declared static. Constructors, destructors, and other operators must not be static.

Function function should have a prototype Compiler errorA function was called with no prototype in scope.In C, int foo(); is not a prototype, but int foo(int); is, and so is int foo(void);. In C++, int foo(); is a prototype, and is the same as int foo(void);. In C, prototypes are recommended for all functions. In C++, prototypes are required for all functions. In C and C++, a function definition (a function header with its body) serves as a prototype if it appears before any other mention of the function.

Function should return a value Compiler warningThis function was declared (perhaps implicitly) to return a value. A return statement was found without a return value or the end of the function was reached without a return statement being found. Either return a value or declare the function as void.

Functions function1 and function2 both use the same dispatch number Compiler errorThis error is the result of a dynamically dispatched virtual table (DDVT) problem. When you override a dynamically dispatchable function in a derived class, use the same dispatch index. Each function within the same class hierarchy must use a different dispatch index.

Functions cannot return arrays or functions Compiler errorA function cannot return an array or a function. Only pointers or references to arrays or functions can be returned.

Functions containing local destructors are not expanded inline in function function Compiler warningYou’ve created an inline function for which Turbo C++ turns off inlining. You can ignore this warning if you like; the function will be generated out of line.

Functions containing reserved word are not expanded inline Compiler warningFunctions containing any of the reserved words do, for, while, goto, switch, break, continue, and case cannot be expanded inline, even when specified as inline. The function is still perfectly legal, but will be treated as an ordinary static (not global) function.

Functions may not be part of a struct or union Compiler errorThis C struct or union field was declared to be of type function rather than pointer to function. Functions as fields are allowed only in C++.

Functions with exception specifications are not expanded inline Compiler warningCheck your inline code for lines containing exception specifications.

Functions with taking class-by-value argument(s) are not expanded inline Compiler warningWhen exception handling is enabled, functions that take class arguments by value cannot be expanded inline (Note that functions taking class parameters by reference are not subject to this restriction.)

General error Linker errorGeneral error in library file filename in module module near module file offset 0xyyyyyyyy. Linker errorGeneral error in module module near module file offset 0xyyyyyyyy Linker error

The linker gives as much information as possible about what processing was happening at the time of the unknown fatal error. Call Technical Support with information about .OBJ or .LIB files.

Global anonymous union not static Compiler errorIn C++, a global anonymous union at the file level must be static.

Page 242: UG

242 U s e r ’ s G u i d e

Goto bypasses initialization of a local variable Compiler errorIn C++ it is illegal to bypass the initialization of a local variable in any way. You’ll get this error when there is a goto that tries to transfer control past this local variable.

Goto into an exception handler is not allowed Compiler errorIt’s illegal to jump into a try block or an exception handler that’s attached to a try block.

Goto statement missing label Compiler errorThe goto keyword must be followed by an identifier.

Group group exceeds 64K Linker errorA group exceeded 64K bytes when the segments of the group were combined.

Group overflowed maximum size: group Compiler errorThe total size of the segments in a group (for example, DGROUP) exceeded 64K.

Group group1 overlaps group group2 Linker warningThis means that TLINK has encountered nested groups. This warning occurs only when overlays are used.

Handler for type1 hidden by previous handler for type2 Compiler warningThis warning is issued when a handler for a type D that is derived from type B is specified after a handler for B, since the handler for D will never be invoked.

specifier has already been included Compiler errorThis type specifier occurs more than once in this declaration. Delete or change one of the occurrences.

Hexadecimal value contains more than 3 digits Compiler warningUnder older versions of C, a hexadecimal escape sequence could contain no more than three digits. The ANSI standard allows any number of digits to appear as long as the value fits in a byte. This warning results when you have a long hexadecimal escape sequence with many leading zero digits (such as “\x00045”). Older versions of C would interpret such a string differently.

function1 hides virtual function function2 Compiler warningA virtual function in a base class is usually overridden by a declaration in a derived class. In this case, a declaration with the same name but different argument types makes the virtual functions inaccessible to further derived classes.

Identifier expected Compiler errorAn identifier was expected here, but not found. In C, this error occurs in a list of parameters in an old-style function header, after the reserved words struct or union when the braces are not present, and as the name of a member in a structure or union (except for bit fields of width 0). In C++, an identifier is also expected in a list of base classes from which another class is derived, following a double colon (::), and after the reserved word operator when no operator symbol is present.

Identifier identifier cannot have a type qualifier Compiler errorA C++ qualifier class::identifier cannot be applied here. A qualifier is not allowed on typedef names, on function declarations (except definitions at the file level), on local variables or parameters of functions, or on a class member except to use its own class as a qualifier (which is redundant but legal).

If statement missing ( Compiler errorIn an if statement, the compiler found no left parenthesis after the if keyword.

If statement missing ) Compiler errorIn an if statement, the compiler found no right parenthesis after the test expression.

If statement too long MAKE errorIfdef statement too long MAKE errorIfndef statement too long MAKE error

An If, Ifdef, or Ifndef statement has exceeded 4,096 characters.

Ignored module, path is too long Librarian warningThe path to a specified .OBJ or .LIB file is greater than 64 characters. The max path to a file for librarian is 64 characters.

Illegal ACBP byte in SEGDEF Linker errorThis is usually a translator error.

Illegal character character (0xvalue) Compiler errorThe compiler encountered some invalid character in the input file. The hexadecimal value of the offending character is printed. This can also be caused by extra parameters passed to a function macro.

Page 243: UG

A p p e n d i x C , E r r o r m e s s a g e s 243

Illegal character in constant expression expression MAKE errorMAKE encountered a character not allowed in a constant expression. If the character is a letter, this probably indicates a misspelled identifier.

Illegal component to GRPDEF Linker errorThis is usually a translator error.

Illegal group definition: group Linker errorThis error is caused by a malformed GRPDEF record in an .OBJ file. This could result from custom-built .OBJ files or a bug in the translator used to generate the .OBJ file. If this occurs in a file created by Turbo C++, recompile the file. If the error persists, contact Borland Technical Support.

Illegal initialization Compiler errorIn C, initializations must be either a constant expression, or else the address of a global extern or static variable plus or minus a constant.

Illegal local public in module Linker warningThe message occurs when the linker sees an LPUBDEF record with an offset of zero for a VIRDEF that resides in an overlay segment. This can happen if you are trying to use structured exception support in an application that uses overlays.

Illegal octal digit Compiler errorAn octal constant containing a digit of 8 or 9 was found.

Illegal parameter to _ _emit_ _ Compiler errorYou supplied an argument to _ _emit_ _ that is not a constant or an address.

Illegal pointer subtraction Compiler errorThis is caused by attempting to subtract a pointer from a nonpointer.

Illegal structure operation Compiler errorIn C or C++, structures can be used with dot (.), address-of (&), or assignment (=) operators, or can be passed to or from functions as parameters. In C or C++, structures can also be used with overloaded operators. The compiler encountered a structure being used with some other operator.

Illegal to take address of bit field Compiler errorIt is not legal to take the address of a bit field, although you can take the address of other kinds of fields.

Illegal use of floating point Compiler errorFloating-point operands are not allowed in shift, bitwise Boolean, indirection (*), or certain other operators. The compiler found a floating-point operand with one of these prohibited operators.

Illegal use of member pointer Compiler errorPointers to class members can be used only with assignment, comparison, the .*, –>*, ?:, &&, and || operators, or passed as arguments to functions. The compiler has encountered a member pointer being used with a different operator.

Illegal use of pointer Compiler errorPointers can be used only with addition, subtraction, assignment, comparison, indirection (*) or arrow (–>) operators. Your source file used a pointer with some other operator.

Ill-formed pragma Compiler warningA pragma does not match one of the pragmas expected by the Turbo C++ compiler.

Image base address must be a multiple of 0x10000 Linker errorBased images must be aligned on 64k boundaries.

Images fixed at specific addresses typically will not run under Win32s Linker warningWindows 32s loads all applications in a single address space. It’s impossible to predict where you application is going to be loaded, because other 32-bit applications might have been loaded before yours. Fixed images must be loaded at their requested base address or the loader will fail to run them.

Implicit conversion of type1 to type2 not allowed Compiler errorWhen a member function of a class is called using a pointer to a derived class, the pointer value must be implicitly converted to point to the appropriate base class. In this case, such an implicit conversion is illegal.

Import symbol in module module clashes with prior module Librarian errorAn import symbol can appear only once in a library file. A module that is being added to the library contains an import that is already in a module of the library and it cannot be added again.

Page 244: UG

244 U s e r ’ s G u i d e

Import library library encountered in obj list Linker errorImport libraries (import.lib) are not permitted in the OBJ file list. They must always appear in the LIB file list.

Improper use of typedef identifier Compiler errorYour source file used a typedef symbol where a variable should appear in an expression. Check for the declaration of the symbol and possible misspellings.

Include files nested too deep Compiler errorWhen the compiler detects that header files are nested more than 1,000 levels deep, it assumes that the header file is recursive, and stops compilation with this (fatal) error.

filename (linenum): Incompatible attribute Linker errorThe linker encountered incompatible segment attributes in a CODE or DATA statement. For instance, both PRELOAD and LOADONCALL can’t be attributes for the same segment.

Incompatible type conversion Compiler errorThe cast requested can’t be done. Check the types.

Incorrect command-line argument: argument MAKE errorYou’ve used incorrect command-line arguments.

Incorrect command-line option: option Compiler errorThe compiler did not recognize the command-line parameter as legal.

Incorrect configuration file option: option Compiler errorThe compiler did not recognize the configuration file parameter as legal; check for a preceding hyphen ().

Incorrect number format Compiler errorThe compiler encountered a decimal point in a hexadecimal number.

Incorrect use of default Compiler errorThe compiler found no colon after the default keyword in a case statement.

Incorrect version of RLINK32.DLL Linker errorThe RLINK32.DLL used was not the correct version. Check to make sure you have the correct version of the DLL.

Initialization is only partially bracketed Compiler warningWhen structures are initialized, nested pairs of braces can be used to mark the initialization of each member of the structure. Bracketing the the members ensures that your idea and the compiler’s idea of the initializations are the same. The compiler issues this warning when the brackets are not equally matched.

Initializing enumeration with type Compiler warningYou’re trying to initialize an enum variable to a different type. For example,

enum count { zero, one, two } x = 2;results in this warning, because 2 is of type int, not type enum count. It is better programming practice to use an enum identifier instead of a literal integer when assigning to or initializing enum types.This error is reduced to a warning status to give existing programs a chance to compile.

Inline assembly not allowed Compiler errorYour source file contains inline assembly-language statements and you’re trying to compile it from within the integrated environment. You must use BCC to compile source files that contain inline assembly.

Inline assembly not allowed in inline and template functions Compiler errorThe compiler cannot handle inline assembly statements in a C++ inline or template function. You could eliminate the inline assembly code or, in case of an inline function, make this a macro or remove the inline storage class.

int and string types compared MAKE errorYou have tried to compare an integer operand with a string operand in an !if or !elif expression.

Internal compiler error Compiler errorAn error occurred in the internal logic of the compiler. This error shouldn’t occur in practice, but it is listed here for completeness in the event that a more specific error message is not generated.

Internal linker error errorcode Linker errorAn error occurred in the internal logic of TLINK. This error shouldn’t occur in practice, but is listed here for completeness in the event that a more specific error isn’t generated. If this error persists, write down the errorcode number and contact Borland Technical Support.

Page 245: UG

A p p e n d i x C , E r r o r m e s s a g e s 245

Invalid combination of opcode and operands Compiler errorThe built-in assembler does not accept this combination of operands. Possible causes are the following:

There are too many or too few operands for this assembler opcode.The number of operands is correct, but their types or order do not match the opcode; for example.DEC 1, MOV AX, or MOV 1,AX. Try prefacing the operands with type overrides; for example MOV AX, WORD PTR foo.

Invalid entry at segment:offset. Application may not work in real mode Linker warningThis warning indicates that a necessary entry was missing from the entry table of your executable file. The application may not work in real mode unless you fix the code and data.

Invalid entry point offset Linker errorThis message occurs only when modules with 32-bit records are linked. It means that the initial program entry point offset exceeds the DOS limit of 64K.

Invalid exe filename: filename Linker errorThe exe filename had an incorrect extension, such as .OBJ, .MAP, .LIB, .DEF, or .RES.

Invalid extended dictionary in library library: extended dictionaries ignored Linker warningThe extended dictionary in the library is invalid. Run TLIB /E on the library.

Invalid indirection Compiler errorThe indirection operator (*) requires a non-void pointer as the operand.

Invalid initial stack offset Linker errorThis message occurs only when modules with 32-bit records are linked. It means that the initial stack pointer value exceeds the DOS limit of 64K.

Invalid macro argument separator Compiler errorIn a macro definition, arguments must be separated by commas. The compiler encountered some other character after an argument name.

Invalid map filename: filename Linker errorThe map filename had an incorrect extension, such as .OBJ, .EXE, .DLL, .LIB, .DEF, or .RES.

Invalid page size value ignored Librarian warningInvalid page size is given. The page size must be a power of 2, and it cannot be smaller than 16 or larger than 32,768.

Invalid pointer addition Compiler errorYour source file attempted to add two pointers together.

Invalid register combination (e.g. [BP+BX]) Compiler errorThe built-in assembler detected an illegal combination of registers in an instruction. Valid index register combinations are [BX], [BP], [SI], [DI], [BX+SI], [BX+DI], [BP+SI], and [BP+DI]. Other index register combinations (such as [AX], [BP+BX], and [SI+DX]) are not allowed.Local variables (variables declared in procedures and functions) are usually allocated on the stack and accessed via the BP register. The assembler automatically adds [BP] in references to such variables, so even though a construct like Local[EBX] (where Local is a local variable) appears valid, it is not, because the final operand would become Local[BP+EBX].

Invalid segment definition Linker errorThe compiler produced a flawed object file. If this occurs in a file created by Turbo C++, recompile the file. If the problem persists, contact Borland Technical Support.

Invalid size specified for segment alignment Linker errorThis error occurs if an invalid value is specified for the Segment Alignment setting. The value specified must be an integral multiple of 2 and less than 64K. Common values are 16 and 512. This error only occurs when linking Windows applications.

Invalid size specified for segment packing Linker errorAn non-decimal number was provided on the command line for the segment packing size limit.

Invalid target–>/T target Linker errorThe command-line linker found an invalid target. Valid targets are ‘w’ and ‘d’.

Invalid template argument list Compiler errorIn a template declaration, the keyword template must be followed by a list of formal arguments enclosed within the < and > delimiters; an illegal template argument list was found.

Page 246: UG

246 U s e r ’ s G u i d e

Invalid template qualified name template::name Compiler errorWhen defining a template class member, the actual arguments in the template class name that is used as the left operand for the :: operator must match the formal arguments of the template class. For example:

template <class T> class X{

void f();};

template <class T> void X<T>::f(){}

The following would be illegal:

template <class T> void X<int>::f(){}

Invalid use of dot Compiler errorAn identifier must immediately follow a period operator (.).

Invalid use of template template Compiler errorOutside of a template definition, it is illegal to use a template class name without specifying its actual arguments. For example, you can use vector<int> but not vector.

Irreducible expression tree Compiler errorThis is a sign of some form of compiler error. An expression on the indicated line of the source file has caused the code generator to be unable to generate code. The offending expression should be avoided. Notify Borland Technical Support if the compiler encounters this error.

base is an indirect virtual base class of class Compiler errorA pointer to a C++ member of the given virtual base class cannot be created; an attempt has been made to create such a pointer (either directly or through a cast).

identifier is assigned a value that is never used Compiler warningThe variable appears in an assignment, but is never used anywhere else in the function just ending. The warning is indicated only when the compiler encounters the closing brace.

identifier is declared as both external and static Compiler warningThis identifier appeared in a declaration that implicitly or explicitly marked it as global or external, and also in a static declaration. The identifier is taken as static. You should review all declarations for this identifier.

identifier is declared but never used Compiler warningYour source file declared the named variable as part of the block just ending, but the variable was never used. The warning is indicated when the compiler encounters the closing brace of the compound statement or function. The declaration of the variable occurs at the beginning of the compound statement or function.

constructor is not a base class of class Compiler errorA C++ class constructor class is trying to call a base class constructor constructor, or you are trying to change the access rights of class::constructor. constructor is not a base class of class. Check your declarations.

identifier is not a member of struct Compiler errorYou are trying to reference identifier as a member of struct, but it is not a member. Check your declarations.

identifier is not a non-static data member and can’t be initialized here Compiler errorOnly data members can be initialized in the initializers of a constructor. This message means that the list includes a static member or function member.

identifier is not a parameter Compiler errorIn the parameter declaration section of an old-style function definition, identifier is declared but is not listed as a parameter. Either remove the declaration or add identifier as a parameter.

type is not a polymorphic class type Compiler errorA dynamic_cast was used with a pointer to a class that was compiled with the –RT compiler option disabled.

identifier is not a public base class of classtype Compiler errorThe right operand of a .*, –>*, or ::operator was not a pointer to a member of a class that is either identical to or an unambiguous accessible base class of the left operand’s class type. The class of the member pointer must match (or be a public base class of) the object operand.

Page 247: UG

A p p e n d i x C , E r r o r m e s s a g e s 247

filename is not a valid library Linker warningThis error occurs if a file that wasn’t a valid library module was passed to the linker in the library section.

member is not a valid template type member Compiler errorA member of a template with some actual arguments that depend on the formal arguments of an enclosing template was found not to be a member of the specified template in a particular instance.

member is not accessible Compiler errorYou are trying to reference C++ class member member, but it is private or protected and cannot be referenced from this function. This sometimes happens when attempting to call one accessible overloaded member function (or constructor), but the arguments match an inaccessible function. The check for overload resolution is always made before checking for accessibility. If this is the problem, try an explicit cast of one or more parameters to select the desired accessible function.

function is obsolete Compiler warningThe compiler generates this warning message when it encounters a function that is obsolete. Functions marked by this error message will be removed from the next version of the product.

Last parameter of operator must have type int Compiler errorWhen a postfix operator++ or operator– – is declared, the last parameter must be declared with the type int.

Library contains COMDEF records—extended dictionary not created Librarian warningAn object record being added to a library contains a COMDEF record. This is not compatible with the extended dictionary option.

Library too large, restart with library page size size Librarian errorThe library being created could not be built with the current library page size.

Limit of 254 segments for new executable file exceeded Linker errorThe new executable file format only allows for 254 segments. Examine the map file. Usually one of two things cause this problem. If the application is large model, the code segment packing size could be so small that there are too many code segments. Increasing the code segment packing size with the /P option could help. The other possibility is that you have a lot of far data segments with only a few bytes of data in them. The map file will tell you if this is happening. In this case, reduce the number of far data segments.

Linkage specification not allowed Compiler errorLinkage specifications such as extern “C” are allowed only at the file level. Move this function declaration out to the file level.

Linker name conflict for function Compiler errorWhen the mangled name of a C++ inline function or a virtual table is too long and has to be truncated (this happens most often with templates), and the truncated name matches a previously generated function or virtual table, this error is issued by the compiler. The problem can be fixed by changing the name of the class or function, or by compiling with the –Vs option.

Linker stack overflow Linker errorThe linker uses a recursive procedure for marking modules to be included in an executable image from libraries. This procedure can cause stack overflows in extreme circumstances. If you get this error message, remove some modules from libraries, include them with the object files in the link, and try again.

Lvalue required Compiler errorThe left hand side of an assignment operator must be an addressable expression. These include numeric or pointer variables, structure field references or indirection through a pointer, or a subscripted array element.

Macro argument syntax error Compiler errorAn argument in a macro definition must be an identifier. The compiler encountered some non-identifier character where an argument was expected.

Macro expansion too long Compiler errorA macro cannot expand to more than 4,096 characters.

Macro expansion too long MAKE errorA macro cannot expand to more than 4,096 characters. This error often occurs if a macro recursively expands itself. A macro cannot legally expand to itself.

Macro substitute text string is too long MAKE errorMacro replace text string is too long MAKE error

The macro substitution or replacement text string overflowed MAKE’s internal buffer of 512 bytes.

Page 248: UG

248 U s e r ’ s G u i d e

main must have a return type of int Compiler errorIn C++, function main has special requirements, one of which is that it cannot be declared with any return type other than int.

Malformed command-line Compiler errorAn invalid entry in the command line was found.

Matching base class function for function has different dispatch number. Compiler errorIf a DDVT function is declared in a derived class, the matching base class function must have the same dispatch number as the derived function.

Matching base class function for function is not dynamic Compiler errorIf a DDVT function is declared in a derived class, the matching base class function must also be dynamic.

Maximum precision used for member pointer type type Compiler warningWhen you use the –Vmd option, the compiler has to use the most general (and the least efficient) representation for that member pointer type when it is declared and its class hasn’t been fully defined. This can cause less efficient code to be generated (and make the member pointer type unnecessarily large), and can also cause problems with separate compilation.

Member function must be called or its address taken Compiler errorWhen a member function is used in an expression, either it must be called or its address must be taken using the & operator. In this case, a member function has been used in an illegal context.

Member identifier expected Compiler errorThe name of a structure or C++ class member was expected here, but not found. The right side of a dot (.) or arrow (–>) operator must be the name of a member in the structure or class on the left of the operator.

Member is ambiguous: member1 and member2 Compiler errorYou must qualify the member reference with the appropriate base class name. In C++ class class, member member can be found in more than one base class, and was not qualified to indicate which was meant. This happens only in multiple inheritance, where the member name in each base class is not hidden by the same member name in a derived class on the same path. The C++ language rules require that this test for ambiguity be made before checking for access rights (private, protected, public). It is therefore possible to get this message even though only one (or none) of the members can be accessed.

Member member cannot be used without an object Compiler errorThis means that the user has written class::member where member is an ordinary (nonstatic) member, and there is no class to associate with that member. For example, it is legal to write obj.class::member, but not to write class::member.

Member member has the same name as its class Compiler errorA static data member, enumerator, member of an anonymous union, or nested type cannot have the same name as its class. Only a member function or a nonstatic member can have a name that is identical to its class.

Member member is initialized more than once Compiler errorIn a C++ class constructor, the list of initializations following the constructor header includes the same member name more than once.

Member pointer required on right side of .* or –>* Compiler errorThe right side of a C++ dot-star (.*) or an arrow-star (–>*) operator must be declared as a pointer to a member of the class specified by the left side of the operator. In this case, the right side is not a member pointer.

Memory full listing truncated! Librarian warningThe librarian has run out of memory creating a library listing file. A list file will be created but is not complete.

Memory reference expected Compiler errorThe built-in assembler requires a memory reference. Most likely you have forgotten to put square brackets around an index register operand; for example, MOV AX,BX+SI instead of MOV AX,[BX+SI].

Misplaced break Compiler errorThe compiler encountered a break statement outside a switch or looping construct.

Misplaced continue Compiler errorThe compiler encountered a continue statement outside a looping construct.

Misplaced decimal point Compiler errorThe compiler encountered a decimal point in a floating-point constant as part of the exponent.

Page 249: UG

A p p e n d i x C , E r r o r m e s s a g e s 249

Misplaced elif directive Compiler errorThe compiler encountered an #elif directive without any matching #if, #ifdef, or #ifndef directive.

Misplaced elif statement MAKE errorAn !elif directive is missing a matching !if directive.

Misplaced else Compiler errorThe compiler encountered an else statement without a matching if statement. An extra else statement could cause this message, but it could also be caused by an extra semicolon, missing braces, or some syntax error in a previous if statement.

Misplaced else directive Compiler errorThe compiler encountered an #else directive without any matching #if, #ifdef, or #ifndef directive.

Misplaced else statement MAKE errorAn !else directive does not have a matching !if directive.

Misplaced endif directive Compiler errorThe compiler encountered an #endif directive without a matching #if, #ifdef, or #ifndef directive.

Misplaced endif statement MAKE errorAn !endif directive does have a matching !if directive.

filename (linenum): Missing internal name Linker errorIn the IMPORTS section of the module definition file there was a reference to an entry specified via module name and ordinal number. When an entry is specified by ordinal number an internal name must be assigned to this import definition. Your program uses this internal name to refer to the imported definition. The syntax in the module definition file should be

<internalname>=<modulename>.<ordinal>

Mixed common types in module module. Cannot mix COMDEFs and VIRDEFs. Linker errorYou cannot mix both COMDEFs and VIRDEFs. Turn off the –Fc switch to stop generating COMDEFs, or turn on the –Vs switch to stop generating VIRDEFs.

Mixing pointers to different ‘char’ types Compiler warningYou converted a signed char pointer to an unsigned char pointer, or vice versa, without using an explicit cast. (Strictly speaking, this is incorrect, but it is often harmless.)

Multiple base classes require explicit class names Compiler errorIn a C++ class constructor, each base class constructor call in the constructor header must include the base class name when there is more than one immediate base class.

Multiple declaration for identifier Compiler errorThis identifier was improperly declared more than once. This might be caused by conflicting declarations such as int a; double a;, by a function declared two different ways, by a label repeated in the same function, or by some declaration repeated other than an extern function or a simple variable (in C).

Multiple entry points defined Linker errorMore than one entry point was defined for the application. You can only have one entry point.

identifier must be a member function Compiler errorMost C++ operator functions can be members of classes or ordinary nonmember functions, but certain ones are required to be members of classes. These are operator =, operator –>, operator (), and type conversions. This operator function is not a member function but should be.

identifier must be a member function or have a parameter of class type Compiler errorMost C++ operator functions must have an implicit or explicit parameter of class type. This operator function was declared outside a class and does not have an explicit parameter of class type.

identifier must be a previously defined class or struct Compiler errorYou are attempting to declare identifier to be a base class, but either it is not a class or it has not yet been fully defined. Correct the name or rearrange the declarations.

identifier must be a previously defined enumeration tag Compiler errorThis declaration is attempting to reference identifier as the tag of an enum type, but it has not been so declared. Correct the name, or rearrange the declarations.

Page 250: UG

250 U s e r ’ s G u i d e

identifier must be declared with no parameters Compiler errorThis C++ operator function was incorrectly declared with parameters.

identifier must be declared with one parameter Compiler errorThis C++ operator function was incorrectly declared with more than one parameter.

operator must be declared with one or no parameters Compiler errorWhen operator++ or operator – – is declared as a member function, it must be declared to take either no parameters (for the prefix version of the operator) or one parameter of type int (for the postfix version).

operator must be declared with one or two parameters Compiler errorWhen operator++ or operator – – is declared as a nonmember function, it must be declared to take either one parameter (for the prefix version of the operator) or two parameters (for the postfix version).

identifier must be declared with two parameters Compiler errorThis C++ operator function was incorrectly declared with other than two parameters.

Must take address of a memory location Compiler errorYour source file used the address-of operator (&) with an expression that cannot be used that way; for example, a register variable (in C).

Need an identifier to declare Compiler errorIn this context, an identifier was expected to complete the declaration. This might be a typedef with no name, or an extra semicolon at file level. In C++, it might be a class name improperly used as another kind of identifier.

‘new’ and ‘delete’ not supported IDE debugger errorThe integrated debugger does not support the evaluation of ‘new’ and ‘delete’.

New executable header overflowed 64K Linker errorThe size of all the components of the new executable header of a Windows application is greater than 64K. Usually this is caused by a very large resident name table. If your application exports many functions, try exporting more of them by ordinal value , rather than by name. See the /Gr and /Gn linker options, documented under “Advanced Linker” on page 57 for more information.

No : following the ? Compiler errorThe question mark (?) and colon (:) operators do not match in this expression. The colon might have been omitted, or parentheses might be improperly nested or missing.

No automatic data segment Linker warningNo group named DGROUP was found. Because Borland’s initialization files define DGROUP, you will only see this error if you don’t link with an initialization file and your program doesn’t define DGROUP. Windows uses DGROUP to find the local data segment. The DGROUP is required for Windows applications (but not DLLs) unless DATA NONE is specified in the module definition file.

No base class to initialize Compiler errorThis C++ class constructor is trying to implicitly call a base class constructor, but this class was declared with no base classes. Check your declarations.

No closing quote MAKE errorThere is no closing quote for a string expression in a !if or !elif expression.

No declaration for function function Compiler warningYou called a function without first declaring that function. In C, you can declare a function without presenting a prototype, as in int func();. In C++, every function declaration is also a prototype; this example is equivalent to int func(void);. The declaration can be either classic or modern (prototype) style.

No module definition file specified; using defaults Linker warningThis warning occurs when you do not specify a .DEF file for the link.

No file name ending Compiler errorThe file name in an #include statement was missing the correct closing quote or angle bracket.

No filename ending MAKE errorThe file name in an !include statement is missing the correct closing quote or angle bracket.

No file names given Compiler errorThe command line of the Turbo C++ command-line compiler (BCC) contained no file names. You must specify a source file name.

Page 251: UG

A p p e n d i x C , E r r o r m e s s a g e s 251

No internal name for IMPORT in .DEF file Linker errorThe .DEF file has a semantic error. You probably forgot to put the internal name for an import before the module name. For example,

IMPORTS_foo.1

The proper syntax is

IMPORTS_foo=mydll.1

No macro before = MAKE errorYou must give a macro a name before you can assign it a value.

No match found for wildcard expression MAKE errorThere are no files matching the wildcard expression for MAKE to expand. For example, if you write

prog.exe: *.objMAKE sends this error message if there are no files with the extension .OBJ in the current directory.

No output file specified Linker errorNo EXE or DLL file was specified. Because the linker defaults to the first .OBJ name, this error is usually caused because no object object files were included.

No program starting address defined Linker warningThis warning means that no module defined the initial starting address of the program. This is probably caused by forgetting to link in the initialization module C0x.OBJ.

No stack Linker warningThis warning is issued if no stack segment is defined in any of the object files or in any of the libraries included in the link. This is a normal message for the tiny memory model in Turbo C++, or for any application program that will be converted to a .COM file. Except for DLLs, this indicates an error.If a Turbo C++ program produces this message for any but the tiny memory model, make sure you are using the correct C0x startup object files.

No stub for fixup at address Linker warningThis error occurs when the target for a fixup is in an overlay segment, but no stub is found for a target external. This is usually the result of not making public a symbol in an overlay that is referenced from the same module.

No terminator specified for inline file operator MAKE errorThe makefile contains either the && or << command-line operators to start an inline file, but the file is not terminated.

No type information IDE debugger errorThe integrated debugger has no type information for this variable. Ensure that you’ve compiled the module with debug information.

Non-const function function called for const object Compiler warningA non-const member function was called for a const object. This is an error, but was reduced to a warning to give existing programs a chance to work.

Nonportable pointer comparison Compiler warningYour source file compared a pointer to a nonpointer other than the constant zero. You should use a cast to suppress this warning if the comparison is proper.

Nonportable pointer conversion Compiler errorAn implicit conversion between a pointer and an integral type is required, but the types are not the same size. This cannot be done without an explicit cast. This conversion might not make any sense, so be sure this is what you want to do.

Nonportable pointer conversion Compiler warningA nonzero integral value is used in a context where a pointer is needed or where an integral value is needed; the sizes of the integral type and pointer are the same. Use an explicit cast if this is what you really meant to do.

Nonresident Name Table is greater than 64K Linker warningThe maximum size of the Nonresident name table is 64K (in accordance with the industry-wide executable specification standard). The linker continues with the link but ignores any subsequent Nonresident names encountered during linking.

Page 252: UG

252 U s e r ’ s G u i d e

Nontype template argument must be of scalar type Compiler errorA nontype formal template argument must have scalar type; it can have an integral, enumeration, or pointer type.

Non-ANSI Keyword Used: keyword Compiler errorA non-ANSI keyword (such as _ _fastcall) was used when strict ANSI conformance was requested via the –A option.

Non-virtual function function declared pure Compiler errorOnly virtual functions can be declared pure, because derived classes must be able to override them.

Non-volatile function function called for volatile object Compiler warningIn C++, a class member function was called for a volatile object of the class type, but the function was not declared with volatile following the function header. Only a volatile member function can be called for a volatile object.

filename not a MAKE MAKE errorThe file you specified with the –f option is not a makefile.

Not a valid expression format type IDE debugger errorYou used an invalid format specifier following an expression in the integrated debugger. A valid format specifier is a repeat value (optional) followed by one of the following format specifiers: c, d, f[n], h, m, p, r, s, or x.

Not an allowed type Compiler errorYour source file declared some sort of forbidden type; for example, a function returning a function or array.

Not enough memory MAKE errorAll your working storage has been exhausted.

Not enough memory to run application Linker errorThere is not enough memory to run TLINK. Try reducing the size of any RAM disk or disk cache currently active. If you’re running real mode, try using the MAKE –S option, or removing TSRs and network drivers.

Not enough memory for command-line buffer Librarian errorThis error occurs when the librarian runs out of memory.

module not found in library Librarian warningAn attempt to perform either a ‘_’ or ‘*’ on a library has been made and the indicated object does not exist in the library.

Null pointer assignment Run-time errorWhen a small or medium memory model program exits, a check is made to determine if the contents of the first few bytes within the program’s data segment have changed. These bytes would never be altered by a working program. If they have been changed, the message Null pointer assignment is displayed to inform you that (most likely) a value was stored to an uninitialized pointer. The program might appear to work properly in all other respects; however, this is a serious bug which should be attended to immediately. Failure to correct an uninitialized pointer can lead to unpredictable behavior (including locking the computer up in the large, compact, and huge memory models). You can use the integrated debugger to track down null pointers.

Numeric constant too large Compiler errorString and character escape sequences larger than hexadecimal \xFF or octal \377 cannot be generated. Two-byte character constants can be specified by using a second backslash. For example, \x0D\x0A represents a two-byte constant A numeric literal following an escape sequence should be broken up like this:

printf("\x0D" '"12345");This prints a carriage return followed by 12345.

Object module filename is invalid Librarian errorThe librarian could not understand the header record of the object module being added to the library and has assumed that it is an invalid module.

Objects of type type cannot be initialized with {} Compiler errorOrdinary C structures can be initialized with a set of values inside braces. C++ classes can be initialized with constructors only if the class has constructors, private members, functions, or base classes that are virtual.

Old debug information in module module will be ignored Linker warningDebug information in the .OBJ file is incompatible with this linker, and it will be ignored.

Only <<KEEP or <<NOKEEP MAKE errorYou have specified something besides KEEP or NOKEEP when closing a temporary inline file.

Only member functions may be ‘const’ or ‘volatile’ Compiler errorSomething other than a class member function has been declared const and/or volatile.

Page 253: UG

A p p e n d i x C , E r r o r m e s s a g e s 253

Only one of a set of overloaded functions can be “C” Compiler errorC++ functions are by default overloaded, and the compiler assigns a new name to each function. If you want to override the compiler’s assigning a new name by declaring the function extern “C”, you can do this for only one of a set of functions with the same name. (Otherwise the linker would find more than one global function with the same name.)

Operand of delete must be non-const pointer Compiler errorIt is illegal to delete a constant pointer value using operator delete.

Operator [ ] missing ] Compiler errorThe C++ operator [ ] was declared as operator [. You must add the missing ] or otherwise fix the declaration.

Operator –> must return a pointer or a class Compiler errorThe C++ operator –> function must be declared to either return a class or a pointer to a class (or struct or union). In either case, it must be something to which the –> operator can be applied.

Operator delete must return void Compiler errorThis C++ overloaded operator delete was declared in some other way.

Operator delete[] must return void Compiler errorThis C++ overloaded operator delete was declared in some other way. Declare the delete with one of the following:

A single void* parameterA second parameter of type size_t

If you use the second version, it will be used in preference to the first version. The global operator delete can be declared using the single-parameter form only.

Operator must be declared as function Compiler errorAn overloaded operator was declared with something other than function type.

Operator new must have an initial parameter of type size_t Compiler errorOperator new can be declared with an arbitrary number of parameters, but it must always have at least one parameter that specifies the amount of space to allocate.

Operator new[] must have an initial parameter of type size_t Compiler errorOperator new can be declared with an arbitrary number of parameters. It must always have at least one parameter that specifies the amount of space to allocate.

Operator new must return an object of type void * Compiler errorThe C++ overloaded operator new was declared another way.

Operator new[] must return an object of type void * Compiler errorThis C++ overloaded operator new was declared another way.

Operators may not have default argument values Compiler errorIt is illegal for overloaded operators to have default argument values.

Optimizer: Error reading input file Linker errorThis message indicates a hardware error; reading from the device failed.

Optimizer: Error writing output file Linker errorThis message indicates a hardware error, or a full disk drive; writing to the device failed.

Optimizer: File is not a new exe (NE format), optimization request ignored Linker warningThe 16-bit /Ox linker switches are validfor only 16-bit Windows and DMPI executibles.

Optimizer: Out of memory Linker errorThere is not enough memory available to perform the linker optimizations.

Out of memory Compiler errorThe total working storage is exhausted. Compile the file on a machine with more memory.

Out of memory Librarian errorFor any number of reasons, the librarian or Turbo C++ ran out of memory while building the library. For many specific cases a more detailed message is reported, leaving “Out of memory” to be the basic catchall for general low-memory situations.If you get this message because the public symbol tables have grown too large, you must free up memory. For the command line this could involve removing TSRs or device drivers using real mode memory or close windows. In the IDE, some additional memory can be gained by closing editors.

Page 254: UG

254 U s e r ’ s G u i d e

Out of memory Linker errorThe linker has run out of dynamically allocated memory needed during the link process. This error is a catchall for running into a TLINK limit on memory usage. This usually means that too many modules, externals, groups, or segments have been defined by the object files being linked together. You can try reducing the size of RAM disks and/or disk caches that might be active.

Out of memory at library library: extended dictionaries ignored Linker warningThe linker ran out of memory allocating space to cache the extended dictionaries. The linker will ignore extended dictionaries and proceed with the link.

Out of memory creating extended dictionary Librarian errorThe librarian has run out of memory creating an extended dictionary for a library. The library is created but will not have an extended dictionary.

Out of memory for block block Linker errorThis error should not occur. If it does, call Borland Technical Support and give them the text of the message, including the block name.

Out of memory reading LE/LIDATA record from object module Librarian errorThe librarian is attempting to read a record of data from the object module, but it cannot get a large enough block of memory. If the module that is being added has a large data segment or segments, it is possible that adding the module before any other modules might resolve the problem. By adding the module first, there will be memory available for holding public symbol and module lists later.

Out of space allocating per module debug struct Librarian errorThe librarian ran out of memory while allocating space for the debug information associated with a particular object module. Removing debugging information from some modules being added to the library might resolve the problem.

Output device is full Librarian errorUsually this error means that no space is left on the disk.

Overlays generated and no overlay manager included Linker warningThis warning is issued if overlays are created but the symbol _ _OVRTRAP_ _ is not defined in any of the object modules or libraries linked in. The standard overlay library (OVERLAY.LIB) defines this symbol.

Overlays ignored in new executable image Linker warningThis error occurs if you attempt to link a Windows program with the /o option on. Windows executables can’t be overlaid, although, with discardable code segments, you should be able to achieve a similar effect.

Overlays only supported in medium, large, and huge memory models Compiler errorOnly programs using the medium, large, or huge memory models can be overlaid.

Overloadable operator expected Compiler errorAlmost all C++ operators can be overloaded. The only ones that can’t be overloaded are the field-selection dot (.), dot-star (.*), double colon (::), and conditional expression (?:). The preprocessor operators (# and ##) are not C or C++ language operators and thus cannot be overloaded. Other nonoperator punctuation, such as a semicolon (;) cannot be overloaded.

Overloaded function name ambiguous in this context Compiler errorThe only time an overloaded function name can be used without actually calling the function is when a variable or parameter of an appropriate type is initialized or assigned. This error was issued because an overloaded function name has been used in some other context.

Overloaded function resolution not supported IDE debugger errorThe only time an overloaded function name can be used without actually calling the function is when a variable or parameter if a appropriate type is initialized or assigned. In this case, an overloaded function name has been used in some other context.

Overloaded prefix ‘operator operator’ used as a postfix operator Compiler warningWith the latest specification of C++, it is now possible to overload both the prefix and postfix versions of the ++ and – – operators. To allow older code to compile, Turbo C++ uses the prefix operator and issues this warning whenever only the prefix operator is overloaded, but is used in a postfix context.

P1001 Unable to read file filename Help project errorThe file specified in the project file is unreadable. This is a DOS file error.

P1003 Invalid path specified in Root option Help project errorThe path specified by the Root option cannot be found. The compiler uses the current working directory.

Page 255: UG

A p p e n d i x C , E r r o r m e s s a g e s 255

P1005 Path and filename exceed limit of 79 characters Help project errorThe absolute path name, or the combined root and relative pathname, exceed the DOS limit of 79 characters. The file is skipped.

P1007 Root path exceeds maximum limit of 66 characters Help project errorThe specified root path name exceeds the DOS limit of 66 characters. The path name is ignored and the compiler uses the current working directory.

P1009 [FILES] section missing Help project errorThe [Files] section is required. The compilation is aborted.

P1011 Option optionname previously defined Help project errorThe specified option was defined previously. The compiler ignores the attempted redefinition.

P1013 Project file extension cannot be .HLP Help project errorYou cannot specify that the compiler use a project file with the .HLP extension. Normally, project files are given the .HPJ extension.

P1015 Unexpected end-of-file Help project errorThe compiler has unexpectedly come to the end of the project file. There might be an open comment in the project file or an included file.

P1017 Parameter exceeds maximum length of 128 characters Help project errorAn option, context name or number, build tag, or other parameter on the specified line exceeds the limit of 128 characters. The line is ignored.

P1021 Context number already used in [MAP] section Help project errorThe context number on the specified line in the project file was previously mapped to a different context string. The line is ignored.

P1023 Include statements nested too deeply Help project errorThe #include statement on the specified line has exceeded the maximum of five include levels.

P1025 Section heading sectionname unrecognized Help project errorA section heading that is not supported by the compiler has been used. The line is skipped.

P1027 Bracket missing from section heading sectionname Help project errorThe right bracket (]) is missing from the specified section heading. Insert the bracket and compile again.

P1029 Section heading missing Help project errorThe section heading on the specified line is not complete. This error is also reported if the first entry in the project file is not a section heading. The compiler continues with the next line.

P1030 Section sectionname previously defined Help project errorA duplicate section has been found in the project file. The lines under the duplicated section heading are ignored and the compiler continues from the next valid section heading.

P1031 Maximum number of build tags exceeded Help project errorThe maximum number of build tags that can be defined is 30. The excess tags are ignored.

P1033 Duplicate build tag in [BUILDTAGS] section Help project errorA build tag in the [BUILDTAGS] section has been repeated unnecessarily

P1035 Build tag length exceeds maximum Help project errorThe build tag on the specified line exceeds the maximum of 32 characters. The compiler skips this entry.

P1037 Build tag tagname contains invalid characters Help project errorBuild tags can contain only alphanumeric characters or the underscore (_) character. The line is skipped.

P1039 [BUILDTAGS] section missing Help project errorThe BUILD option declared a conditional build, but there is no [BuildTags] section in the project file. All topics are included in the build.

P1043 Too many tags in Build expression Help project errorThe Build expression on the specified line has used more than the maximum of 20 build tags. The compiler ignores the line.

P1045 [ALIAS] section found after [MAP] section Help project errorWhen used, the [Alias] section must precede the [Map] section in the project file. The [Alias] section is skipped otherwise.

Page 256: UG

256 U s e r ’ s G u i d e

P1047 Context string contextname already assigned an alias Help project errorYou cannot do: a=b then a=c<_>(A context string can only have one alias.)The specified context string has previously been aliased in the [Alias] section. The attempted reassignment on this line is ignored.

P1049 Alias string aliasname already assigned Help project errorYou cannot do: a=b then b=cAn alias string cannot, in turn, be assigned another alias.

P1051 Context string contextname cannot be used as alias string Help project errorYou cannot do: a=b then c=aA context string that has been assigned an alias cannot be used later as an alias for another context string.

P1053 Maximum number of font ranges exceeded Help project errorThe maximum number of font ranges that can be specified is five. The rest are ignored.

P1055 Current font range overlaps previously defined range Help project errorA font size range overlaps a previously defined mapping. Adjust either font range to remove any overlaps. The second mapping is ignored.

P1056 Unrecognized font name in Forcefont option Help project errorA font name not supported by the compiler has been encountered. The font name is ignored and the compiler uses the default Helvetica font.

P1057 Font name too long Help project errorFont names cannot exceed 20 characters. The font is ignored.

P1059 Invalid multiple-key syntax Help project errorThe syntax used with a MULTIKEY option is unrecognized.

P1061 Character already used Help project errorThe specified keywordtable identifier is already in use. Choose another character.

P1063 Characters ‘K’ and ‘k’ cannot be used Help project errorThese characters are reserved for Help’s normal keyword table. Choose another character.

P1065 Maximum number of keyword tables exceeded Help project errorThe limit of five keyword tables has been exceeded. Reduce the number. The excess tables are ignored.

P1067 Equal sign missing Help project errorAn option is missing its required equal sign on the specified line. Check the syntax for the option.

P1069 Context string missing Help project errorThe line specified is missing a context string before an equal sign.

P1071 Incomplete line in sectionname section Help project errorThe entry on the specified line is not complete. The line is skipped.

P1073 Unrecognized option in [OPTIONS] section Help project errorAn option has been used that is not supported by the compiler. The line is skipped.

P1075 Invalid build expression Help project errorThe syntax used in the build expression on the specified line contains one or more logical or syntax errors.

P1077 Warning level must be 1, 2, or 3 Help project errorThe WARNING reporting level can only be set to 1, 2, or 3. The compiler will default to full reporting (level 3).

P1079 Invalid compression option Help project errorThe COMPRESS option can only be set to TRUE or FALSE. The compilation continues without compression.

P1081 Invalid title string Help project errorThe TITLE option defines a string that is null or contains more than 32 characters. The title is truncated.

P1083 Invalid context identification number Help project errorThe context number on the specified line is null or contains invalid characters.

P1085 Unrecognized text Help project errorThe unrecognizable text that follows valid text in the specified line is ignored.

Page 257: UG

A p p e n d i x C , E r r o r m e s s a g e s 257

P1086 Invalid font-range syntax Help project errorThe font-range definition on the specified line contains invalid syntax. The compiler ignores the line. Check the syntax for the MAPFONTSIZE option.

P1089 Unrecognized sort ordering Help project errorYou have specified an ordering that is not supported by the compiler. Contact Borland Technical Support for clarification of the error.

Parameter names are used only with a function body Compiler errorWhen declaring a function (not defining it with a function body), you must use either empty parentheses or a function prototype. A list of parameter names only is not allowed.Example declarations include

int func(); // declaration without prototype--OKint func(int, int); // declaration with prototype--OKint func(int i, int j); // parameter names in prototype--OKint func(i, j); // parameter names only--illegal

Parameter number missing name Compiler errorIn a function definition header, this parameter consisted only of a type specifier number with no parameter name. This is not legal in C. (It is allowed in C++, but there’s no way to refer to the parameter in the function.)

Parameter parameter is never used Compiler warningThe named parameter, declared in the function, was never used in the body of the function. This might or might not be an error and is often caused by misspelling the parameter. This warning can also occur if the identifier is redeclared as an automatic (local) variable in the body of the function. The parameter is masked by the automatic variable and remains unused.

path - path is too long Librarian errorThis error occurs when the length of any of the library file or module file’s path is greater than 64 characters.

Pointer to structure required on left side of –> or –>* Compiler errorNothing but a pointer is allowed on the left side of the arrow (–>) in C or C++. In C++ a –>* operator is allowed.

Possible reference to undefined extern xxxx::i in module module Linker warningStatic data member has been declared but not defined in your application.

Possible unresolved external sym referenced from module mod Linker warningThis warning appears only for static data members of classes that have been declared but not defined.

Possible use of identifier before definition Compiler warningYour source file used the named variable in an expression before it was assigned a value. The compiler uses a simple scan of the program to determine this condition. If the use of a variable occurs physically before any assignment, this warning will be generated. Of course, the actual flow of the program might assign the value before the program uses it.

Possibly incorrect assignment Compiler warningThis warning is generated when the compiler encounters an assignment operator as the main operator of a conditional expression (that is, as part of an if, while or do-while statement). More often than not, this is a typographical error for the equality operator. If you want to suppress this warning, enclose the assignment in parentheses and compare the whole thing to zero explicitly. Thus,

if (a = b) ...should be rewritten as

if ((a = b) != 0) ...

Program entry point may not reside in an overlay Linker errorAlthough almost all of an application can be overlaid, the initial starting address cannot reside in an overlay. This error usually means that an attempt was made to overlay the initialization module (C0x.OBJ, for instance) by specifying the /o option before the startup module.

Public symbol in module module1 clashes with prior module module2 Librarian errorA public symbol can appear only once in a library file. A module that is being added to the library contains a public symbol that is already in a module of the library and cannot be added. The command-line message reports the module2 name.

Page 258: UG

258 U s e r ’ s G u i d e

Public symbol in module filename clashes with prior module Librarian errorA public symbol can appear only once in a library file. A module that is being added to the library contains a public symbol that is already in a module of the library and cannot be added.

R2001 Unable to open bitmap file filename Help RTF errorThe specified bitmap file is unreadable. This is a DOS file error.

R2003 Unable to include bitmap file filename Help RTF errorThe specified bitmap file could not be found or is unreadable. This is a DOS file error or an out-of-memory condition.

R2005 Disk full Help RTF errorThe Help resource file could not be written to disk. Create more space on the destination drive.

R2009 Cannot use reserved DOS device name for file filename Help RTF errorA file has been referred to as COM1, LPT2, PRN, and so on. Rename the file.

R2013 Output file filename already exists as a directory Help RTF errorThere is a subdirectory in the Help project root with the same name as the desired Help resource file. Move or rename the subdirectory.

R2015 Output file filename already exists as read-only Help RTF errorThe specified filename cannot be overwritten by the Help resource file because the file has a read-only attribute. Rename the project file or change the file’s attribute.

R2017 Path for file filename exceeds limit of 79 characters Help RTF errorThe absolute path name, or the combined root and relative path name, to the specified file exceed the DOS limit of 79 characters. The file is ignored.

R2019 Cannot open file filename Help RTF errorThe specified file is unreadable. This is a DOS file error.

R2021 Cannot find file filename Help RTF errorThe specified file could not be found or is unreadable. This is a DOS file error or an out-of-memory condition.

R2023 Not enough memory to build Help file Help RTF errorTo free up memory, unload any unneeded applications, device drivers, and memory-resident programs.

R2025 File environment error Help RTF errorThe compiler has insufficient available file handles to continue. Increase the values for FILES= and BUFFERS= in your CONFIG.SYS file and reboot.

R2027 Build tag tagname not defined in [BUILDTAGS] section of project file Help RTF errorThe specified build tag has been assigned to a topic, but not declared in the project file. The tag is ignored for the topic.

R2033 Context string in Map section not defined in any topic Help RTF errorThere are one or more context strings defined in the project file that the compiler could not find topics for.

R2035 Build expression missing from project file Help RTF errorThe topics have build tags, but there is no Build= expression in the project file. The compiler includes all topics in the build.

R2037 File filename cannot be created, due to previous error(s) Help RTF errorThe Help resource file could not be created because the compiler has no topics remaining to be processed. Correct the errors that preceded this error and recompile.

R2039 Unrecognized table formatting in topic topicnumber of file filename Help RTF errorThe compiler ignores table formatting that is unsupported in Help. Reformat the entries as linear text if possible.

R2041 Jump context_string unresolved in topic topicnumber of file filename Help RTF errorThe specified topic contains a context string that identifies a nonexistent topic. Check spelling, and that the desired topic is included in the build.

R2043 Hotspot text cannot spread over paragraphs Help RTF errorA jump term spans two paragraphs. Remove the formatting from the paragraph mark.

R2045 Maximum number of tab stops reached in topic topicnumber of file filename Help RTF errorThe limit of 32 tab stops has been exceeded in the specified topic. The default stops are used after the 32nd tab.

R2047 File filename not created Help RTF errorThere are no topics to compile, or the build expression is false for all topics. There is no Help resource file created.

Page 259: UG

A p p e n d i x C , E r r o r m e s s a g e s 259

R2049 Context string text too long in topic topicnumber of file filename Help RTF errorContext string hidden text cannot exceed 64 characters. The string is ignored.

R2051 File filename is not a valid RTF topic file Help RTF errorThe specified file is not an RTF file. Check that you have saved the topic as RTF from your word processor.

R2053 Font fontname in file filename not in RTF font table Help RTF errorA font not defined in the RTF header has been entered into the topic. The compiler uses the default system font.

R2055 File filename is not a usable RTF topic file Help RTF errorThe specified file contains a valid RTF header, but the content is not RTF or is corrupted.

R2057 Unrecognized graphic format in topic topicnumber of file filename Help RTF errorThe compiler supports only Windows bitmaps. Check that metafiles or Macintosh formats have not been used. The graphic is ignored.

R2059 Context string identifier already defined in topic topicnumber of file filename Help RTF errorThere is more than one context-string identifier footnote for the specified topic. The compiler uses the identifier defined in the first # footnote.

R2061 Context string contextname already used in file filename Help RTF errorThe specified context string was previously assigned to another topic. The compiler ignores the latter string and the topic has no identifier.

R2063 Invalid context-string identifier for topic topicnumber of file filename Help RTF errorThe context-string footnote contains nonalphanumeric characters or is null. The topic is not assigned an identifier.

R2065 Context string defined for index topic is unresolved Help RTF errorThe index topic defined in the project file could not be found. The compiler uses the first topic in the build as the index.

R2067 Footnote text too long in topic topicnumber of file filename Help RTF errorFootnote text cannot exceed the limit of 1000 characters. The footnote is ignored.

R2069 Build tag footnote not at beginning of topic topicnumber of file filename Help RTF errorThe specified topic contains a build tag footnote that is not the first character in the topic. The topic is not assigned a build tag.

R2071 Footnote text missing in topic topicnumber of file filename Help RTF errorThe specified topic contains a footnote that has no characters.

R2073 Keyword string is null in topic topicnumber of file filename Help RTF errorA keyword footnote exists for the specified topic, but contains no characters.

R2075 Keyword string too long in topic topicnumber of file filename Help RTF errorThe text in the keyword footnote in the specified topic exceeds the limit of 255 characters. The excess characters are ignored.

R2077 Keyword(s) defined without title in topic topicnumber of file filename Help RTF errorKeyword(s) have been defined for the specified topic, but the topic has no title assigned. Search Topics Found displays Untitled Topic<< for the topic.

R2079 Browse sequence string is null in topic topicnumber of file filename Help RTF errorThe browse-sequence footnote for the specified topic contains no sequence characters.

R2081 Browse sequence string too long in topic topicnumber of file filename Help RTF errorThe browse-sequence footnote for the specified topic exceeds the limit of 128 characters. The sequence is ignored.

R2083 Missing sequence number in topic topicnumber of file filename Help RTF errorA browse-sequence number ends in a colon (:) for the specified topic. Remove the colon, or enter a “minor” sequence number.

R2085 Sequence number already defined in topic topicnumber of file filename Help RTF errorThere is already a browse-sequence footnote for the specified topic. The latter sequence is ignored.

R2087 Build tag too long Help RTF errorA build tag for the specified topic exceeds the maximum of 32 characters. The tag is ignored for the topic.

R2089 Title string null in topic topicnumber of file filename Help RTF errorThe title footnote for the specified topic contains no characters. The topic is not assigned a title.

Page 260: UG

260 U s e r ’ s G u i d e

R2091 Title too long in topic topicnumber of file filename Help RTF errorThe title for the specified topic exceeds the limit of 128 characters. The excess characters are ignored.

R2093 Title titlename in topic topicnumber of file filename used previously Help RTF errorThe specified title has previously been assigned to another topic.

R2095 Title defined more than once in topic topicnumber of file filename Help RTF errorThere is more than one title footnote in the specified topic. The compiler uses the first title string.

R2501 Using old key-phrase table Help RTF errorMaximum compression can only result by deleting the .PH file before each recompilation of the Help topics.

R2503 Out of memory during text compression Help RTF errorThe compiler encountered a memory limitation during compression. Compilation continues with the Help resource file not compressed. Unload any unneeded applications, device drivers, and memory-resident programs.

R2505 File environment error during text compression Help RTF errorThe compiler has insufficient available file handles for compression. Compilation continues with the Help resource file not compressed. Increase the values for FILES= and BUFFERS= in your CONFIG.SYS file and reboot.

R2507 DOS file error during text compression Help RTF errorThe compiler encountered a problem accessing a disk file during compression. Compilation continues with the Help resource file not compressed.

R2509 Error during text compression Help RTF errorOne of the three compression errors—R2503, R2505, or R2507—has occurred. Compilation continues with the Help resource file not compressed.

R2701 Internal error Help RTF errorR2703 Internal error Help RTF errorR2705 Internal error Help RTF errorR2707 Internal error Help RTF errorR2709 Internal error Help RTF error

Contact Borland Technical Support for clarification of the error.

Record kind num found, expected theadr or lheadr in module filename Librarian errorThe librarian could not understand the header record of the object module being added to the library and has assumed that it is an invalid module.

Record length len exceeds available buffer in module module Librarian errorThis error occurs when the record length len exceeds the available buffer to load the buffer in module module. This occurs when librarian runs out of dynamic memory.

Record type type found, expected theadr or lheadr in module Librarian errorThe librarian encountered an unexpected type type instead of the expected THEADR or LHEADER record in module module.

Recursive template function: class instantiated as class Compiler errorThe compiler has detected a recursive template function instance. For example,

template<class T> void f(t x){

f((T*)0); //recursive template function!}

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:

Page 261: UG

A p p e n d i x C , E r r o r m e s s a g e s 261

void f(int **){}

Redefinition of macro is not identical Compiler warningYour source file redefined the named macro using text that was not exactly the same as the first definition of the macro. The new text replaces the old.

Redefinition of target filename MAKE errorThe named file occurs on the left side of more than one explicit rule.

Reference initialized with type1, needs lvalue of type type2 Compiler errorA reference variable or parameter that is not declared constant must be initialized with an lvalue of the appropriate type. This error was issued either because the initializer wasn’t an lvalue or because its type didn’t match the reference being initialized.

Reference member member in class without constructors Compiler errorA class that contains reference members must have at least one user-defined constructor; otherwise, there would be no way to initialize such members.

Reference member member initialized with a non-reference parameter Compiler errorAn attempt has been made to bind a reference member to a parameter in a constructor. Because the parameter object ceases to exist the moment the constructor returns, the reference member is then left referring to an undefined object. (This is a common mistake that causes crashes and erratic program behavior.)

Reference member member is not initialized Compiler errorReferences must always be initialized. A class member of reference type must have an initializer provided in all constructors for that class. This means that you cannot depend on the compiler to generate constructors for such a class, because it has no way of knowing how to initialize the references.

Reference member member needs a temporary for initialization Compiler errorYou provided an initial value for a reference type that was not an lvalue of the referenced type. This requires the compiler to create a temporary for the initialization. Because there is no obvious place to store this temporary, the initialization is illegal.

Reference variable variable must be initialized Compiler errorThis C++ object is declared as a reference but is not initialized. All references must be initialized at their point of declaration.

Register allocation failure Compiler errorThis is a sign of some form of compiler error. Some expression in the indicated function was so complicated that the code generator could not generate code for it. Try to simplify the offending function. Notify Borland Technical Support if the compiler encounters this error.

Relocation item exceeds 1MB DOS limit Linker errorThe DOS executable file format doesn’t support relocation items for locations exceeding 1MB. Although DOS could never load an image this big, DOS extenders can, and thus TLINK supports generating images greater than DOS could load. Even if the image is loaded with a DOS extender, the DOS executable file format is limited to describing relocation items in the first 1MB of the image.

Relocation offset overflow Linker errorThis error occurs only for 32-bit object modules and indicates a relocation (segment fixup) offset greater than the DOS limit of 64K.

Relocation table overflow Linker errorThis error occurs only for 32-bit object modules. The file being linked contains more base fixups than the standard DOS relocation table can hold (base fixups are created mostly by calls to far functions).

Repeat count needs an lvalue IDE debugger errorThe expression before the comma in the Watch or Evaluate window must be a manipulable region of storage. For example, expressions like these are not valid:

i++, 10dx = y, 10m

Page 262: UG

262 U s e r ’ s G u i d e

Resident Name Table is greater than 64K Linker warningThe maximum size of the Resident name table is 64K (in accordance with the industry-wide executable specification standard). The linker continues with the link but ignores any subsequent Resident names encountered during linking.

Resource binding failed Linker errorWhile you were linking from the command line, RLINK.EXE reported an error while binding resources to your image.

Restarting compile using assembly Compiler warningThe compiler encountered an ASM with an accompanying –B command-line option or #pragma inline statement. The compile restarts using assembly language capabilities.

Results are safe in file filename Librarian warningThe librarian has successfully built the library into a temporary file, but cannot rename the file to the desired library name. The temporary file will not be removed (so that the library can be preserved).

Rule line too long MAKE errorAn implicit or explicit rule was longer than 4096 characters.

Segment alignment factor too small Linker errorThis error occurs if the segment alignment factor is too small to represent the file addresses of the segments in the .EXE file. This error only occurs when linking for Windows. See the documentation for the /A option.

Segment segment exceeds 64K Linker errorThis message occurs if too much data is defined for a given data or code segment when TLINK combines segments with the same name from different source files.

Segment segment is in two groups: group1 and group2 Linker warningThe linker found conflicting claims by the two named groups. Usually, this happens only in assembly language programs. It means that two modules assigned the segment to two different groups.

Segment segment relocation data exceeds 64K Linker errorThe NE format only allows for 8192 relocations per segment.

Segment too large for segment table Linker errorThis error should never occur in practice. It means that a segment was bigger than 64K and its size cannot be represented in the executable file. This error can only occur when linking for Windows; the format of the executable file used for Windows does not support segments greater than 64K.

Self relative fixup overflowed in module module Linker warningThis message appears if a self-relative reference (usually a call) is made from one physical segment to another. It usually happens only when employing assembler code, but can occur if you use the segment-naming options in the compiler. If the reference is from one code segment to another, you are safe. If, however, the reference is from a code segment to a data segment, you have probably made a mistake in some assembler code.

Side effects are not allowed IDE debugger errorSide effects such as assignments, ++, or – – are not allowed in the debugger watch window. A common error is to use “x = y” (not allowed) instead of “x == y” to test the equality of “x” and “y.”

Size of identifier is unknown or zero Compiler errorThis identifier was used in a context where its size was needed. For example, a struct tag might only be declared (with the struct not defined yet), or an extern array might be declared without a size. If so, it’s illegal to have references to such an item (like sizeof) or to dereference a pointer to this type. Rearrange your declaration so that the size of identifier is available.

sizeof may not be applied to a bit field Compiler errorsizeof returns the size of a data object in bytes, which does not apply to a bit field.

sizeof may not be applied to a function Compiler errorsizeof can be applied only to data objects, not functions. You can request the size of a pointer to a function.

Size of the type is unknown or zero Compiler errorThis type was used in a context where its size was needed. For example, a struct tag might only be declared (with the struct not defined yet). If so, it’s illegal to have references to such an item (like sizeof) or to dereference a pointer to this type. Rearrange your declarations so that the size of this type is available.

identifier specifies multiple or duplicate access Compiler errorA base class can be declared public or private, but not both. This access specifier can appear no more than once for a base class.

Page 263: UG

A p p e n d i x C , E r r o r m e s s a g e s 263

Stack overflow Run-time errorThe default stack size for Turbo C++ programs is 5120 bytes. This should be enough for most programs, but those which execute recursive functions or store a great deal of local data can overflow the stack. You will get this message only if you have stack checking enabled. If you do get this message, you can try increasing the stack size or decreasing your program’s dependence on the stack. Change the stack size by altering the global variable _stklen. Try switching to a larger memory model to fit the larger stack.To decrease the amount of local data used by a function, look at the example below. The variable buffer has been declared static and does not consume stack space like list does.

void anyfunction(void) {static int buffer[2000]; /* resides in the data segment */int list[2000]; /* resides on the stack */

}There are two disadvantages to declaring local variables as static.1) It now takes permanent space away from global variables and the heap. This is usually only a minor disadvantage.2) The function can no longer be reentrant. If the function is called recursively or asynchronously and it is important that each call to the function have its own unique copy of the variable, you cannot make it static. This is because every time the function is called, it will use the same exact memory space for the variable, rather than allocating new space for it on each call. You could have a sharing problem if the function is trying to execute from within itself (recursively) or at the same time as itself (asynchronously). For most DOS programs this is not a problem.

Stack size is less than 1400h. It has been reset to 1400h. Linker warningWindows 3.0 requires the stack size of an application to be at least 1400h. If the automatic data segment (ADS) is near 64K, but your stack is less than 1400h, this can cause the ADS to overflow at load time, but not at link time. For a Windows application, to protect against this, the linker forces the stack size to be at least 1400h.

Statement missing ; Compiler errorThe compiler encountered an expression statement without a semicolon following it.

Storage class storage class is not allowed here Compiler errorThe given storage class is not allowed here. Probably two storage classes were specified, and only one can be given.

String type not allowed with this operand MAKE errorYou have tried to use an operand that is not allowed for comparing string types. Valid operands are ==, !=, <, >, <=, and >=.

Structure passed by value Compiler warningA structure was passed by value as an argument to a function without a prototype. It is a frequent programming mistake to leave an address-of operator (&) off a structure when passing it as an argument. Because structures can be passed by value, this omission is acceptable. This warning provides a way for the compiler to warn you of this mistake.

Structure required on left side of . or .* Compiler errorThe left side of a dot (.) operator (or C++ dot-star operator) must evaluate to a structure type. In this case it did not.

Structure size too large Compiler errorYour source file declared a structure larger than 64K.

Stub program exceeds 64K Linker errorThis error occurs if a DOS stub program written for Windows application exceeds 64K. Stub programs are specified via the STUB module definition file statement. The linker only supports stub programs up to 64K.

Style of function definition is now obsolete Compiler warningIn C++, this old C style of function definition is illegal:

int func(p1, p2)int p1, p2;{...}

Subscripting missing ] Compiler errorThe compiler encountered a subscripting expression that was missing its closing bracket. This could be caused by a missing or extra operator, or by mismatched parentheses.

Superfluous & with function Compiler warningAn address-of operator (&) is not needed with function name; any such operators are discarded.

Page 264: UG

264 U s e r ’ s G u i d e

Suspicious pointer conversion Compiler warningThe compiler encountered some conversion of a pointer that caused the pointer to point to a different type. You should use a cast to suppress this warning if the conversion is proper.

Switch selection expression must be of integral type Compiler errorThe selection expression in parentheses in a switch statement must evaluate to an integral type (char, short, int, long, enum). You might be able to use an explicit cast to satisfy this requirement.

Switch statement missing ( Compiler errorIn a switch statement, the compiler found no left parenthesis after the switch keyword.

Switch statement missing ) Compiler errorIn a switch statement, the compiler found no right parenthesis after the test expression.

filename (linenum): Syntax error Linker errorThe linker found a syntax error in the module definition file. The file name and line number tell you where the syntax error occurred.

Table limit exceeded Linker errorOne of linker’s internal tables overflowed. This usually means that the programs being linked have exceeded the linker’s capacity for public symbols, external symbols, or for logical segment definitions. Each instance of a distinct segment name in an object file counts as a logical segment; if two object files define this segment, then this results in two logical segments.

Table limit exceeded–>try linking with extended dictionaries Linker errorThis error occurs if you are linking many object modules, each with many segment definition records. Turning on extended dictionaries will cause the linker to process fewer modules, eliminating unnecessary caching of these records. Make sure that the libraries that are being linked ALL have extended dictionaries. If you are not sure, run TLIB /E on the libraries, and extended dictionaries will be constructed.

Target index of FIXUP is 0 in module module Linker errorThis is a translator error.

Template argument must be a constant expression Compiler errorA non-type actual template class argument must be a constant expression (of the appropriate type); this includes constant integral expressions, and addresses of objects or functions with external linkage or members.

Template class nesting too deep: ‘class’ Compiler errorThe compiler imposes a certain limit on the level of template class nesting; this limit is usually exceeded only through a recursive template class dependency. When this nesting limit is exceeded, the compiler issues this error message for all of the nested template classes, which usually makes it easy to spot the recursion. This is always followed by the fatal error Out of memory.For example, consider the following set of template classes:

template<class T> class A{

friend class B<T*>;};

template<class T> class B{

friend class A<T>;};

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 * *>'

Page 265: UG

A p p e n d i x C , E r r o r m e s s a g e s 265

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>'Fatal: Out of memory

Template function argument argument not used in argument types Compiler errorThe given argument was not used in the argument list of the function. The argument list of a template function must use all of the template formal arguments; otherwise, there is no way to generate a template function instance based on actual argument types.

Template functions may only have type-arguments Compiler errorA function template was declared with a non-type argument. This is not allowed with a template function because there is no way to specify the value when calling it.

Templates can only be declared at file level Compiler errorTemplates cannot be declared inside classes or functions; they are allowed only in the global scope (file level).

Templates must be classes or functions Compiler errorThe declaration in a template declaration must specify either a class type or a function.

Temporary used to initialize identifier Compiler warningTemporary used for parameter number in call to function Compiler warningTemporary used for parameter number Compiler warningTemporary used for parameter parameter Compiler warning

In C++, a variable or parameter of reference type must be assigned a reference to an object of the same type. If the types do not match, the actual value is assigned to a temporary of the correct type, and the address of the temporary is assigned to the reference variable or parameter. The warning means that the reference variable or parameter does not refer to what you expect, but to a temporary variable, otherwise unused.In the following example, function f requires a reference to an int, and c is a char:

f(int&);char c;f(c);

Instead of calling f with the address of c, the compiler generates code equivalent to the C++ source code:

int X = c, f(X);

Terminated by user Linker errorYou canceled the link.

The ‘...’ handler must be last Compiler errorIn a list of catch handlers, if the ‘...’ handler is present, it must be the last handler in the list (that is, it cannot be followed by any more catch handlers).

The combinations ‘+*’ or ‘*+’ are not allowed Librarian errorIt is not legal to add and extract an object module from a library in one action. The action probably desired is a ‘+–’.

The constructor constructor is not allowed Compiler errorConstructors of the form X::(X) are not allowed. The correct way to write a copy constructor is X::(const X&).

The value for identifier is not within the range of an int Compiler errorAll enumerators must have values that can be represented as an integer. You attempted to assign a value that is out of the range of an integer. In C++ if you need a constant of this value, use a const integer.

‘this’ can be used only within a member function Compiler errorIn C++, this is a reserved word that can be used only within class member functions.

This initialization is only partly bracketed Compiler warningWhen structures are initialized, braces can be used to mark the initialization of each member of the structure. If a member itself is an array or structure, nested pairs of braces can be used. When some of the optional braces are omitted, the compiler issues this warning.

Too few arguments in template class name template Compiler errorA template class name was missing actual values for some of its formal parameters.

Page 266: UG

266 U s e r ’ s G u i d e

Too few parameters in call Compiler errorA call to a function with a prototype (via a function pointer) had too few arguments. Prototypes require that all parameters be given.

Too few parameters in call to function Compiler errorA call to the named function (declared using a prototype) had too few arguments.

Too many commas on command-line Linker errorAn invalid entry in the command-line was found.

Too many decimal points Compiler errorThe compiler encountered a floating-point constant with more than one decimal point.

Too many default cases Compiler errorThe compiler encountered more than one default statement in a single switch.

Too many default libraries Compiler errorThe linker can handle a maximum of 128 default libraries.

Too many error or warning messages Compiler errorA maximum of 255 errors and warnings can be set before the compiler stops.

Too many error or warning messages Linker errorThe number of messages reported by the compiler has exceeded its limit. This error indicates that TLINK reached its limit.

Too many errors Linker errorThe linker encountered more errors than the –E switch will permit.

Too many exponents Compiler errorThe compiler encountered more than one exponent in a floating-point constant.

Too many initializers Compiler errorThe compiler encountered more initializers than were allowed by the declaration being initialized.

Too many LNAMEs Linker errorTLINK has a limit of 256 LNAMES in a single .OBJ file.

Too many rules for target target MAKE errorMAKE can’t determine which rules to follow when building a target because you’ve created too many rules for the target. For example, the following makefile generates this error message:

abc.exe : a.objbcc -c a.c

abc.exe : b.obj

abc.exe : c.objbcc -c b.c c.c

Too many storage classes in declaration Compiler errorA declaration can never have more than one storage class.

Too many suffixes in .SUFFIXES list MAKE errorThe limit of 255 allowable suffixes in the suffixes list has been exceeded.

Too many types in declaration Compiler errorA 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 errorThe 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 errorIf a class is declared (or defaults to) huge, all derived classes must also be huge.

Page 267: UG

A p p e n d i x C , E r r o r m e s s a g e s 267

Trying to derive a far class from the near base base Compiler errorIf a class is declared (or defaults to) near, all derived classes must also be near.

Trying to derive a huge class from the far base base Compiler errorIf a class is declared (or defaults to) far, all derived classes must also be far.

Trying to derive a huge class from the near base base Compiler errorIf a class is declared (or defaults to) near, all derived classes must also be near.

Trying to derive a near class from the far base base Compiler errorIf a class is declared (or defaults to) far, all derived classes must also be far.

Trying to derive a near class from the huge base base Compiler errorIf a class is declared (or defaults to) huge, all derived classes must also be huge.

Two consecutive dots Compiler errorBecause an ellipsis contains three dots (...), and a decimal point or member selection operator uses one dot (.), two consecutive dots cannot legally occur in a C program.

Two operands must evaluate to the same type Compiler errorThe types of the expressions on both sides of the colon in the conditional expression operator (?:) must be the same, except for the usual conversions like char to int, or float to double, or void* to a particular pointer. In this expression, the two sides evaluate to different types that are not automatically converted. This might be an error or you might merely need to cast one side to the type of the other.

Type type is not a defined class with virtual functions Compiler errorA dynamic_cast was used with a pointer to a class type that is either undefined or doesn’t have any virtual member functions.Note on type-mismatch errors: When compiling C++ programs, the following type-mismatch error messages are always preceded by another message that explains the exact reason for the type mismatch; this is usually “Cannot convert type1 to type2” but the mismatch could also be due to many other reasons.

Type type may not be defined here Compiler errorClasses and enumerations may not be defined in certain places. For example, the return type specification of a function. The class or enum definition must be moved into a separate type declaration.

Type mismatch in default argument value Compiler errorType mismatch in default value for parameter parameter Compiler error

The default parameter value given could not be converted to the type of the parameter. The first message is used when the parameter was not given a name. See the previous note on type-mismatch errors.

Type mismatch in parameter number Compiler errorThe function called, via a function pointer, was declared with a prototype; the given parameter number (counting left to right from 1) could not be converted to the declared parameter type. See the previous note on type-mismatch errors.

Type mismatch in parameter number in call to function Compiler errorYour source file declared the named function with a prototype, and the given parameter number (counting left to right from 1) could not be converted to the declared parameter type. See the previous note on type-mismatch errors.

Type mismatch in parameter parameter Compiler errorYour source file declared the function called via a function pointer with a prototype, and the named parameter could not be converted to the declared parameter type. See the previous note on type-mismatch errors.

Type mismatch in parameter parameter in call to function Compiler errorYour source file declared the named function with a prototype, and the named parameter could not be converted to the declared parameter type. See entry for Type mismatch in parameter parameter and the previous note on type-mismatch errors.

Type mismatch in parameter parameter in template class name template Compiler errorType mismatch in parameter number in template class name template Compiler error

The actual template argument value supplied for the given parameter did not exactly match the formal template parameter type. See the previous note on type-mismatch errors.

Type mismatch in redeclaration of identifier Compiler errorYour source file redeclared with a different type than was originally declared. This can occur if a function is called and subsequently declared to return something other than an integer. If this has happened, you must declare the function before the first call to it. See the previous note on type-mismatch errors.

Page 268: UG

268 U s e r ’ s G u i d e

Type name expected Compiler errorOne of these errors has occurred:

In declaring a file-level variable or a struct field, neither a type name nor a storage class was given.In declaring a typedef, no type for the name was supplied.In declaring a destructor for a C++ class, the destructor name was not a type name (it must be the same name as its class).In supplying a C++ base class name, the name was not the name of a class.

Type qualifier identifier must be a struct or class name Compiler errorThe C++ qualifier in the construction qual::identifier is not the name of a struct or class.

Unable to create output file filename Compiler errorThe work disk is full or write-protected or the output directory does not exist. If the disk is full, try deleting unneeded files and restarting the compilation. If the disk is write-protected, move the source files to a writable disk and restart the compilation.

Unable to create turboc.$ln Compiler errorThe compiler cannot create the temporary file TURBOC.$LN because it cannot access the disk or the disk is full.

Unable to execute command: command MAKE errorA command failed to execute; this might be because the command file could not be found or was misspelled, because there was no disk space left in the specified swap directory, because the swap directory does not exist, or (less likely) because the command itself exists but has been corrupted.

Unable to execute command command Compiler errorTLINK or TASM cannot be found, or possibly the disk is bad.

Unable to open file filename MAKE errorUnable to open filename Linker error

This occurs if the named file does not exist or is misspelled.

Unable to open filename for output Librarian errorThe librarian cannot open the specified file for output. This is usually due to lack of disk space for the target library, or a listing file.

Unable to open include file filename Compiler errorThe compiler could not find the named file. This error can also be caused if an #include file included itself, or if you do not have FILES set in CONFIG.SYS on your root directory (try FILES=20). Check whether the named file exists.

Unable to open include file filename MAKE errorThe compiler could not find the named file. This error can also be caused if an !include file included itself, or if you do not have FILES set in CONFIG.SYS on your root directory (try FILES=20). Check whether the named file exists.

Unable to open input file filename Compiler errorThis error occurs if the source file cannot be found. Check the spelling of the name and whether the file is on the proper disk or directory.

Unable to open makefile MAKE errorThe current directory does not contain a file named MAKEFILE or MAKEFILE.MAK, or it does not contain the file you specified with –f.

Unable to process debug information, disable tasm /zi option Linker errorThis happens when you compile .C or .CPP code with debug information, generating assembler output, and then run TASM on the result with the /zi option. Do not use the /zi option. The compiler already generated the appropriate debug information.

Unable to redirect input or output MAKE errorMAKE was unable to open the temporary files necessary to redirect input or output. If you are on a network, make sure you have rights to the current directory.

Unable to rename filename to filename Librarian errorThe librarian builds a library into a temporary file and then renames the temporary file to the target library file name. If there is an error, usually due to lack of disk space, this message is posted.

Undefined alias symbol symbol Linker errorAn ALIAS definition record was encountered which specified a substitute public symbol for an external reference. The public symbol was never found. ALIAS records are generated by the assembler when the ALIAS directive is used.

Page 269: UG

A p p e n d i x C , E r r o r m e s s a g e s 269

Undefined label identifier Compiler errorThe named label has a goto in the function, but no label definition.

Undefined structure identifier Compiler warningThe named structure was used in the source file, probably on a pointer to a structure, but had no definition in the source file. This is probably caused by a misspelled structure name or a missing declaration.

Undefined structure structure Compiler errorYour source file used the named structure on some line before where the error is indicated (probably on a pointer to a structure) but had no definition for the structure. This is probably caused by a misspelled structure name or a missing declaration.

Undefined symbol identifier Compiler errorThe named identifier has no declaration. This could be caused by a misspelling either at this point or at the declaration. This could also be caused if there was an error in the declaration of the identifier.

Undefined symbol symbol Linker errorThe named symbol is referenced in the given module but is not defined anywhere in the set of object files and libraries included in the link. Check to make sure the symbol is spelled correctly.You will usually see this error from TLINK for Turbo C++ symbols if you did not properly match a symbol’s declarations of pascal and cdecl type in different source files, or if you have omitted the name of an .OBJ file your program needs. If you are linking C++ code with C modules, you might have forgotten to wrap C external declarations in extern "C" {...}. You might have a case mismatch between two symbols. See the /C and /c switches.

Unexpected } Compiler errorAn extra right brace was encountered where none was expected. Check for a missing {.

Unexpected char X in command line Librarian errorThe librarian encountered a syntactical error while parsing the command line.

Unexpected end of file MAKE errorThe end of the makefile was reached without a temporary inline file having been closed.

Unexpected end of file in comment started on line number MAKE errorThe source file ended in the middle of a comment. This is normally caused by a missing close of comment (*/).

Unexpected end of file in conditional started on line line number Compiler errorThe source file ended before the compiler (or MAKE) encountered an !endif. The !endif was either missing or misspelled.

Union cannot be a base type Compiler errorA union cannot be used as a base type for another class type.

Union cannot have a base type Compiler errorA union cannot be derived from any other class.

Union member member is of type class with constructor Compiler errorUnion member member is of type class with destructor Compiler errorUnion member member is of type class with operator= Compiler error

A union cannot contain members that are of type class with user-defined constructors, destructors, or operator=.

Unions cannot have virtual member functions Compiler errorA union cannot have virtual functions as its members.

Unknown assembler instruction Compiler warningThe compiler encountered an inline assembly statement.

Unknown command line switch X ignored Librarian warningA forward slash character (/) was encountered on the command line or in a response file without being followed by one of the allowed options.

Unknown Goodie Linker errorAn unsupported option was supplied to the command-line linker. See the documentation for currently supported Goodies (options).

Unknown language, must be C or C++ Compiler errorIn the C++ construction

Page 270: UG

270 U s e r ’ s G u i d e

extern "name" type func( /*...*/ );the name given in quotes must be “C” or “C++”; other language names are not recognized. For example, you can declare an external Pascal function without having the compiler rename it like this:

extern "C" int pascal func( /*...*/ );A C++ (possibly overloaded) function can be declared Pascal and allow the usual compiler renaming (to allow overloading) like this:

extern int pascal func( /*...*/ );

Unknown option –> option Linker errorA forward slash character (/), hyphen (), or DOS switch character was encountered on the command line or in a response file without being followed by one of the allowed options. You might have used the wrong case to specify an option.

Unknown preprocessor directive: identifier Compiler errorThe compiler encountered a # character at the beginning of a line, and the name following was not a legal directive name or the rest of the directive was not well formed.

Unknown preprocessor statement MAKE errorA ! character was encountered at the beginning of a line, and the statement name following was not error, undef, if, elif, include, else, or endif.

Unreachable code Compiler warningA break, continue, goto or return statement was not followed by a label or the end of a loop or function. The compiler checks while, do and for loops with a constant test condition, and attempts to recognize loops that cannot fall through.

Unsupported option string Linker errorYou have specified an invalid option to the linker.

Unterminated string or character constant Compiler errorThe compiler found no terminating quote after the beginning of a string or character constant.

Use ‘> >’ for nested templates instead of ‘>>’ Compiler warningWhitespace is required to separate the closing “>” in a nested template name, but since it is a common mistake to leave out the space, the compiler accepts a “>>” with this warning.

Use . or –> to call function Compiler errorYou tried to call a member function without giving an object.

Use . or –> to call member, or & to take its address Compiler errorA reference to a nonstatic class member without an object was encountered. Such a member must be used with an object, or its address must be taken with the & operator.

Use :: to take the address of a member function Compiler errorIf f is a member function of class c, you take its address with the syntax &c::f. Note the use of the class type name, rather than the name of an object, and the :: separating the class name from the function name. (Member function pointers are not true pointer types, and do not refer to any particular instance of a class.)

Use /e with TLINK to obtain debug information from library Librarian warningThe library was built with an extended dictionary and also includes debugging information. TLINK will not extract debugging information if it links using an extended dictionary, so to obtain debugging information in an executable from this library, the linker must be told to ignore the extended dictionary using the /e switch. Note: The IDE linker does not support extended dictionaries; therefore no settings need to be altered in the IDE.

Use of : and :: dependents for target target MAKE errorYou have tried to use the target in both single and multiple description blocks (using both the : and :: operators). Examples:

filea: filebfilea:: filec

Use qualified name to access nested type type Compiler warningIn older versions of the C++ specification, typedef and tag names declared inside classes were directly visible in the global scope. With the latest specification of C++, these names must be prefixed with a class:: qualifier if they are to be used outside their class’ scope. To allow older code to compile, whenever such a name is uniquely defined in one single class, Turbo C++ allows its usage without class:: and issues this warning.

Page 271: UG

A p p e n d i x C , E r r o r m e s s a g e s 271

User break Compiler errorYou pressed Ctrl+Break while compiling or linking in the IDE, thus aborting the process. (This is not an error, just a confirmation.)

User break, library aborted Librarian errorYou pressed Ctrl+Break to abort the build of the library.

Value of type void is not allowed Compiler errorA value of type void is really not a value at all, and thus cannot appear in any context where an actual value is required. Such contexts include the right side of an assignment, an argument of a function, and the controlling expression of an if, for, or while statement.

VIRDEF Name Conflict for function Compiler errorThe compiler must truncate mangled names to a certain length because of a name length limit that is imposed by the linker. This truncation might (in rare cases) cause two names to mangle to the same linker name. If these names happen to both be VIRDEF names, the compiler issues this error message. The simplest workaround for this problem is to change the name of function so that the conflict is avoided.

Variable variable has been optimized and is not available IDE debugger errorYou have tried to inspect, watch, or otherwise access a variable which the optimizer removed. This variable is never assigned a value and has no stack location. Recompile your program without optimizations if you need to inspect this variable.

Variable identifier is initialized more than once Compiler errorThis variable has more than one initialization. It is legal to declare a file level variable more than once, but it can have only one initialization (even if two are the same).

‘virtual’ can only be used with member functions Compiler errorA data member has been declared with the virtual specifier; only member functions can be declared virtual.

Virtual function function1 conflicts with base class base Compiler errorThe compiler encountered a virtual function that has the same argument types as a function in its base class, but the two functions have different return types. This is illegal.

Virtual specified more than once Compiler errorThe C++ reserved word virtual can appear only once in a member function declaration.

void & is not a valid type Compiler errorA reference always refers to an object, but an object cannot have the type void. Thus the type void is not allowed.

Void functions may not return a value Compiler warningYour source file declared the current function as returning void, but the compiler encountered a return statement with a value. The value of the return statement will be ignored.

function was previously declared with the languagelanguage Compiler errorOnly one language can be used with extern for a given function. This function has been declared with different languages in different locations in the same module.

While statement missing ( Compiler errorIn a while statement, the compiler found no left parenthesis after the while keyword.

While statement missing ) Compiler errorIn a while statement, the compiler found no right parenthesis after the test expression.This occurs if TLINK could not write all of the data it attempted to write. This is almost certainly caused by the disk being full.

Write error on file filename MAKE errorMAKE couldn’t open or write to the file specified in the makefile. Check to ensure that there’s enough space left on your disk, and that you have write access to the disk.

Write failed, disk full? Linker errorThis occurs if the linker could not write all of the data it attempted to write. This is almost certainly caused by the disk being full.

Wrong number of arguments in call of macro mac Compiler errorYour source file called the named macro with an incorrect number of arguments.

Page 272: UG

272 U s e r ’ s G u i d e

Page 273: UG

I n d e x 273

Symbols& (ampersand)

adding to menus 173, 174+ (plus sign)

AppExpert hierarchies 62Environment Options dialog

box 14Project Manager 20

– (hyphen)AppExpert hierarchies 62Environment Options dialog

box 14Project Manager 20

Numerics16-bit Compiler option (Project

Options) 48–52-3 compiler option 48/3 linker option 5732-bit applications See DOS;

Windows applications386 enhanced mode 553-D controls 153, 169-4 compiler option 4880x86 processors

compiler options 50segmentation 50

A-A compiler option 46, 47-a compiler option 48Absolute Align property 150ACBP fields (Intel) 56Accelerator editor

(resources) 178customizing 181

Accelerator Key Value command (resources) 175

accelerator tables 171, 176adding accelerators 179editing scripts 178–179

accelerators 178–181changing keys 180checking for duplicate

keys 181manipulating 180menus 175–176naming 179source code 181–182viewing 178

Indexaccessing IDE SpeedMenus 9accessing source files 21Actual Size command

(resources) 195Add Breakpoint command 96Add Comment command 108Add Handler command

(ClassExpert) 79Add New Class dialog box 77Add Node option 24Add Watch command 101adding watches 101addresses

exceptions 123symbolic 56

Advanced Options dialog boxadding tools 32specifying source nodes 23

-AK compiler option 47Align Center command

(resources) 192Align command (resources) 158Align Controls dialog box 158Align Left command

(resources) 192Align Right command

(resources) 192alignment

attribute (Intel) 56code pages 57compiler options 48graphics 192, 193text 192

in controls 161, 163Alignment palette

Dialog editor 148, 158Alignment property 161

scroll bars 164All Windows command

(Messages) 115allocation

compiler options 45memory See memory

alternative translators 31Alt-key shortcuts 176ampersand (&)

adding to menus 173, 174ancestor-descendant

relationships 86ANSI codes

bitmapped fonts and 198–199AppExpert 61

creating applications 62–67default files 62modifying code 65, 66options 68–74

specifying 64organizing project files 62overview 62rebuilding projects 82SpeedMenu 62starting 62targets, default viewer 75

AppExpert Application Generation Options dialog box 62, 63, 68

applications 1932-bit See DOS; Windows

applicationscompiling See compilationconsole

converting to Windows 215

creating 30, 61entry/exit code options 51linking See linkagemain windows

dialog boxes as 61, 149testing 30, 91Windows See Windows

applications.APX files 82

rebuilding 83arguments 107

See also parametersArray command (resources) 159arrays

debugging 102, 105huge 50inspecting 105viewing 106

ASCII codeswatches and 104

ASCII files See text filesASCII keys 175, 176assembly language

command-line options 53integrated debugger and 95

-AT compiler option 46attributes

bit fields 56project nodes 24, 26, 30syntax highlighting 15

-AU compiler option 47Auto Horizontal property 166

Page 274: UG

274 U s e r ’ s G u i d e

autodependency informationMAKE 46Project Manager 20

autodependency nodes 20, 40automatic error tracking 43automatic file linkage 20Automatic Horizontal Scroll

property 165Automatic Vertical Scroll

property 165automatically generating

underscores 46automatically saving IDE

settings 17automation servers See servers

(automation)

B-b compiler option 45background colors

dialog boxes 149graphics resources 189main windows 71syntax highlighting 15

backward compatibilityloading project files 27

base classescompiler options 52

BBN_GOTABTAB message 153BBN_GOTATAB message 153BBN_SETFOCUS message 153BBN_SETFOCUSMOUSE

message 153BCC.EXE

See also command-line compilers

BCC32.EXESee also command-line

compilersBCCONFIG.BCW 17BCDEF.CSM 217, 218

reducing size 219BCWDEF.DSW 17big attribute 56binary data 134

WinSpector reports, processing 126

binary filesresources 142–143

bit fieldsACBP (Intel) 56

bitmap buttons 162bitmapped fonts 198–199bitmaps 187, 201, 202

See also graphics

metafiles vs. 205properties, setting 196resizing 196resource scripts and 138

blank lines in codebreakpoints and 97

.BMP files 143Boolean expressions

breakpoints and 99Border property 161borders 189

dialog boxes 150, 152, 161main windows 71pop-up windows 167

Borland Assist program 4Borland C++

starting IDE 7Borland resource compilers See

BRCC.EXE; BRCC32.EXEBorland resource linkers See

RLINK.EXE; RLINK32.DLLBorland Visual Solutions

Pack 153break character (fonts) 199Breakpoint command 97Breakpoint Properties dialog

box 98, 99breakpoints 96–100

See also debuggingconditional 99customizing colors 100deleting 98disabling 97invalid 97, 100properties 98–100setting 95, 96–97

after program start 96pass counts and 99

skipping over 99viewing 97, 100

Breakpoints window 97opening 97

Brief editor, emulating 15Browse Symbol command

(Search) 86browser (IDE) 85–88

configuring 87customizing 88error messages 86filters, setting 87overview 86–87searching for symbols 88starting 85, 86

brushes (resources) 190buffers

transfer 80

Build All command (Project) 41, 64

Build Node option 42building projects 35

canceling builds 41MAKE vs. 41specific parts 42

BUILDSYM.EXE 129buttons

See also specific typesAlignment palette

(resources) 148dialog boxes 152IDE SpeedBars 9

adding/deleting 16compiling options 41customizing 16

Tools palette (resources) 148, 188

byte-wise alignment 48

C/C linker option 55/c linker option 55C calling convention 48C language See ANSI C; Borland

C++C++ Options option (Project

Options) 52–54Call Stack command 107Call Stack window 107–108

opening 107Calling Convention option

(Project Options) 48calling conventions

fastthis 45Pascal See Pascal

callsfar 57function See function callsoptimizing 57Windows programs See

Windows API callscanceling builds 41Caption property 160Caption Type property 161captions

controls 160, 161main windows 71

cascading menus 173, 178case

controls, setting 164Case property 164case sensitivity

external symbols 55public symbols 55

Page 275: UG

I n d e x 275

.CBK files 15central processing unit See CPU.CFG files See configuration filesCGA Resolution command

(resources) 195Change Identifier Prefix

command (resources) 178, 181changes, source code,

undoing 10character sets 198

OEM 165, 166characters

newlinestatic controls 163

nullresource scripts 212

right-align 173, 174tab

menus 173, 174static controls 163

underliningstatic text controls 161

check boxes 152properties, setting 163

Check Dup Keys command (resources) 181

Check Duplicates command (resources) 177

child nodes 38, 41child windows

AppExpert options 71, 73viewing 114

circles, drawing 191.CKB files 15Class property 149classes 75

adding 76–78compiler options 52defining 218deleting from ClassExpert

projects 82importing 83moving 82, 83non-GUI 77renaming 83resources and 75, 80viewing 75, 76window 67

currently registered 113retrieving information

on 111Classes command (View) 86ClassExpert 75

adding classes 76–78AppExpert and 62, 65comment records 65

creating document types 78–79

default files 78deleting classes 82editor 76event handlers 76, 79, 83importing classes 83options 76

new classes 77overview 76renaming classes 83resources and 81

associating with classes 75, 80

handling controls 80retrieving information

on 82SpeedMenus 76starting 75viewing source code 76, 81

ClassExpert command (View) 75

ClassExpert window 76editing code 76

Clear Events command 108clearing IDE error messages 43client windows

AppExpert options 72Clip Children property 150Clip Siblings property 150code 9

See also source codeblank lines, breakpoints

and 97compiler options, setting 44defining color and font

attributes 15editing 9, 43

AppExpert 65, 66Breakpoints window 97Call Stack window 107ClassExpert window 76

headers and 218IDE options 22line numbers 57undoing changes 10

code segments 55compiler options 51detailed maps 56packing 55renaming 51

Code-Generation option (Project Options) 45

collapsing listsAppExpert hierarchies 62dialog boxes 14Project Manager 20

colorsbreakpoints, customizing 100graphics resources 189, 195,

197, 200syntax highlighting and 15text 192

Colors paletteGraphic editor 188, 189

customizing 200–201hiding 200

combining attribute 56combo boxes 152

properties, setting 166COMDEFs (communal

variables) 46, 50command-line compilers

resources See resource compilers

command-line optionsdebugging 47integrated debugger and 92messages 54precompiled headers 218, 219setting from IDE 35–40

commandsmenu See menu commands

commentsAppExpert and 66breakpoints and 97logging 108, 122

communal variables 46, 50compatibility See backward

compatibilitycompilation 19, 41–42

compiler errors and 222debugger and 91, 92DOS applications

as Windows 215fatal errors and 221generating browser

information 85large modules 217large programs 217nodes in Source Pools 29resources 142, 212specific project parts 42stopping 55syntax errors 42–43warnings and 222

Compile command (Project) 13, 41

Compiler option (Project Options) 45–50

compiler options 43–58See also command-line optionslanguage extensions 46messages 54

Page 276: UG

276 U s e r ’ s G u i d e

shortcuts 41Compiler Output option (Project

Options) 46compilers 217

See also command-line compilers

error messages 222Help systems 22, 222warnings, ignoring 13

compiling errorsviewing 43

Compose option (Style Sheets) 37

compressed formatsbitmaps 196fonts 198

conditional breakpoints 99disabling 97pass counts and 100

conditionsbreakpoints (defined) 99

conforming extensions 46console applications

converting to Windows 215constants

resourcesversions 208–211

Control ID property 162control-menu box

adding to main window 71controls 69, 80

See also resourcesaligning 148, 157–160

text 161, 163arranging 159captions 160, 161custom 153–154dialog boxes See dialog boxesfocus, setting 153grouping/ungrouping 157installing 153invisible 161moving 155, 156naming 161painting 149resizing 155–156selecting 154, 161tab order 157three-dimensional 153, 169

conversionsDOS applications to

Windows 215–216Convert OEM property 165Copy option (Style Sheets) 38copying project nodes 26–27copyright information 70

resources 211

.CPP files 10CPU

flags 106registers, checking 106

Create option (Style Sheets) 37creating

new program files 10DOS platforms 11Windows platforms 12

new projects 21–23, 36, 58resources See Resource

WorkshopSource Pools 29

.CSM files 218reducing size 219

CTL3D2V.DLL 169Ctrl-key shortcuts 176.CUR files 143cursors

position, Edit window 9cursors (graphics

resources) 187, 202, 203creating 195–196defining hot spots 196inverted areas 189properties, setting 196removing images 195testing 195transparent areas 189viewing 194

Custom Control tool (resources) 154

customer assistance 4customizing Resource

Workshop 144–145customizing the IDE 14–17CWH.HLP 22

D-d compiler option 45data

alignmentcompiler options 48

binary 134WinSpector reports,

processing 126far 50IDE options 22inspecting 105resources and 135values, changing 104, 105

data objects 90data segments

compiler options 49, 50detailed maps 56removing virtual tables 49

renaming 50uninitialized 50

data typeschar

treating as unsigned 45compiler options 45, 53resources, customizing 205,

206, 211–212, 213databases 153-dc compiler option 49Debug command (IDE) 8Debug menu 89debugger 89

accessing 89compiler options and 92controlling program

execution 92–96deleting breakpoints 98disabling breakpoints 97evaluating expressions 100,

101, 103–105changing values and 105restrictions 103

examining register values 106execution point 93, 100, 107flickering screens,

eliminating 91inspecting data elements 105invalid breakpoints 97, 100loading symbol tables 109logging messages 108moving through code 93–95

single stepping 93multiple statements and 92multitasking and 109restarting programs 95running programs 91–92

to breakpoints 95setting breakpoints 95, 96–97

after program start 96conditional 99pass counts and 99

starting 90stepping over code 94stopping programs 95, 99,

108symbolic debug

information 91, 93DLLs and 109

tracing into code 93–94, 107DLLs and 109

viewing breakpoints 97, 100watching expressions 101–

103deleting watches 103disabling watches 102formatting watches 102,

104

Page 277: UG

I n d e x 277

debugging 56See also debuggerarrays 102, 105assembly code 95bugs, types 89–90compiler options 47DLLs 109expressions 100–106external programs 95functions 93, 94, 107–108

locating specific 108member functions 95modes 109sessions, beginning 91statements 92, 93

in loops 100strategy 90–92structures 104subroutines 47variables 99, 103Windows applications 109,

111, 128Debugging option (Project

Options) 47debugging tools 111, 120decimal values

resources and 212watches and 102, 104

declarationsbreakpoints and 97

.DEF files See module-definition files

default file names 10, 21default keymapping 15default libraries

overriding 55default settings

IDE SpeedBars 17new projects 21, 58

default translators 31default viewers 31

AppExpert targets 75resources 81

Defines option (Project Options) 45

defining macros 45definitions

public 53template instances 53virtual tables 53

Delete All Breakpoints command 98

Delete Breakpoint command 98Delete Node option 24, 25Delete option (Style Sheets) 38deleting

breakpoints 98

classes 82event handlers 79instance variables 80project nodes 24, 25resources 176, 195

from script files 140, 141Style Sheets 38watches 103

derived classescompiler options 52

descendant relationships, viewing 86

desktop, viewing existing windows 114–115

destructors 54DFA utility 126–128DFA.EXE 126diacritical marks 198dialog boxes 147

adding menus 149backgrounds 149collapsing lists 14controls 152

adding 151–153aligning 148, 157–160custom 153–154grouping 157messages 153, 161moving 155, 156painting 149resizing 155–156selecting 154, 161tabbing through 157three-dimensional 153,

169creating See Dialog editorediting scripts 147–149expanding lists 14frames 150, 152, 161modal 170properties, setting 149–151,

160–168resizing, automatically 151source code for 170styles 150

extended 151testing 168

Dialog Client models 61, 68, 73Dialog editor (resources) 147–

149Alignment palette 148, 158customizing 169Duplicate tool 159Properties window 160Selector tool 154Set Groups tool 157Set Order tool 157starting 147

Style window 161–168Test tool 168Tools palette 148, 152

adding custom controls 154

undoing current actions 160dimming menu commands 174directories

file-search algorithms 44hierarchy trees See Project

TreeDirectories option (Project

Options) 43directory paths 69Disable All Breakpoints

command 98Disable Breakpoint command 98Disable Watch command 103disabling

autogenerating underscores 46

breakpoints 97invalid 97

drawing tools 200menu commands 174message tracing 112palettes 200syntax highlighting 16watches 102

dispatched messages 115displaying

project nodes 20warnings 55

DLLsbrowsing through 85debugging 109packing code segments 55

Document/View models 61, 68, 73

document types 78–79documentation, printing

conventions 3Don’t Redraw property 165DOS applications

32-bit executablescompiler options 51linking 57

compilingas Windows 215

converting to Windows applications 215–216

creating 11IDE options 22

DOS_TEST.CPP 11drag-and-drop actions 68DRAW.IDE 64

setting up 62

Page 278: UG

278 U s e r ’ s G u i d e

DRAWAPP.CPP 65–67drawapp.h 65drawing 190–192, 200

brush shapes 190paint patterns 190pen styles 189pop-up windows 149

drawing routines 149drawing tools (resources) 148,

188, 200drive specifier 43drivers

resources and 209drop-down lists See combo boxes.DSW files 17duplicate strings, merging 45Duplicate tool (resources) 159dynamic link libraries See DLLsdynamic objects 54

EEasyWin 215–216edit boxes 152

new lines 164properties, setting 164

Edit Breakpoint command 97, 98Edit command (IDE) 8Edit Local Options command

(IDE) 39Edit menu

adding to menu bars 173edit modes (IDE) 9Edit Node Attributes option 24,

31Edit option (Style Sheets) 38Edit Source command 97, 107Edit window (IDE) 43

customizing 15debugging programs 92, 93,

94, 96deleting breakpoints 98examining code 97, 107inspecting data

elements 105setting watches 101

loading source files 21, 43opening 10overview 9SpeedMenu, activating 9

editingcode 43

AppExpert 65, 66Breakpoints window 97Call Stack window 107ClassExpert window 76

node attributes 24, 26

resources 135, 138, 141, 206dialog boxes 147–149graphics 187–188in binary files 142in graphics files 144in script files 136menus 171–172string tables 183

Style Sheets 38, 41editors 10

ClassExpert 76reconfiguring IDE 15resource scripts 135–136, 206

EGA/VGA Resolution command (resources) 194, 195

ellipses, drawing 191Enable Breakpoint command 98Enable Watch command 103enabling menu commands 174enabling run-time type

information 54enhanced mode

packing code segments 55Entry/Exit Code option (Project

Options) 51enumerations

treating as integers 45environment

saving IDE settings 17Environment command

(Options) 14Environment Options dialog

box 14changing debugging

modes 110expanding/contracting

lists 14Project View options 28

Epsilon editor, emulating 15Eraser tool (resources) 192error messages 221–271

browser 86compiler 54, 222Help compiler 222IDE 42, 43resources 183, 213

errors 43, 222automatically tracking 43fatal 221, 222logic 90makefiles 222run-time 89–90, 222syntax 42–43TLINK 222unrecoverable

application 120, 127viewing 43

Evaluate/Modify command 103event handlers 76, 79

deleting 79renaming 83

Event Log command 108Event Log window 100, 108

opening 108events 75exceptions 122

addresses 123compiler options 54logging 122–126run-time identification 54

.EXE files See executable filesexecutable files 129

including debug information 91

reducing size 91viewing 85

EXEMAP.EXE 128exit code 51Exit command (Spy) 112expanding lists

AppExpert hierarchies 62dialog boxes 14Project Manager 20

export functionscompiler options 51–52prologs and epilogs 51, 52

Expression Evaluator dialog box 103–104

expressionsBoolean

breakpoints and 99changing 103current value, viewing 101debugging 100–106evaluating 100, 101, 103–105

restrictions 103inspecting 105logging 100, 108

Extend Select property 166Extended Style property 151extensions

See also file-name extensionslanguage, conforming 46

external modules 55external programs,

debugging 95external symbols 55

F-f compiler option 46/f linker option 57far calls 57far data 50

Page 279: UG

I n d e x 279

far pointerscompiler options 49, 50

_ _fastthis calling convention 45fatal errors 221

Help compiler 222-Fc compiler option 46-Ff compiler option 50-ff compiler option 46File command (IDE) 8file filters

AppExpert 74ClassExpert 78

File Manager (Windows)adding source nodes 24

File menuadding to menu bars 173

file names 10, 21AppExpert 62ClassExpert 78

filesSee also specific program filesadding to projects 24binary See binary filescompiler options, setting 44generated 62keyboard mapping 15log 108, 122, 122–126map See map filesopening

backward compatible 27redistributable iisymbol tables and 91temporary 44text See text filesviewing in IDE 20

file-search algorithms 44fill patterns 190filters 31

AppExpert 74browser 87ClassExpert 78

Filters matrix (IDE) 87Find Execution Point

command 93Find Window command

(Spy) 114First Graphic command

(resources) 178fixed-width fonts 198fixing errors 43flags

checking 99status 106

flickering screens, eliminating 91floating menus 177

Floating Point option (Project Options) 46

floating-point librariescompiler options 46

floating-point operationscalculations, turning off 46optimizing 46

floating-point valueswatches and 102, 104

flood-filling algorithm 191.FNT files 143focus See controlsFont Character Width command

(resources) 198Font command (resources) 192Font Name property 150Font Size command

(resources) 198, 199Font Size property 150fonts 187, 198

break character, specifying 199

changing 192specific characters 199

character mapping 198–199dialog boxes 150properties, setting 197–199syntax highlighting and 15version information 209

foreground colorsgraphics resources 189syntax highlighting 15

format specifierswatches 104

syntax 102formats

compressedbitmaps 196fonts 198

rich-text 222files, generating 69

formatting watches 102, 104Frame Style property 150frame windows

properties, setting 77frames 167

dialog boxes 150, 152, 161free-hand drawing 190-Fs compiler option 49function calls

viewing 107functions 47

debugging 93, 94, 107–108locating specific 108

exporting See exporting functions

inline See inline functions

inspecting 105Windows See Windows

functionsWinSpector and 124with no parameters 47

G-g compiler option 55General Protection Exception

dialog box 108general protection faults 108, 120generated files 62generating symbolic debug

information 91generating underscores 46geometric shapes, drawing 191global symbols

searching for 88viewing 86–87

global variablescompiler options 50

global virtual tables 53/Gm linker option 57/Gn linker option 57GPFs 108, 120/Gr linker option 57Graphic editor (resources) 187–

188Airbrush tool 190Colors palette 188, 189

customizing 200–201hiding 200

copying and moving areas 193

customizing 199–201Eraser tool 192Hand tool 194Line tool 191manipulating areas 193Paint Can tool 191Paint Pattern tool 190Paintbrush tool 190Pen Style tool 189Pick Rectangle tool 192Scissors tool 193selecting areas 192–193starting 187Text tool 192Tools palette 188

hiding 200window, splitting 200Zoom tool 194

graphics 187, 205adding text 192aligning 192, 193

Page 280: UG

280 U s e r ’ s G u i d e

brush shapes and patterns 190

colors 189, 195, 197changing 200

creating See Graphic editordrawing and painting 189–

192, 200editing scripts 187–188enabling grids 201erasing 192flood-filling algorithm 191large 194moving 194pen styles 189resource scripts and 138RLE compression

algorithm 196screen resolution, setting 194source code for 201–203testing 195viewing 194

multiple images 199zooming 194, 201

graphics filesresources 143–144

Grid command (resources) 159grids

aligning controls 159enabling 201

group boxes 152properties, setting 164

Group property 157

H-H compiler option 48-h compiler option 50Hand tool (resources) 194handlers

See also event handlershardware 2Has Strings property 166hdrfile pragma directive 218hdrstop pragma directive 219Header command

(resources) 197header files

compiler options 48parsing 217referencing 29resources 141, 142

headerscontaining code 218precompiled 217–220

compiler options 218, 219optimizing 219–220storing 217, 218

warnings 218heap, tracing into 126Height property 160Help command (IDE) 8

See also online helpHelp compiler 22

messages 222Help files, searching through

multiple 4Help menu 3

adding to menu bars 173Help systems 61, 69, 222

About dialog box 70Hex Values (WinSight

option) 116hexadecimal numbers

resources and 212hexadecimal values

watches and 102, 104Hide Palette command

(resources) 200Hide Toolbox command

(resources) 200hiding IDE SpeedBars 16hierarchies (classes) 86hierarchy trees See Project Treehistory, recording 108

See also log filesHorizontal Scroll Bar

property 161horizontal scroll bars 164

dialog boxes 152, 161main windows 71

Horizontal Scroll property 150hot spots (cursors) 196-Hu compiler option 48huge pointers

compiler options 50

I-i compiler option 46/i linker option 57I/O

See also input; output.ICO files 143icons

Alignment palette 148program 7Tools palette 148, 188used in documentation 3

icons (graphics resources) 138, 187, 202, 203

as controls 152, 167colors, setting 197creating 195–196

inverted areas 189properties, setting 197removing images 195testing 195transparent areas 189viewing 194

ID source/Control ID property 161

ID Value property 161IDABORT constant 162IDCANCEL constant 162.IDE files 21, 82

See also project filesIDE 7–18, 218

adding tools 31–33browsing classes and

objects 85–88customizing 14–17

keyboard shortcuts 15Tool menu 18

defining macros 45disabling invalid

breakpoints 97displaying errors 42, 43Edit window See Edit windowgenerating resources 142integrated debugger,

starting 90menu 8predefined Style Sheets 36preferences 17Project Manager See Project

ManagerResource Workshop, starting

from 135restoring defaults 17running programs 18, 91–92saving settings 17setting command-line options

debugging 47messages 54

SpeedBars 9, 16hiding 16

SpeedMenus 9starting 7viewing program status 9windows 16

See also specific windowidentical SpeedBars 17identifiers

See also namesconflicts 46generating underscores

automatically 46resources 136, 140–142, 184

accelerators 179changing 178, 181, 184checking for duplicate 177

Page 281: UG

I n d e x 281

controls 161renaming 83

significant length 46truncated 46virtual keys 176

Identifiers command (resources) 140

Identifiers dialog box 140IDIGNORE constant 163idle symbols 56IDNO constant 163IDOK constant 162IDRETRY constant 163IDYES constant 163ignoring warnings 13images (defined) 195import librarian See IMPLIBimporting classes 83importing project files 27#include directive 44include files

file-search algorithms 44include paths See directory pathsinheritance 76

multiple 52project options 36, 38

_InitEasyWin function 215–216initialization

variables 46inline expansion 47inline functions

compiler options 47, 53precompiled headers 218

inputTTY devices 215

input messagescontrols 165

Insert mode (IDE) 9Inspect Expression window 105Inspect Object command 105inspecting data 105Inspector windows 105–106installation

custom controls 153hardware requirements 2software requirements 2

instance variables 76, 80renaming 83

instantiationtemplates 54

instructionsassembler See assembly

languageintegers

See also numberswatches and 102, 104

Integral Height property 165, 166

integrated debugger See debugger

integrated development environment See IDE

IntelACBP fields 56

interfaces See user interfacesinternational

versions, resources 139–140, 209–210

Interpret Values option (WinSight) 116

invalid breakpoints 97, 100Invalid Breakpoints dialog

box 97invisible controls 161

J-j compiler option 55-Jg compiler option 53-Jgd compiler option 54-Jgx compiler option 54

K-K compiler option 45-k compiler option 47-K2 compiler option 53.KB files 15Keep Selection property 165Key Value command

(resources) 180keyboard

moving controls 155resizing controls 156

keyboard mapping files 15keyboard shortcuts

adding to menus 173, 174, 175–176

IDE windows 15

L-L compiler option 44/l linker option 57Language command

(resources) 140languages

extensions, conforming 46large memory models

compiler options, setting 49Left property 161libraries

compiler options 44

dynamic link See DLLsfile-search algorithms 44floating-point 46ignoring default 55import See import librariesrun-time See run-time

librariesspecifying 22

line controls 167line numbers

including in .OBJ files 47map files 57returning in Edit window 9

Line property 165Line tool (resources) 191lines, drawing 189, 191linkage 41

32-bit applications 57automatic 20external modules 55floating-point libraries 46generating browser

information 85resources 142Windows applications 23

linker errors 222Linker option (Project

Options) 55linkers See RLINK; TLINKlinking and embedding servers

See servers (linking and embedding)

linking resources to applications 135, 142, 184

list boxes 152properties, setting 165

listsexpanding/contracting 14, 20

AppExpert 62sorting 165, 166

literal stringscompiler options 45, 49

Load Symbol Table command 109

Load Symbol Table dialog box 109

loading files See files, openingLocal Edit property 150local overrides (Style Sheets) 35,

39–40, 41undoing 39

local symbols 86–87local variables 47local virtual tables 53Locate Function command 108log files 108

Page 282: UG

282 U s e r ’ s G u i d e

adding comments 122tracking exceptions 122–126

logging expressions 100, 108logging messages 108logic errors 90logical addresses 123loops

debugging 100

M/M linker option 56/m linker option 56machine instructions See

instructionsmachine-dependent

constructs 222macros

defining 45MAKE See MAKEprecompiled headers and 218undefining 45

main windowsAppExpert options 69, 71dialog boxes as 61, 149disabling at startup 71

.MAK files See makefilesMAKE

autodependency information 46

building vs. 41Make All command (Project) 41Make option (Project

Options) 58makefiles

errors 221, 222mangled names 45

linking and 56manifest constants See macrosmap files 56

adding symbols 56creating 128suppressing build 56viewing code 57

Maximize Box property 150maximize boxes

main windows 71MDI applications 61, 68

AppExpert options 72, 73medium memory models

compiler options, setting 49member functions

debugging 95inline

compiler options 53expansion 47precompiled headers 218

Member Pointer option (Project Options) 52

memoryallocation

resources 139, 184, 211dump 104location, watching 104

memory addressespointers 104

Memory Model option (Project Options) 49

memory modelsSee also specific modelcompiler options 49specifying 22

Memory Options command (resources) 139

menu bars 172–173menu commands

adding to menus 173–176associating with

shortcuts 174, 175–176checking for duplicate

names 177display options 174flashing 175, 176Help text and 175manipulating 176viewing 172

Menu editor (resources) 171–172customizing 178starting 171

Menu property 149menus 171

adding to menu bars 172–173associating with

shortcuts 173creating See Menu editordeleting 176dialog boxes 149editing scripts 171–172floating 177IDE 8moving 176separators 173, 174source code for 181–182testing 177, 178viewing 172

merging duplicate strings 45Message Trace Options dialog

box 116Message window 42messages

See also notification messages; prompts

command-line options 54error See error messages

Help compiler 222input

controls 165logging 108saving WinSight 116tracing 112, 113, 115–120

Messages option (Project Options) 54

metafiles 205Minimize Box property 150minimize boxes

main windows 71-ml compiler option 49-mm compiler option 49-mm! compiler option 49modal dialog boxes 170Modal Frame property 150modes

debugging 109memory 55

module definition filescase sensitivity 55

modulescompiling large 217debugging information

and 91linking 55sharing objects 49tracing into 125

moving controls 155, 156moving through Message

window 43moving through source code 93–

95single stepping 93

-ms compiler option 49-ms! compiler option 49Multi Column property 166multiple controls, selecting 154multiple Help files, searching 4multiple inheritance 52Multiple Select property 165multiple-document interface

applications See MDI applications

multitaskingdebugger and 109

MULTITRG.IDE 25

N-N compiler option 47-n compiler option 44/n linker option 55names

See also identifiers

Page 283: UG

I n d e x 283

conflicting 46mangled 45

linking and 56New AppExpert Project dialog

box 62New Image command

(resources) 195New Menu Item command

(resources) 174New Popup command

(resources) 173New Project command

(Project) 21New Target command

(Project) 25New Target dialog box 21

adding targets 25setting target options 21–23

newline character (\r)static controls 163

No Character Underlining property 161

No Idle Messages property 150Node Attributes dialog box 24nodes

Project Manager See Project Tree

non-GUI classes 77nonzero values

variables 46notebook tabs 153notification messages

dialog boxes 153, 161Notify property 165null characters

resource scripts 212numbers

See also constants; integersresources and 212

O.OBJ files See object filesobject files

debugging information 47including line numbers 47

Object Linking and Embedding See OLE

objects 90browsing through

hierarchies 86compiler options 49dynamic 54sharing 49

ObjectWindows applications 61adding classes 76

octal numbersresources and 212

OEM character sets 165, 166OEM Conversion property 166OLE applications 69online help 3–4

AppExpert 63building 61, 69compiler messages 222menu commands,

building 175Open command (Project) 41Open Detail command (Spy) 112Open Project command

(Project) 24, 27OpenHelp tool 4opening files

backward compatible 27project 41

opening windowsBreakpoints 97Call Stack 107Edit 10Event Log 108Project 24Register 106Watch 101

operating system See systemoptimization 55

far calls, inhibiting 57floating-point operations 46large programs 217precompiled headers 219–

220registers 45

optionsSee also command-line optionsAppExpert 68–74

specifying 64ClassExpert 76, 77projects 35

changing 28defaults, setting 58inheriting 36, 38viewing 40

WinSpector 121Options command (IDE) 8Options Hierarchy dialog box 40out-of-date nodes 41output

logging messages 108testing 90TTY devices 215watching program 91

overflow 47Overwrite mode (IDE) 9Owner Draw property 161

Owner Drawing property 161

P/P linker option 55-p compiler option 48packing code segments 55pages

alignment 57Paint Can tool (resources) 191Paint Pattern tool

(resources) 190paint patterns (resources) 190painting 190, 200

controls 149windows 71

palettesdisabling 200resources See specific editor

parametersSee also argumentsfunctions with no 47

Parent Notify property 153, 161parsing header files 217Pascal

calling conventionscompiler options 48

debugging programs 95pass counts 99

See also debuggingviewing 97

Pass Keyboard Input property 166

Password property 165passwords 165paths See directory pathsPause Program command 95pausing program execution 95,

99-pc compiler option 48Pen Style tool (resources) 189pens 189performance See optimizationphotographs, scanning 196Pick Rectangle tool

(resources) 192platforms

See also DOS; Windows programs

setting 21plus sign (+)

AppExpert hierarchies 62-po compiler option 45pointers

derived classes 52far

Page 284: UG

284 U s e r ’ s G u i d e

compiler options 49, 50huge

compiler options 50memory addresses 104suspicious 49

pop-up windows 147See also dialog boxesdrawing 149frames 167menus 149overlapping 151properties 149–151

-pr compiler option 49#pragma directives

precompiled headers and 218, 219

precompiled headers 217–220compiler options 48, 218, 219optimizing 219–220storing 217, 218warnings 218

Precompiled Headers option (Project Options) 48

predefined colorsProject Manager 20syntax highlighting 15

predefined resources 153, 172, 211

predefined Style Sheetsattaching to nodes 36

preferences (IDE) 17Preferences command

(Environment) 43preserving IDE error

messages 43printing 68

WinSight messages 116printing conventions

(documentation) 3.PRJ files 27Processor option (Project

Options) 48program files

adding to Tool menu 31creating new 10

DOS platforms 11Windows platforms 12

default 10status in Edit window 10

program group 7Program Manager

Resource Workshop, starting from 135

programsSee also DOS programs;

Windows programscompiling See compilation

crashing 108debugging See debuggingexecution

controlling 90, 92–96pausing 95, 99terminating 95

external 95failing 89history, recording 108implementation, problems

with 90large 217linking See linkagerunning 13

from the IDE 18in the IDE 91–92to breakpoints 95to specific locations 92

single-source 13stepping through 93–95

single stepping 93testing 10, 90, 104tracing into 125type, setting 11, 12watching 91

Project command (IDE) 8Project command (Options) 36Project command (View) 24project files 62, 69

See also projectsbackward compatibility 27browsing 85including debug

information 91opening 41rearranging in IDE 26targets 36

adding 25changing defaults 21defining multiple 29deleting 26dependent files 20setting options 21–23updating 29, 41

testing 10viewing 20

Project Manager (IDE) 19, 20–29adding files 24creating projects 21–23, 36glyphs 21loading preexisting project

files 27Project Tree See Project Treesetting target options 21–23SpeedMenus 9Style Sheets See Style Sheetstranslators, specifying 25, 30

Project menu 41

project nodes (IDE) 20See also Project Tree

Project Options dialog box 36setting options 43

Project Style Sheet 36settings, overriding 36

Project Tree 20–21See also Project Managerexpanding/contracting

lists 20nodes

adding 24, 25, 42compiling 29copying 26–27deleting 24, 26, 27editing 24, 26moving 26option settings 35out-of-date 41referencing 29specifying 23Style Sheets 36, 39translating 24, 30, 41, 42types, defined 20viewing 28

settings 40Project View options 28Project window

customizing 28generating symbolic debug

information 91opening 24SpeedBar buttons 9viewing resources 144

project-manager utility See MAKE

projectsSee also project files; Project

Manageradding source files 24building 41

parts of 42canceling builds 41compiling See compilationcreating new 21–23, 36, 58importing earlier versions 27linking See linkagemanaging 19options 35

changing 28inheriting 36, 38setting defaults 58viewing 40

samplemulti-targets 25Source Pools 30Style Sheets 36

setting up 10

Page 285: UG

I n d e x 285

prompts 183properties

bitmaps 196breakpoints 98–100cursors 196dialog boxes 149–151, 160–

168fonts 197–199frame windows 77icons 197

Properties window (resources) 160

proportionally-spaced fonts 199public definitions 53public symbols 55, 56push buttons 152, 162

properties, setting 162–163

R-R compiler option 47-r compiler option 46radio buttons 152

properties, setting 163.RC files

See also resource script files-rd compiler option 45reconfiguring the IDE 14–17rectangle controls 167rectangles, drawing 191redistributable files iireferencing/dereferencing

templates 54virtual tables 53

Register command 106register keyword 45register variables

compiler options 45registers 49

CPU, checking values 106optimizing 45tracing into 124

registers calling convention 49Registers window 106Remove All Messages option 43Rename option (Style Sheets) 38renaming Style Sheets 38repainting windows 71repeat counts 102, 104

See also watches.RES files

See also resource script filesRescan 65, 82–83

moving classes 82, 83resizing characters 198resizing controls 155–156

resizing main windows 71resource script files 135–142

adding scripts 137binary 142–143changing 136compiling and linking 142,

212creating 136identifiers 140–141

resource scripts 135, 137–140changing 138, 141controls 169copying and moving 138creating new 137, 138customizing resources 206–

212deleting 140, 141entering data 212

Resource Workshop 62, 133ClassExpert and 81custom data types 205, 206,

211–212, 213customizing 144–145editors 135–136, 138

accelerators 178customizing 169, 178, 185,

199–201dialog boxes 147–149graphics 187–188menus 171–172scripts 206–212string tables 183

error messages 183, 213installing custom controls 153starting 135

Resource Workshop command (Tool) 135

resources 135See also specific typesallocating memory 139, 184,

211associating with classes 75, 80compiling See resource

compilersdefined 134drawing routines 149editing 135, 138, 141, 206

in binary files 142in graphics files 144in script files 136

generating binary 142header files 141, 142identifiers 184

changing 178, 181, 184duplicate, checking

for 177international versions 139–

140, 209–210

linking to applications 135, 142, 184

naming 136, 140–142accelerators 179controls 161

predefined 153, 172, 211renaming 83retrieving information on 82setting version 206–211, 213

header file 208testing 168, 177, 178, 195tools 148, 152, 188

disabling 200transfer buffers 80types 134user-defined 205–214viewing 144, 194

multiple images 199Resources option (Project

Options) 58restarting programs (integrated

debugger) 95restoring defaults

IDE SpeedBars 17rich-text formats 222

files, generating 69right-align character (\a) 173,

174RLE compression algorithm 196RLINK.EXE

See also resource linkersRLINK32.DLL

See also resource linkersrounded rectangles,

drawing 191routines

drawing 149.RSP files See response files-RT compiler option 54.RTF files 222

generating 69RTTI 54RTTI option (Project Options) 54Run command (Debug) 13Run To Cursor button 92Run to Cursor command 92run-time errors 89–90, 222run-time nodes (IDE) 20run-time type information See

RTTI

S/s linker option 56sample projects

multi-targets 25Source Pools 30

Page 286: UG

286 U s e r ’ s G u i d e

Style Sheets 36Save Events To File

command 108Save Resource As command

(resources) 138saving

IDE settings 17window settings 17

scalars, inspecting 105scanned photographs 196Scissors tool (resources) 193screens

flickering, eliminating 91resolution 194

Script editor (resources) 206–212starting 206

Scroll Bar Always property 166scroll bars 164

combo boxes 166dialog boxes 152, 161list boxes 166main windows 71

SDI applications 61, 68, 72creating 62

Search command (IDE) 8search operations

online help 4symbols 88

search paths See directory pathsSecond Graphic command

(resources) 178Segment Names Data option

(Project Options) 50segments

code See code segmentscompiler options 50–51data See data segmentsdetailed maps 56renaming 50–51trailing 57

Selected Classes command (Messages) 113

Selected Windows command (Messages) 115

Selector tool (resources) 154separators

dialog boxes 152menus 173, 174

deleting 176moving 176viewing 172

servers (automation) 70servers (linking and

embedding) 70Set Grid Attributes dialog

box 159

Set Groups command (resources) 157

Set Groups tool (resources) 157Set Hot Spot command

(resources) 197Set Options command 108Set Or Clear An Unconditional

Breakpoint button 96Set Order tool (resources) 157Set Range command 106Set Watch command 101SetCursor member function

TWindow 202SetIcon member function

TFrameWindow 202setting breakpoints 95, 96–97

after program start 96setting watches 101settings

reconfiguring IDE 15–17resources See propertiessaving IDE 17window 17

shapes, drawing 191shortcuts

compiler options 41keyboard

adding to menus 173, 174, 175–176

IDE windows 15Show Palette command

(resources) 200Show Project Node option 20Show Properties command

(resources) 160Show Toolbox command

(resources) 200single-document interface

applications See SDI applications

single-source programs 13Size and Attributes command

(resources) 196, 197Size command (resources) 155Size Controls dialog box 155, 156small memory models

compiler options, setting 49software 2Sort property 165, 166source code

accelerators 181–182debugging 91, 92, 104

breakpoints and 96execution point 93, 100,

107dialog boxes 170

editingBreakpoints window 97Call Stack window 107

generating with AppExpert 64, 70

graphics 201–203machine-dependent

constructs 222menus 181–182moving through 93–95

single stepping 93viewing 76, 81, 91, 97, 107

source files 19accessing 21adding to projects 24Edit window 21, 43fixing errors 43rearranging in IDE 26viewing 21WinSpector reports 127

source nodes (IDE) 20See also Project Treeadding 24attributes 24deleting 24referencing 29specifying 23translating 24viewing 28

Source option (Project Options) 46

Source Pools 29–30compiling nodes 29creating 29

Special command (SpeedMenu) 31

SpeedBars (IDE) 9customizing 16hiding 16

SpeedMenusAppExpert 62ClassExpert 76IDE 9, 31

adding tools 32Split Horizontal command

(resourcers) 200Split Vertical command

(resourcers) 200spying on classes 113spying on windows 115squares, drawing 191SRCPOOL.IDE 30stack

IDE options 22overflow 47tracing into 47, 122, 124, 127

Page 287: UG

I n d e x 287

Standard Libraries options (IDE) 22

Start! command (WinSight) 112starting

AppExpert 62ClassExpert 75IDE browser 85, 86OpenHelp 4Resource Workshop 135WinSight 111WinSpector 121

statementschecking 90debugging 92, 93, 100

static text controls 152character underlining 161new lines 163properties, setting 163

status bars 68, 175IDE 9

status flags 106Step Over button 94Step Over command 94stepping through programs 93–

95single stepping 93

Stop! command (WinSight) 112stopping compilation 55stopping program execution

(integrated debugger) 95, 99, 108

String editor (resources) 183customizing 185

string resources See string tablesstring tables 175, 183–185

adding to scripts 183allocating memory 184changing 184

stringsincluding in resource

scripts 212literal

compiler options 45, 49structures 50

debugging 104inspecting 105watching 104

Style Sheets 36–41copying 38creating 37defined 35deleting 38editing 38, 41overriding 35, 39–40, 41scope 38sharing 38–39undoing overrides 39

Style Sheets command (Options) 36

Style Sheets dialog box 36options 37–38

Style window (Dialog editor) 161–168

stylesdialog boxes 150, 151document types 78pens 189

STYLESHT.IDE 36subroutines

debugging 47suspicious pointers 49switches See command-line

options.SYM files 124, 128symbol tables 91, 217

adding to files 91loading 109

symbolic addresses 56symbolic browser

information 85symbolic constants See macrossymbolic debug information 91,

93See also symbol tablesDLLs and 109

symbols 55case 55idle 56public 56searching for 88viewing 86–87

syntaxformat specifiers

watches 102syntax errors (defined) 42Syntax Highlighting option 15system information,

returning 126System menu

adding to main window 71System Menu property 150System Modal property 150

Ttab character (\t)

menus 173, 174static controls 163

Tab Stop property 161Tab Stops property 165tabbing through controls 157tables

virtual 49, 51, 53

tabs (notebook) 153target files 19Target Model options (IDE) 22target nodes (IDE) 20

See also Project Treeadding 25attributes 26deleting 26multiple 29types, defined 25updating 29viewing 28

target platformsSee also DOS; Windows

programssetting 21

TargetExpert 22editing target attributes 26

TargetExpert dialog box 26targets See makefiles; project filesTBitmap class 201TClientDC class 201TDialog class 170TDibDC class 201TDip class 201technical support 4TEditView class 78template classes

compiler options 53instances, duplicating 54referencing/dereferencing 54

Templates option (Project Options) 53

temporary files 44Terminate Program

command 95, 108terminating programs 95Test Dialog command

(resources) 168Test tool (resources) 168testing

applications 30, 91program setup 10programs 90, 104resources 168, 177, 178, 195

text 183adding to graphics 192aligning 192

in controls 161, 163colors 192

Text Edit command (View) 21text editors 10

reconfiguring IDE 15resource scripts 135–136, 206

text strings See stringsText tool (resources) 192

Page 288: UG

288 U s e r ’ s G u i d e

TFrameWindow classcreating icons 202members

SetIcon 202Thick Frame property 150this pointer

compiler options 45three-dimensional controls 153,

169title bars

main windows 71TLINK

See also TLINK32ACBP fields and 56compiler options 53errors 222options 55

TListView class 78TMAPSYM.EXE 128TMenu class 181Toggle Breakpoint command 96,

98Tool command (IDE) 8Tool menu

adding files 31customizing 18

toolbars 68TOOLHELP.DLL 121tools 30–33

adding to IDE 31–33adding to SpeedMenus 32defined 30

Tools command (Options) 31Tools dialog box 31Tools palette

Dialog editor 148, 152adding custom

controls 154Graphic editor 188

hiding 200Top property 161Trace Into button 93Trace Into command 93–94tracing into code 93–94, 107

See also debuggingDLLs and 109

tracing messages (WinSight) 112, 113, 115

Track Test Menu command (resources) 178

trailing segments, uninitialized 57

transfer buffersresources 80

transfer macros 31

translating project nodes 24, 30, 41, 42

translators 30specifying 25

truncated identifiers 46TTY devices 215Turbo Debugger 127Turbo Pascal See Pascalturning off

breakpoints 97drawing tools 200message tracing 112palettes 200syntax highlighting 16underscores 46watches 102

-tW compiler option 51-tWD compiler option 52-tWDE compiler option 52-tWE compiler option 51TWindow class

creating cursors 202members

SetCursor 202TWindowView class 78-tWS compiler option 52-tWSE compiler option 52Type property 149, 151

check boxes 163combo boxes 166frames 167group boxes 164lines 167push buttons 162radio buttons 163rectangles 167static text controls 163

typographic conventions (documentation) 3

U-u compiler option 46UAEs 120

multiple 127undefined watches 101undefining macros 45underbars See underscoresunderscores 46Undo command (Edit) 10Undo command (resources) 160undocumented Windows

messages 116uninitialized data segments 50uninitialized trailing

segments 57

unionswatching 104

unrecoverable application errors 120, 127

updating targets 29, 41user interfaces

components 134dialog boxes as main 61, 68testing 90

user-defined resources 205–214utilities See specific C++ utility

V-V compiler option 53-v compiler option 47/v linker option 55-V0 compiler option 53-V1 compiler option 53values

ACBP fields 56changing 103, 104, 105checking 90, 91, 100CPU registers 106decimal

watches and 102, 104expressions, viewing 101floating-point

watches and 102, 104hexadecimal

watches and 102, 104variables

See also environment variablescommunal 46, 50debugging 99, 103global 50initializing to nonzero

values 46instance 76, 80

renaming 83local 47register 45values

changing 103, 104checking 90, 91, 100

variable-width fonts 197, 198ver.h 208verbose stack trace 122, 127version compatibility

loading project files 27version information

(resources) 206–211, 213header file 208

version numbers 70Vertical Scroll Always

property 166Vertical Scroll Bar property 161

Page 289: UG

I n d e x 289

vertical scroll bars 164dialog boxes 152, 161main windows 71

Vertical Scroll property 150-Vf compiler option 49-vi compiler option 47View As Popup command

(resources) 178View Breakpoint command 97View command (IDE) 8View menu 89View Options Hierarchy

command (IDE) 40View Source command 97, 107viewers 30

AppExpert targets 75defined 30resources 81

viewing 106arguments 107breakpoints 97, 100classes 75, 76current windows 114–115executable files 85expressions 101function calls 107IDE errors 42, 43pass counts 97project files 20project nodes 28

settings 40resources 144, 194

multiple images 199source code 91, 97, 107

ClassExpert window 76, 81

source files 21status flags 106symbols 86–87warnings 55WinSight messages 112–113WinSpector reports 122

virtual functions 75, 76compiler options 49event handlers 79

virtual keys 175, 176virtual tables 49, 51, 53

referencing/dereferencing 53Virtual Tables option (Project

Options) 53Visible property 150, 161visual application generation 61Visual Basic controls 153Visual Solutions Pack 153-Vmm compiler option 52-Vmp compiler option 52-Vms compiler option 53

-Vmv compiler option 52-Vs compiler option 53

W-W compiler option 51-w compiler option 55warnings 43, 222

compiler 54displaying 55ignoring 13precompiled headers 218viewing 55

Watch command 101watch expressions See watchesWatch Properties dialog box 101

settings, losing 102Watch window 101

opening 101updating 101

watches 101–103See also debuggingdeleting 103disabling 102formatting 102, 104undefined 101

-WC compiler option 51-WD compiler option 52-WDE compiler option 52-WE compiler option 51Width property 161wildcards

AppExpert 74ClassExpert 78search expressions

browser 88WIN_TEST.IDE 12Win32 applications See Windows

applications, 32-bit executableswindow classes

creating 67currently registered 113retrieving information on 111

Window command (IDE) 8Window messages 109windows

child 114AppExpert options 71, 73

clientAppExpert options 72

frameproperties, setting 77

IDE See specific windowmain

AppExpert options 69, 71dialog boxes as 61, 149disabling at startup 71

Message 42opening

Breakpoints 97Call Stack 107Event Log 108Register 106Watch 101

painting 71pop-up See pop-up windowsretrieving information on 111saving settings 17viewing current 114–115

Windows 3.1 Style property 164Windows API calls

resources 170, 181, 203Windows applications 183

32-bit executablescompiler options 51

creating 61, 68debugging 109, 111, 128IDE options 22, 23main window 69, 71resources See resources

Windows classes (controls) 160Windows functions

accelerators 181compiler options 51dialog boxes 170exportable 51menus 181

Windows messagesdialog boxes 153, 161tracing 112, 113, 115–120

Windows programs 109, 123converting DOS programs

to 215–216creating 12–13running 13system information 126

WinSight 111–120class lists 113exiting 112locating windows 114printing messages 116saving messages 116starting 111tracing messages 112, 113,

115–120viewing messages 112–113windows hierarchy lists 114–

115WinSight window 111

choosing views 112WINSPCTR.BIN 121, 122, 126

DFA utility and 127WINSPCTR.INI, editing 121WINSPCTR.LOG 121, 122–126

Page 290: UG

290 U s e r ’ s G u i d e

configuring 121DFA utility and 127

WinSpector 120–129adding source files to

reports 127appending new reports 121exception types 122heap information 126including line numbers in

reports 127listing functions 124locating last message

received 124modules list 125options 121overwriting previous

reports 121processing data 126–128program lists 125reading log file 122–126setting preferences 121stack pointer 123starting 121system information

returning 126tracing into stack 124utilities 128–129viewing reports 122

word alignment 48word-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

Zoom In command (resources) 194

Zoom Out command (resources) 194

Zoom tool (resources) 194-zP compiler option 51-zR compiler option 50-zS compiler option 50-zV compiler option 51-zW compiler option 51

Page 291: UG

U s e r ’ s G u i d e

Page 292: UG

User’s Guide

V E R S I O N 4 . 5

Borland International, Inc., 100 Borland WayP.O. Box 660001, Scotts Valley, CA 95067-0001

Turbo C ++®

Page 293: UG

Redistributable filesYou 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.

1E0R10949495969798-9 8 7 6 5 4 3 2 1H1

• BC450RTL.DLL

• BIDS45.DLL

• BIVBX11.DLL

• BWCC.DLL

• BIVBX11C.DLL

• BIVBX11N.EXE

• BIVBX11S.DLL

• BOCOLE.DLL

• GAUGE.VBX

• BWCC0009.DLL

• OWL250.DLL

• PICT.VBX

• BWCC000C.DLL

• SWITCH.VBX

• LOCALE.BLL

Page 294: UG

i

Introduction 1What’s new in Turbo C++. . . . . . . . . . . . . . 1Hardware and software requirements . . . . . . 2Manual conventions . . . . . . . . . . . . . . . . . 3Getting help . . . . . . . . . . . . . . . . . . . . . . 3

Searching through multiple Help files with OpenHelp . . . . . . . . . . . . . . . . . . . . . .4

Software registration and technical support . . . 4

Part IUsing the integrated development environment 5

Chapter 1Getting started 7Starting the Turbo C++ IDE. . . . . . . . . . . . . 7

The IDE menu system . . . . . . . . . . . . . . . .8The IDE SpeedBar . . . . . . . . . . . . . . . . . .9

Using SpeedMenus in the IDE . . . . . . . . . . . 9Using the Edit window . . . . . . . . . . . . . . . 9

Creating a new file . . . . . . . . . . . . . . . . . 10Working with simple projects . . . . . . . . . . 10

Creating an EasyWin Program . . . . . . . . . . 11Creating a Windows program . . . . . . . . . . 12Single file programs . . . . . . . . . . . . . . . . 13

Customizing the IDE. . . . . . . . . . . . . . . . 14Configuring the IDE editor . . . . . . . . . . . . 15Syntax highlighting. . . . . . . . . . . . . . . . . 15Customizing the SpeedBars. . . . . . . . . . . . 16Setting IDE preferences . . . . . . . . . . . . . . 17Saving your IDE settings . . . . . . . . . . . . . 17

Running other programs from the IDE . . . . . 18

Chapter 2Creating and managing projects 19What is project management? . . . . . . . . . . 19Using the Project Manager . . . . . . . . . . . . 20

Creating a project . . . . . . . . . . . . . . . . . . 21Setting target options with the New Target

dialog box . . . . . . . . . . . . . . . . . . . . 21Specifying the source node types . . . . . . . 23Opening existing projects . . . . . . . . . . . . 24

Adding source nodes to your project . . . . . . 24Deleting source nodes . . . . . . . . . . . . . . 24

Editing source node attributes . . . . . . . . . . 24Adding target nodes to your project. . . . . . . 25

Deleting target nodes . . . . . . . . . . . . . . 25Editing target attributes using TargetExpert. . 26Moving nodes within a project . . . . . . . . . 26Copying nodes in a project . . . . . . . . . . . . 26Importing projects from older versions of

Turbo C++ . . . . . . . . . . . . . . . . . . . . 27Importing projects from Borland C++ . . . . . 27Customizing the Project window . . . . . . . . 28

Grouping sets of files with Source Pools . . . . 29Creating a Source Pool . . . . . . . . . . . . . . 29

Translators, viewers, and tools . . . . . . . . . . 30Adding translators, viewers, and tools to the

IDE . . . . . . . . . . . . . . . . . . . . . . . . . 31

Chapter 3Specifying project options and

compiling 35Setting project options . . . . . . . . . . . . . . . 35

Using Style Sheets . . . . . . . . . . . . . . . . . 35Predefined Style Sheets . . . . . . . . . . . . . 36The default project options . . . . . . . . . . . 36Managing Style Sheets. . . . . . . . . . . . . . 37Attaching Style Sheets to a node . . . . . . . . 38

Sharing Style Sheets between projects . . . . . 38Setting local overrides. . . . . . . . . . . . . . . 39

Viewing project options . . . . . . . . . . . . . . 40Compiling projects . . . . . . . . . . . . . . . . . 41

Compiling part of a project. . . . . . . . . . . . 42Fixing compile-time errors. . . . . . . . . . . . . 42

Viewing errors . . . . . . . . . . . . . . . . . . . 43Fixing errors. . . . . . . . . . . . . . . . . . . . 43

Project options reference . . . . . . . . . . . . . . 43Directories. . . . . . . . . . . . . . . . . . . . . . 43

File-search algorithms . . . . . . . . . . . . . . 44Compiler . . . . . . . . . . . . . . . . . . . . . . 44

Defines . . . . . . . . . . . . . . . . . . . . . . . 45Code generation . . . . . . . . . . . . . . . . . 45Floating Point . . . . . . . . . . . . . . . . . . . 46Compiler Output . . . . . . . . . . . . . . . . . 46Source . . . . . . . . . . . . . . . . . . . . . . . 46Debugging. . . . . . . . . . . . . . . . . . . . . 47Precompiled headers. . . . . . . . . . . . . . . 48

Advanced Compiler. . . . . . . . . . . . . . . . 48Processor. . . . . . . . . . . . . . . . . . . . . . 48Calling Convention. . . . . . . . . . . . . . . . 48Memory Model . . . . . . . . . . . . . . . . . . 49Segment Names Data . . . . . . . . . . . . . . 50Segment Names Far Data . . . . . . . . . . . . 50Segment Names Code . . . . . . . . . . . . . . 51

Contents

Page 295: UG

ii

Entry/Exit Code . . . . . . . . . . . . . . . . . 51C++ Options. . . . . . . . . . . . . . . . . . . . . 52

Member Pointer . . . . . . . . . . . . . . . . . 52C++ Compatibility . . . . . . . . . . . . . . . . 53Virtual Tables . . . . . . . . . . . . . . . . . . . 53Templates . . . . . . . . . . . . . . . . . . . . . 53Exception handling/RTTI . . . . . . . . . . . 54

Messages . . . . . . . . . . . . . . . . . . . . . . . 54Linker. . . . . . . . . . . . . . . . . . . . . . . . . 55

General . . . . . . . . . . . . . . . . . . . . . . 55Map File . . . . . . . . . . . . . . . . . . . . . . 56Advanced Linker. . . . . . . . . . . . . . . . . 57

Other Project Options dialog box options. . . . 58Option defaults . . . . . . . . . . . . . . . . . . . 58

Chapter 4Building applications with AppExpert 61AppExpert basics . . . . . . . . . . . . . . . . . . 62Creating a small application . . . . . . . . . . . 62

Overview of the generated code . . . . . . . . . 64The application object . . . . . . . . . . . . . . 64The client window . . . . . . . . . . . . . . . . 67

AppExpert options reference . . . . . . . . . . . 68Application . . . . . . . . . . . . . . . . . . . . . 68

Basic Options . . . . . . . . . . . . . . . . . . . 68OLE 2 Options . . . . . . . . . . . . . . . . . . 69Code Gen Control . . . . . . . . . . . . . . . . 70Admin Options. . . . . . . . . . . . . . . . . . 70

Main Window. . . . . . . . . . . . . . . . . . . . 71Basic Options . . . . . . . . . . . . . . . . . . . 71SDI Client . . . . . . . . . . . . . . . . . . . . . 72MDI Client . . . . . . . . . . . . . . . . . . . . 72Dialog Client . . . . . . . . . . . . . . . . . . . 73

MDI Child/View . . . . . . . . . . . . . . . . . . 73Basic Options . . . . . . . . . . . . . . . . . . . 74

Chapter 5Modifying applications with

ClassExpert 75Starting ClassExpert . . . . . . . . . . . . . . . . 75

ClassExpert basics . . . . . . . . . . . . . . . . . 76Classes pane . . . . . . . . . . . . . . . . . . . 76Events pane . . . . . . . . . . . . . . . . . . . . 76Edit pane . . . . . . . . . . . . . . . . . . . . . 76

Adding a class. . . . . . . . . . . . . . . . . . . . 76Creating document types . . . . . . . . . . . . . 78Adding and deleting event handlers . . . . . . 79Adding and deleting instance variables. . . . . 80Jumping to class source code . . . . . . . . . . . 81

Using Resource Workshop with ClassExpert . 81Running Resource Workshop from the IDE . . 81

Using Rescan . . . . . . . . . . . . . . . . . . . . 82

Deleting a class . . . . . . . . . . . . . . . . . . . 82Moving a class . . . . . . . . . . . . . . . . . . . 82Renaming an element . . . . . . . . . . . . . . . 83Importing a class . . . . . . . . . . . . . . . . . . 83Rebuilding the .APX database file. . . . . . . . 83

Chapter 6Browsing classes and objects 85Generating browser information . . . . . . . . . 85Browsing objects (class overview) . . . . . . . . 86

Browsing global and local symbols . . . . . . . 86Configuring the browser display . . . . . . . . . 87Using regular expressions with global

symbols . . . . . . . . . . . . . . . . . . . . . . . 88Customizing the browser . . . . . . . . . . . . . 88

Chapter 7Using the integrated debugger 89Types of bugs . . . . . . . . . . . . . . . . . . . . 89

Run-time errors . . . . . . . . . . . . . . . . . . 89Logic errors . . . . . . . . . . . . . . . . . . . . . 90

Planning a debugging strategy . . . . . . . . . . 90Starting a debugging session . . . . . . . . . . . 90

Compiling with debug information. . . . . . . 91Running your program in the IDE . . . . . . . 91

Specifying program arguments . . . . . . . . 92Controlling program execution . . . . . . . . . . 92

Running to the cursor location. . . . . . . . . . 92The execution point . . . . . . . . . . . . . . . . 93

Finding the execution point. . . . . . . . . . . 93Stepping through code . . . . . . . . . . . . . . 93

Trace Into . . . . . . . . . . . . . . . . . . . . . 93Step Over . . . . . . . . . . . . . . . . . . . . . 94Debugging member functions and external

code. . . . . . . . . . . . . . . . . . . . . . . . 95Running to a breakpoint . . . . . . . . . . . . . 95Pausing the program . . . . . . . . . . . . . . . 95Terminating the program. . . . . . . . . . . . . 95

Using breakpoints. . . . . . . . . . . . . . . . . . 96Setting breakpoints . . . . . . . . . . . . . . . . 96

Setting breakpoints after starting a program . 96Invalid breakpoints. . . . . . . . . . . . . . . . 97

Working with breakpoints . . . . . . . . . . . . 97Viewing and editing code at a breakpoint . . 97Disabling and enabling breakpoints . . . . . . 97Deleting breakpoints. . . . . . . . . . . . . . . 98

Modifying breakpoint properties. . . . . . . . . 98Creating conditional breakpoints . . . . . . . . 99

Setting Boolean conditions . . . . . . . . . . . 99Using pass counts . . . . . . . . . . . . . . . . 99

Logging expressions. . . . . . . . . . . . . . . .100

Page 296: UG

iii

Customizing the breakpoint and execution point colors . . . . . . . . . . . . . . . . . . . 100

Examining program data values . . . . . . . . 100Watching expressions . . . . . . . . . . . . . . 101

Formatting watch expressions . . . . . . . . . 102Disabling a watch . . . . . . . . . . . . . . . . 102Deleting a watch . . . . . . . . . . . . . . . . . 103

Evaluating and modifying expressions . . . . 103Evaluating expressions . . . . . . . . . . . . . 103Modifying the values of variables . . . . . . . 104

Inspecting data elements . . . . . . . . . . . . 105Examining register values. . . . . . . . . . . . 106

Viewing function calls . . . . . . . . . . . . . . 107Navigating to function calls. . . . . . . . . . . 107

Locating functions . . . . . . . . . . . . . . . . 108Catching general protection faults . . . . . . . 108Sending messages to the Event Log window 108Debugging dynamic-link libraries . . . . . . . 109Debugging in soft and hard mode . . . . . . . 109

Chapter 8WinSight and WinSpector 111WinSight . . . . . . . . . . . . . . . . . . . . . . 111

Starting and stopping screen updates . . . . . 112Turning off message tracing . . . . . . . . . . 112

Choosing a view . . . . . . . . . . . . . . . . . 112Class List view. . . . . . . . . . . . . . . . . . . 113

Using the Class List view . . . . . . . . . . . . 113Spying on classes . . . . . . . . . . . . . . . . . 113

Window Tree view . . . . . . . . . . . . . . . . 114Finding a window . . . . . . . . . . . . . . . . 114

Leaving Find Window mode. . . . . . . . . . 115Spying on windows . . . . . . . . . . . . . . . 115

Choosing messages to trace . . . . . . . . . . . 115Using the Message Trace view . . . . . . . . . 115

Other tracing options . . . . . . . . . . . . . . 116WinSpector. . . . . . . . . . . . . . . . . . . . . 120

Configuring WINSPCTR.LOG . . . . . . . . . 121WINSPCTR.LOG reference . . . . . . . . . . . 122

Disassembly section . . . . . . . . . . . . . . . 123Stack Trace section . . . . . . . . . . . . . . . . 124Register section . . . . . . . . . . . . . . . . . . 124Message Queue section . . . . . . . . . . . . . 124Tasks section . . . . . . . . . . . . . . . . . . . 125Modules section . . . . . . . . . . . . . . . . . 125USER and GDI heap section . . . . . . . . . . 126System Information section. . . . . . . . . . . 126

Processing WinSpector data. . . . . . . . . . . 126DFA output . . . . . . . . . . . . . . . . . . . . 127Using DFA with WINSPCTR.LOG . . . . . . 127Using DFA with WINSPCTR.BIN . . . . . . . 127

Other WinSpector tools . . . . . . . . . . . . . 128Using EXEMAP.EXE . . . . . . . . . . . . . . .128Using TMAPSYM.EXE . . . . . . . . . . . . . .128Using BUILDSYM.EXE . . . . . . . . . . . . . .129

Part IIUsing Resource Workshop 131

Chapter 9An overview of working

with resources 133What is a resource? . . . . . . . . . . . . . . . . 134Why you should link resources to your

applications. . . . . . . . . . . . . . . . . . . . 135Starting Resource Workshop . . . . . . . . . . 135Working with resource script files . . . . . . . 135

Creating a resource script file . . . . . . . . . .136Editing an existing resource script file . . . . .136

Adding resource scripts . . . . . . . . . . . . .137Adding a new resource script indirectly . .137Adding one or more existing resource

scripts indirectly . . . . . . . . . . . . . . .137Adding a new resource script directly . . .138Adding an existing resource script

directly . . . . . . . . . . . . . . . . . . . .138Editing a resource script . . . . . . . . . . . . .138

Specifying memory options . . . . . . . . .139Specifying a language version. . . . . . . .139

Removing a resource script . . . . . . . . . . .140Adding an identifier . . . . . . . . . . . . . . .140Editing an identifier . . . . . . . . . . . . . . .141Removing an identifier . . . . . . . . . . . . .141

Generating binary resources from a resource script file. . . . . . . . . . . . . . . . . . . . . .142

Working with binary files . . . . . . . . . . . . 142Creating a .RES file . . . . . . . . . . . . . . . .142Editing resources in a binary file . . . . . . . .142

Working with graphic files . . . . . . . . . . . 143Creating a graphic file. . . . . . . . . . . . . . .143Editing a graphic file . . . . . . . . . . . . . . .144

Customizing Resource Workshop . . . . . . . 144Specifying which information appears in the

Project window. . . . . . . . . . . . . . . . . .144Setting general environment options . . . . . .144

Chapter 10Working with dialog boxes 147Editing a dialog box resource script . . . . . . 147

Setting dialog box properties. . . . . . . . . . .149Class property. . . . . . . . . . . . . . . . . . .149Menu property . . . . . . . . . . . . . . . . . .149

Page 297: UG

iv

Type property . . . . . . . . . . . . . . . . . . 149Style properties . . . . . . . . . . . . . . . . . . 150Frame Style property . . . . . . . . . . . . . . 150Font properties . . . . . . . . . . . . . . . . . . 150Extended Style property . . . . . . . . . . . . 151Common properties . . . . . . . . . . . . . . . 151

Moving and resizing a dialog box . . . . . . . 151Adding a standard control to a dialog box . . 151

The advantages of using Borland controls . . 153Working with custom controls . . . . . . . . . 153

Installing a control library (.DLL or .VBX) . . 153Adding a custom control to a dialog box . . . 154Creating custom controls . . . . . . . . . . . . 154

Selecting controls . . . . . . . . . . . . . . . . . 154Moving controls. . . . . . . . . . . . . . . . . . 155Resizing controls . . . . . . . . . . . . . . . . . 155Fine-tuning the size of controls . . . . . . . . . 156Moving and resizing controls at the same

time . . . . . . . . . . . . . . . . . . . . . . . . 156Grouping and ungrouping controls . . . . . . 157Setting the tab order of controls . . . . . . . . 157Aligning controls . . . . . . . . . . . . . . . . . 157

Aligning controls with the Align|Align command . . . . . . . . . . . . . . . . . . . . 158

Aligning controls with the Alignment palette . . . . . . . . . . . . . . . . . . . . . . 158

Aligning controls with the grid . . . . . . . . 159Aligning controls in columns and rows . . . 159

Undoing actions . . . . . . . . . . . . . . . . . 160Setting the Windows class of a control . . . . 160Setting common properties using the

Properties window . . . . . . . . . . . . . . . 160Setting common properties using the Style

window . . . . . . . . . . . . . . . . . . . . . 161Setting the unique properties of a control. . . 161

Push button properties . . . . . . . . . . . . . 162Type property . . . . . . . . . . . . . . . . 162Control ID property . . . . . . . . . . . . . 162

Radio button properties. . . . . . . . . . . . . 163Check box properties . . . . . . . . . . . . . . 163Static text properties . . . . . . . . . . . . . . . 163Group box properties . . . . . . . . . . . . . . 164Scroll bar properties . . . . . . . . . . . . . . . 164Edit box properties. . . . . . . . . . . . . . . . 164

Case property. . . . . . . . . . . . . . . . . 164Windows 3.1 Style property . . . . . . . . 164Line property . . . . . . . . . . . . . . . . . 165Miscellaneous Boolean properties . . . . . 165

List box properties . . . . . . . . . . . . . . . . 165Combo box properties. . . . . . . . . . . . . . 166

Type property . . . . . . . . . . . . . . . . 166Miscellaneous Boolean properties . . . . . 166

Icon properties . . . . . . . . . . . . . . . . . . 167Frame properties . . . . . . . . . . . . . . . . . 167Rectangle properties . . . . . . . . . . . . . . . 167

Line properties . . . . . . . . . . . . . . . . . .167Testing a dialog box resource . . . . . . . . . . 168

Testing two dialog boxes at the same time. . .168Returning to Edit mode. . . . . . . . . . . . . .168

Customizing the Dialog editor . . . . . . . . . 169Using a dialog box resource in an application 170

Programming a dialog box with OWL . . . . .170Programming a dialog box with the

Windows API. . . . . . . . . . . . . . . . . . .170

Chapter 11Working with menus and

accelerator tables 171Editing a menu resource script . . . . . . . . . 171

Adding a menu or separator to the menu bar .172Adding a predefined menu . . . . . . . . . . .172Adding a custom menu . . . . . . . . . . . . .173Adding a separator. . . . . . . . . . . . . . . .173

Adding a menu item or separator to a menu .173Setting the initial state of a menu or menu

item. . . . . . . . . . . . . . . . . . . . . . . . .174Changing the identifier for a menu item . . . .175Associating Help text with a menu item . . . .175Assigning an accelerator to a menu item. . . .175Copying, moving, or removing a menu,

menu item, or separator. . . . . . . . . . . . .176Checking for duplicate identifiers. . . . . . . .177

Creating a resource script for a floating menu 177Customizing the Menu editor. . . . . . . . . . 178Editing an accelerator table resource script . . 178

Adding an accelerator resource . . . . . . . . .179Changing the identifier for an accelerator

resource . . . . . . . . . . . . . . . . . . . . . .179Changing the keyboard combination for an

accelerator resource . . . . . . . . . . . . . . .180Copying, moving, or removing an

accelerator resource . . . . . . . . . . . . . . .180Checking for duplicate keyboard

combinations . . . . . . . . . . . . . . . . . . .181Customizing the Accelerator editor . . . . . . 181Using menu and accelerator resources in an

application . . . . . . . . . . . . . . . . . . . . 181Programming menus and accelerators with

OWL . . . . . . . . . . . . . . . . . . . . . . . .181Programming menus and accelerators with

the Windows API . . . . . . . . . . . . . . . .181

Chapter 12Working with string tables 183Editing a string table resource script . . . . . . 183

Adding a string resource . . . . . . . . . . . . .183Changing the characters of a string resource .184

Page 298: UG

v

Changing the identifier for a string resource . 184Grouping string resources to maximize

memory efficiency . . . . . . . . . . . . . . . 184Copying, moving, or removing a string

resource . . . . . . . . . . . . . . . . . . . . . 185Customizing the String editor . . . . . . . . . 185Using a string resource in an application . . . 185

Chapter 13Working with graphics 187Editing a resource script for a graphic. . . . . 187

Choosing colors . . . . . . . . . . . . . . . . . . 189Choosing a color that represents a

transparent or inverted area . . . . . . . . . 189Choosing a pen style . . . . . . . . . . . . . . . 189Choosing a brush shape . . . . . . . . . . . . . 190Choosing a paint pattern . . . . . . . . . . . . 190Drawing and painting . . . . . . . . . . . . . . 190Drawing a line. . . . . . . . . . . . . . . . . . . 191Drawing a shape . . . . . . . . . . . . . . . . . 191Filling an area with color . . . . . . . . . . . . 191Adding text . . . . . . . . . . . . . . . . . . . . 192Erasing an area . . . . . . . . . . . . . . . . . . 192Selecting an area . . . . . . . . . . . . . . . . . 192Aligning an area . . . . . . . . . . . . . . . . . 193Moving or resizing an area . . . . . . . . . . . 193Copying or removing an area. . . . . . . . . . 193Zooming in on or out from a graphic . . . . . 194Moving a graphic around in the Drawing

Area. . . . . . . . . . . . . . . . . . . . . . . . 194Viewing an icon or cursor in another

resolution . . . . . . . . . . . . . . . . . . . . 194Testing an icon or cursor . . . . . . . . . . . . 195Adding or removing an image from an icon

or cursor . . . . . . . . . . . . . . . . . . . . . 195Changing the properties of a bitmap . . . . . 196Changing the properties of a cursor . . . . . . 196Changing the properties of an icon . . . . . . 197Changing the properties of a font . . . . . . . 197

Changing the general properties of a font . . 197Changing the height and width of the

characters in a font . . . . . . . . . . . . . . . 198Changing the ANSI codes of the characters

in a font . . . . . . . . . . . . . . . . . . . . . 198Changing the number of characters in a

font . . . . . . . . . . . . . . . . . . . . . . . . 199Editing a specific character in a font . . . . . . 199

Customizing the Graphic editor . . . . . . . . 199Adding or removing a second pane from the

Edit window. . . . . . . . . . . . . . . . . . . 199Hiding or showing the Tools and Colors

palettes . . . . . . . . . . . . . . . . . . . . . . 200

Changing a color on the Colors palette . . . . .200Specifying whether the Colors palette is

saved. . . . . . . . . . . . . . . . . . . . . . . .201Specifying whether a grid appears when

you zoom in. . . . . . . . . . . . . . . . . . . .201Using a graphic resource in an application . . 201

Programming a bitmap with OWL . . . . . . .201Programming an icon with OWL . . . . . . . .202Programming a cursor with OWL . . . . . . .202Programming a bitmap with the Windows

API . . . . . . . . . . . . . . . . . . . . . . . . .202Programming an icon with the Windows

API . . . . . . . . . . . . . . . . . . . . . . . . .203Programming a cursor with the Windows

API . . . . . . . . . . . . . . . . . . . . . . . . .203

Chapter 14Working with version information

and custom data types 205Creating a custom data type. . . . . . . . . . . 205Editing a resource script for version

information or a custom data type . . . . . . 206Editing a resource script for version

information . . . . . . . . . . . . . . . . . . . .206The versionID parameter . . . . . . . . . . . .206The fixed-info parameter . . . . . . . . . . . .206The block-statements parameter . . . . . . . .207

A string information block. . . . . . . . . .207A variable information block . . . . . . . .207

Constants . . . . . . . . . . . . . . . . . . . . .208fileflags . . . . . . . . . . . . . . . . . . . . .208fileos. . . . . . . . . . . . . . . . . . . . . . .208filetype . . . . . . . . . . . . . . . . . . . . .208subtype . . . . . . . . . . . . . . . . . . . . .209langID. . . . . . . . . . . . . . . . . . . . . .209charsetID . . . . . . . . . . . . . . . . . . . .210string-name . . . . . . . . . . . . . . . . . .211

Editing a resource script for a custom data type. . . . . . . . . . . . . . . . . . . . . . . . .211

The resource-name parameter . . . . . . . . .211The type-ID parameter . . . . . . . . . . . . .211The load-type parameter . . . . . . . . . . . .211The filename parameter . . . . . . . . . . . . .212The block-statements parameter . . . . . . . .212

Entering data in a resource script . . . . . . . .212Compiling a resource script . . . . . . . . . . . 212Using a version information resource in an

application . . . . . . . . . . . . . . . . . . . . 213Using a resource for a custom data type in

an application. . . . . . . . . . . . . . . . . . .213

Page 299: UG

vi

Appendix AUsing EasyWin 215_InitEasyWin( ) . . . . . . . . . . . . . . . . . . 215

Added functions . . . . . . . . . . . . . . . . . 216

Appendix BPrecompiled headers 217How they work . . . . . . . . . . . . . . . . . . 217

Drawbacks. . . . . . . . . . . . . . . . . . . . . 218Using precompiled headers. . . . . . . . . . . 218

Setting file names . . . . . . . . . . . . . . . . . 218Establishing identity . . . . . . . . . . . . . . . 218Optimizing precompiled headers . . . . . . . 219

Appendix CError messages 221Message classes . . . . . . . . . . . . . . . . . . 221

Fatal errors . . . . . . . . . . . . . . . . . . . . .221Errors . . . . . . . . . . . . . . . . . . . . . . . .222Warnings . . . . . . . . . . . . . . . . . . . . . .222

Help compiler messages . . . . . . . . . . . . . 222Message listings . . . . . . . . . . . . . . . . . . 223Message explanations . . . . . . . . . . . . . . 223

Index 273

Page 300: UG

xii

1.1 The IDE menus . . . . . . . . . . . . . . . . . . . 83.1 Default Project Option settings . . . . . . . . . 584.1 Sample application files . . . . . . . . . . . . . 646.1 Filter letters in the browser . . . . . . . . . . . 876.2 Browser search expressions . . . . . . . . . . . 887.1 Expression format specifiers . . . . . . . . . 1047.2 CPU flags in the Register window. . . . . . 1068.1 Mouse messages . . . . . . . . . . . . . . . . .1178.2 Window messages . . . . . . . . . . . . . . . .1178.3 Input messages . . . . . . . . . . . . . . . . . .1178.4 System messages . . . . . . . . . . . . . . . . .1178.5 Pen messages . . . . . . . . . . . . . . . . . . .1188.6 Initialization messages . . . . . . . . . . . . . .1188.7 Clipboard messages . . . . . . . . . . . . . . .1188.8 DDE messages. . . . . . . . . . . . . . . . . . .1188.9 Nonclient messages . . . . . . . . . . . . . . .1188.10 Control messages . . . . . . . . . . . . . . . . .1188.11 Multimedia messages . . . . . . . . . . . . . 1208.12 Other messages and messages not

documented by Microsoft . . . . . . . . . . . 1208.13 Exception types . . . . . . . . . . . . . . . . . 1228.14 DFA options . . . . . . . . . . . . . . . . . . . 128

Tables1.1 The Turbo C++ IDE . . . . . . . . . . . . . . . . 81.2 The New Target dialog box . . . . . . . . . . .111.3 The Environment Options dialog box . . . . .142.1 The Project window displaying a

Project Tree . . . . . . . . . . . . . . . . . . . . .202.2 TargetExpert dialog box . . . . . . . . . . . . .222.3 The Environment Options dialog box . . . . .282.4 The Tools dialog box . . . . . . . . . . . . . . .312.5 The Tool Advanced Options dialog box. . . .333.1 The Project Options dialog box . . . . . . . . .363.2 Style Sheets dialog box . . . . . . . . . . . . . .373.3 The Options Hierarchy dialog box . . . . . . .404.1 AppExpert Application Generation

Options dialog box . . . . . . . . . . . . . . . .634.2 DRAW.IDE loaded into the Project

Manager. . . . . . . . . . . . . . . . . . . . . . .655.1 ClassExpert . . . . . . . . . . . . . . . . . . . . .755.2 Add New Class dialog box. . . . . . . . . . . .776.1 Viewing classes in an application . . . . . . . .866.2 Symbol declaration window. . . . . . . . . . .877.1 The Breakpoints window. . . . . . . . . . . . .977.2 The Breakpoint Properties dialog box . . . . .987.3 The Watch window . . . . . . . . . . . . . . . 1017.4 The Watch Properties dialog box . . . . . . . 1027.5 The Expression Evaluator dialog box . . . . 1037.6 Inspect windows. . . . . . . . . . . . . . . . . 1067.7 Call Stack window. . . . . . . . . . . . . . . . 107

Figures