Home > Articles > Programming > Windows Programming

📄 Contents

  1. Delphi for .NET—a Bigger Picture
  2. Introduction to the Integrated Development Environment (IDE)
This chapter is from the book

This chapter is from the book

Introduction to the Integrated Development Environment (IDE)

Much like previous versions of Delphi, its IDE is a powerful environment through which you design and develop applications. It includes the various tools needed to enable you to do this; plus it is extensible, enabling third-party vendors to enhance the IDE capabilities. This chapter goes over the key components of the IDE.

NOTE

This will be the only chapter in which I discuss how to use the IDE. In fact, in much of the code in this book, I make property assignments programmatically rather than setting them within the IDE. I do this so that it is clear what assignments have been made to the various properties. Normally, you would make such assignments using the IDE's Object Inspector. For further tips on IDE usability, you can visit http://www.delphiguru.com, where I will periodically post tutorials on using Delphi for .NET.

The main components to the Delphi IDE are

  • Welcome Page

  • Main Form

  • Designer Surface

  • Forms

  • Tool Palette/Code Snippets

  • Object Inspector

  • Code Editor

  • Project Manager

  • Data Explorer

  • Code Explorer

  • To-Do List

  • Object Repository

This chapter discusses each of these components and then gets you started with your first, simple Delphi for .NET application.

Welcome Page

The Welcome page is the first thing you see when the Delphi IDE is started (see Figure 3.1). This page serves as more of a quick launch center from which you can create new projects, open recent projects, and access various resources on Delphi for .NET.

TIP

If for some reason you lose the Welcome page, you can redisplay it by clicking View, Welcome Page.

Figure 3.1Figure 3.1 Welcome page.

Note that the Welcome page has an embedded Web browser. Therefore, you can type a valid URL into the URL combo to launch the Web site that you entered.

TIP

You can modify the default.htm file in the Welcome Page directory to customize your Welcome page—including your own links—change the shown picture, and so on.

Designer

The Designer is the area of the IDE that you see when you create either a new Windows Form, Web Form, or VCL Form application shown in the center pane and you have clicked the Design tab at the bottom of that pane (see Figure 3.2). The designer is the area where you perform your visual design within the IDE. You can drag and drop components from the Tool Palette onto your forms to visually design your applications. When working with VCL Forms, the designer looks and behaves differently. For instance, you'll notice that the right-click menu is different.

Some components are visual, whereas others are not. When you place visual components on a form, such as a TextBox, it is placed exactly where you positioned it on the form (Figure 3.2). Nonvisual components, such as the SqlDataAdapter and SqlConnection, are positioned on the Component Tray, which is the bottom portion of the Designer (see Figure 3.2). Such components are only visible at design time so that you can select them to modify their properties. Within the Designer's status bar, you'll see information about the status of the file on which you are working such as whether it has been modified. You'll also see your cursor position and whether the editor is in insert or overwrite mode. You'll also see the Macro recording buttons on the status bar, which is discussed momentarily.

Figure 3.2Figure 3.2 Designer.

When working within the design, you will want to make sure to take advantage of some of the features the IDE contains to enhance your productivity. Here are just a few:

  • Locking Control—When you have positioned controls on the form the way you want them, it's often a good idea to lock them in place so that you don't accidentally move them as you select them with the mouse. To do this, simply right-click to invoke the local menu and select the Lock Controls option. This locking is per form. Also, the VCL designer only has a global Edit, Lock Controls for all forms.

  • Tab Order—Something often forgotten is to set the tab order of controls. You can examine the tab order of controls on your form by right-clicking to invoke the local menu and selecting Tab Order. You can adjust the tab order of each control by clicking with your mouse anywhere on the control containing the tab order number.

  • Be sure to take advantage of the Align, Position and Spacing toolbars to arrange controls on your form. These toolbars become enabled when you have multi-selected controls on the form.

  • Docking—The IDE allows you to reposition/doc the various windows almost wherever you want. This great feature enables you to adjust your work space as you like.

  • Layouts—There are three predefined desktop layouts: Default, Classic (for those of you who prefer the classic Delphi undocked layout), and Debug. The Default layout is shown in Figure 3.2. Figure 3.3 depicts the Debug layout, which shows various debugging windows (Call Stack, Watch List, and Local Variables). The IDE switches to the Debug layout whenever you start debugging an application. You can change and save your own custom layouts as well.

  • Customizing the File Menu—You can now customize the File, New menu to add items that you frequently need to create. For instance, if you frequently need to create Web Forms, you can add a WebForm to the File, New menu directly so that you don't have to launch the Object Repository from which you would normally select this form.

Figure 3.3Figure 3.3 IDE Debug layout.

Forms

Forms are the main GUI entities that you create. They can be a window or dialog with which the user interacts or a Web page. In Delphi for .NET, you can work with three types of forms: Windows Forms, Web Forms, and VCL Forms.

Windows Forms enable you to use the classes within the .NET Framework to create functionally rich, Managed GUI applications. You create a Windows Forms application by selecting File, New, Windows Forms Application from the main menu. The IDE will then present you with a Windows Form surface on which you place the various user-interface controls from the tool palette to design the main form of the application. Typically, your applications will consist of numerous Windows Forms. This book uses many examples built upon Windows Forms.

Web Forms are the building blocks of ASP.NET Web applications. To create Web Forms, select File, New, ASP.NET Web Application from the main menu. The IDE will then present you with the Web Form designer, which is your workspace for your Web site pages. Part V, "Internet Development with ASP.NET," covers developing ASP.NET applications in detail.

VCL Forms are similar to Windows Forms in that they give you the tools and classes required to build managed GUI applications. However, VCL Forms make use of Borland's own set of native .NET classes. VCL Forms, being built on Borland's VCL framework, also enable you to easily port existing Win32 applications to managed .NET applications. Through VCL.NET, you will be able to create applications that target both the managed .NET runtime and native Win32. To create a VCL Forms application, select File, New, VCL Forms Application from the main menu. The IDE will present you with a form design surface onto which you can place components from the Tool Palette to build functionally interactive applications.

NOTE

The Mono project is an effort well under way to create an open source .NET runtime for the Linux Operating System. The goal of Mono is to be capable of running any managed assembly, and this includes Delphi assemblies. Theoretically, because of the Wine project used to emulate Win32 on Linux, there is hope to run VCL for .NET apps as is on Linux/Mono/Wine. As of now, this is not realized. You can find out about the Mono project at http://www.go-mono.com/.

Tool Palette/Code Snippets

By default, the Tool Palette is located at the lower-right pane (refer to Figure 3.2). Its contents depend on which view you happen to be working in. If you are working with the Designer display, the Tool Palette contains the various components that you can add to your form either by dragging and dropping them onto the form or by double-clicking them. The list of available components depends on what kind of file you are editing (Win Form, Web Form, VCL Form, or HTML file, for instance). If you are working in the Code Editor, the Tool Palette contains a list of code snippets.

Code snippets are small blocks of reusable code. You can add your own code snippets to the Tool Palette. Additionally, you can categorize the arrangement of your code snippets. To add a category, simply right-click within the Tool Palette and select Add New Category. Enter a category name and click OK. To add code from the code editor to your list of code snippets, highlight your code, press the Alt key, and drag onto the Tool Palette. To add code snippets to a new category, you must first add them to the default Code Snippets category. Once added there, they can be dragged to a custom category. The order is

  1. Drag the code to the default Code Snippets category.

  2. Right-click to Add New Category.

  3. Alt+Drag the new snippet from Code Snippets to your new category.

Also, an empty category will be removed when the Tool Palette loses focus.

Object Inspector

Through the Object Inspector (refer to Figure 3.2), you modify the properties of components and attach event handlers to these components. This allows you to specify at design-time various attributes that affect the visual appearance and behavior of components. For example, after placing a Label component on a Windows Form, you can change its Text property to something more specific and its font color to red. This is done in the Properties Page of the Object Inspector. The Events page is where you attach code to various events of each component. For example, a Button component has a Click event that fires when the user clicks the button. By double-clicking in the edit portion of the Object Inspector for that event, the IDE automatically creates the event handler for you and places your cursor in that event handler within the Code Editor.

Various attributes of the Object Inspector, such as color and look and feel, are configurable. Simply right-click over the Object Inspector to invoke the local menu and select the Properties menu. This will launch the Object Inspector Properties dialog box shown in Figure 3.4.

Figure 3.4Figure 3.4 Object Inspector Properties dialog box.

Code Editor

If you have the opportunity to ever attend a Borland demonstration of one of its products, you'll always hear the claim about being able do great things with the products "without writing a single line of code." Well, the truth is, you really can't do anything useful without writing many lines of code. Fortunately, Borland delivers world class Code Editors with its development tools. The Delphi for .NET Code Editor does not fall short of this trend. Here are some handy features of the Code Editor:

  • Code Folding—Hands down, this is one of the coolest features of the IDE. Within the Code Editor, you'll notice minus (-) and plus (+) signs to the right of code blocks. By clicking a minus sign, you'll collapse the block of code. By clicking a plus sign, you'll expand the block of code. Figure 3.5 shows both a collapsed and expanded block of code. Code folding is enabled automatically for functions, nested functions, structured types, and unit blocks.

  • TIP

    The IDE provides some keyboard shortcuts for people tired of using the mouse (using the default keyboard mapping). These are

    • Ctrl+Shift+K+U—Expands nearest block.

    • Ctrl+Shift+K+E—Collapses nearest block.

    • Ctrl+Shift+K+A—Expands all blocks in this file.

    • Ctrl+Shift K+T—Toggles nearest block.

    TIP

    Ctrl+Shift+K+O—Turns off/on code folding. (After turning it on, you must change to another file and back to see it.)

    Figure 3.5Figure 3.5 Code folding.

  • Regions—You can use the $REGION/$ENDREGION directives to specify your own code folding blocks. The syntax for using these directives is

  • {$REGION 'Region Title'}
    code
    {$ENDREGION}

    Figure 3.6 shows how this looks in the IDE.

  • Class Completion—This is a great productivity tool that allows you to define a class, and then through a shortcut key, the Code Editor will automatically create implementation methods for you. For instance, suppose that you define the class shown here:

  •  TMyClass = class (System.Object)
     private
      procedure Foo;
     public
      property MyInt: Integer;
      property MyString: String;
     end;

    Figure 3.6Figure 3.6 Regions.

    After pressing the Shift+Ctrl+C key combination, the Code Editor creates the following class declaration:

     TMyClass = class (System.Object)
     private
      procedure Foo;
     public
      FMyString: &String;
      FMyInt: Integer;
      procedure set_MyInt(const Value: Integer);
      procedure set_MyString(const Value: &String);
     public
      property MyInt: Integer read FMyInt write set_MyInt;
      property MyString: String read FMyString write set_MyString;
     end;

    You'll notice that the property accessor methods have been defined. The implementation of these methods is also created in the implementation section of the unit as shown here:

    {TMyClass}
    procedure TMyClass.Foo;
    begin
    end;
    
    
    procedure TMyClass.set_MyInt(const Value: Integer);
    begin
     FMyInt := Value;
    end;
    
    
    procedure TMyClass.set_MyString(const Value: &String);
    begin
     FMyString := Value;
    end;
  • Code Block Indentation—Another IDE favorite is code block indent/un-indent. Simply highlight a block of code and use the Ctrl+K+I key combination to indent the selected block of code. Use Ctrl+K+U to un-indent a block of code. Alternatively, you can use Ctrl+Shift+I and Ctrl+Shift+U.

  • Code Browsing—If you want to find the declaration of a particular function in code, simply hold down the Ctrl key while left-clicking with the mouse over the function call. Alternatively, you can use the Alt+Up Arrow key combination to accomplish the same. To quickly navigate from the definition of a function to its implementation, use the Shift+Ctrl+Up Arrow/Shift+Ctrl+Down Arrow combination. Also, the IDE maintains a history of browsed code links. Using Alt+Left and Alt+Right, you can move back and forth in the browsing history.

Project Manager

From the Project Manager, you manage the various files that are contained within your Project Groups. It contains three tabs—Project Manager, Model View, and Data Explorer. Figure 3.7 shows the Project Manager undocked.

Figure 3.7Figure 3.7 Project Manager (undocked).

A Project Group is a group of related projects. For instance, you have a project group composed of a project with multiple separate assembly projects. Figure 3.7 shows a Project Group, ProjectGroup1. It contains the projects Project1.exe, Package1.dll, and Console1.exe. The Project Manager tab allows you to manage projects groups by providing menu options to add/remove projects and to compile/build projects contained in the group.

The Project Manager tab also allows you to manage projects by providing menus to add/remove files as well as compilation options.

Model View

The Model View gives you a nested view of the projects units, classes, and other members contained within your projects. Figure 3.8 shows the Model View. Note that the Model Views is accessed within the Project Manager window by selecting its tab on the lower portion of the Project Manager Window.

iFigure 3.8Figure 3.8 Model View window.

Data Explorer

The Data Explorer (see Figure 3.9) is also accessible from within the Project Manager window.

Figure 3.9Figure 3.9 The Data Explorer displays connections.

From the Data Explorer, you can manage various connections to data sources through Database Providers. You can perform various functions such as creating new connections, creating projects from connections, browsing databases, and more. The online Delphi for .NET help provides examples of performing such functions. Developing database applications is covered in greater detail in Part IV, "Database Development with ADO.NET."

Object Repository

The Object Repository is the location from which you can use reusable items within your applications. From the Object Repository, you can select a type of application or elements that you will use within your application, such as Windows Forms, ASP.NET Forms, classes, and so on. To open the Object Repository, simply select File, New, Other, which launches the form shown in Figure 3.10.

Figure 3.10Figure 3.10 Object Repository is used to select reusable items.

This list on the left represents the various categories of items that you can select from. The view on the right displays the items for a selected category. For instance, by selecting the category Delphi for .NET Projects, you will see a list of the various projects you can create in Delphi for .NET, such as Window Forms Application, VCL Forms Application, Package, Library, and so on. When you select an item that creates a new application, the IDE will create the application and application files for you. If you select an element such as a form, the IDE will create that item for you and will add it to your existing application on which you are currently working.

Code Explorer

The Code Explorer can be useful for navigating through large units of source code. The Code Explorer displays the structural layout of a unit including classes, methods, components, and so on. To navigate to a particular item, simply double-click it, and it will position the cursor on the code in which the item appears. The Code Explorer is shown in Figure 3.11.

Figure 3.11Figure 3.11 Use the Code Explorer to navigate through a unit.

To-Do List

The To-Do list is a convenient way to keep track of to-dos. They are listed in a dockable window and are maintained in your source files.

To use To-Dos, simply right-click anywhere in the Code Editor and select Add To-Do Item from the local menu. Doing so will invoke the Add To-Do Item dialog box.

When you press OK after adding the To-Do, the To-Do will be added to the To-Do list that appears at the bottom of the IDE (see Figure 3.12). If the To-Do list is not displayed, select View, To Do List from the main menu.

Figure 3.12Figure 3.12 To-Do list is displayed at the bottom of the IDE.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020