RAD Studio |  |

VCL Procedures
Collapse All

This section provides how-to information on developing VCL for Win32 applications.

Topics

Name | Description
Building a Windows "Hello World" Console Application | This "Hello World" console application demonstrates the essential steps for creating a Windows application in Delphi or C++. The application uses Windows, a console window, an event, and will display a dialog in response to a user action.
Developing a Windows Application | The following procedure illustrates the essential steps for building a Windows application.
Building Application Menus | Menus provide an easy way for your users to execute logically grouped commands. You can add or delete menu items, or drag them to rearrange them during designtime. In addition to TMainMenu and TPopupMenu components, the Tool Palette also contains TActionMainMenuBar, TActionManager, and TActionToolBar.
Building a VCL Forms Application with Decision Support Components | Creating a form with tables and graphs of multidimensional data consists of the following major steps: Create a VCL form. Add a decision query and dataset. Add a decision cube. Add a decision source. Optionally add a decision pivot. Add one or more decision grids and graphs. Set the active property of the decision query (or alternate dataset component) to True.
Building VCL Forms Applications With Graphics | Each of the procedures listed below builds a VCL Form application that uses graphics. Build one or more of the examples and then add other graphics features to these basic VCL Form applications. Draw straight lines. Draw rectangles and ellipses. Draw a polygon. Display a bitmap image. Place a bitmap in a combo box.
Building a VCL Forms MDI Application Using a Wizard | The VCL Forms MDI application wizard automatically creates a project that includes the basic files for an MDI application. In addition to the Main source file, the wizard creates unit files for child and about box windows, along with the supporting forms files and resources.
Building a VCL Forms MDI Application Without Using a Wizard |
Building a VCL Forms SDI Application |
Creating a New VCL Component | You can use the New VCL Component wizard to create a new VCL component for your application. The wizard detects the personality of the product you are using and creates the appropriate type of component.
Building a VCL Forms ADO Database Application | The following procedure describes how to build an ADO database application. Building a VCL ADO application consists of the following major steps: Set up the database connection. Set up the dataset. Set up the data provider, client dataset, and data source. Connect a DataGrid to the connection components. Run the application.
Building a VCL Forms Application | The following procedure illustrates the essential steps to building a VCL Forms application using RAD Studio.
Creating Actions in a VCL Forms Application | Using RAD Studio, the following procedure illustrates how to create actions using the ActionList tool. It sets up a simple application and describes how to create a file menu item with a file open action. Building the VCL application with ActionList actions consists of the following major steps: Create a main window and add tools for creating a main menu and a File open action. Add the File category to the main menu. Add the File open action to the File category. Build and run the application.
Building a VCL Forms "Hello World" Application | This procedure demonstrates how to construct a simple “Hello world” VCL Forms application using either Delphi or C++. Though simple, the Windows Forms "Hello world" application demonstrates the essential steps for creating a VCL Forms application. The application uses a VCL Form, a control, an event, and displays a dialog in response to a user action. Creating the "Hello world" application consists of the following steps: Create a VCL Form with a button control. Write the code to display "Hello world" when the button is clicked. Run the application.
Using ActionManager to Create Actions in a VCL Forms Application | Using RAD Studio, the following procedure illustrates how to create actions using ActionManager. It sets up a simple user interface with a text area, as would be appropriate for a text editing application, and describes how to create a file menu item with a file open action. Building the VCL application with ActionManager actions consists of the following major steps: Create a main window. Add a File open action to the ActionManager. Create the main menu. Add the action to the menu. Build and run the application.
Building a VCL Forms dbExpress Database Application | The following procedure describes how to build a dbExpress database application. Building a VCL Forms dbExpress application consists of the following major steps: Set up the database connection. Set up the unidirectional dataset. Set up the data provider, client dataset, and data source. Connect a DataGrid to the connection components. Run the application.
Building an Application with XML Components | This example creates a VCL Forms application that uses an XMLDocument component to display contents in an XML file.
Copying Data From One Stream To Another | Creating this VCL application consists of the following steps: Create a project directory containing a text file to copy. Create a VCL Form with a button control. Write the code to read the string and write it to a file. Run the application.
Copying a Complete String List (VCL) | Copying a string list can have the effect of appending to or overwriting an existing string list. This VCL application appends to a string list. With a simple change, it can overwrite a string list. Creating this VCL application consists of the following steps: Create a VCL Form with TButtons, TComboBox, and TMemo controls. Write the code to create a string list to the Button1 OnClick handler. Write the code to copy the string list to the Button2 OnClick handler. Run the application.
Creating Strings | Creating this VCL application consists of the following steps: Create a VCL Form with TButton and TComboBox controls. Write the code to create strings to the TButton OnClick handler. Run the application.
Creating a VCL Form Instance Using a Local Variable | A safe way to create a unique instance of a modal VCL form is to use a local variable in an event handler as a reference to a new instance. If you use a local variable, it doesn't matter whether the form is auto-created or not. The code in the event handler makes no reference to the global form variable. Using RAD Studio, the following procedure creates a modal form instance dynamically. It (optionally) removes the second form's invocation at startup. Building this VCL application consists of the following steps: Create the project directory. Create two forms for the project.... more
Deleting Strings | Creating this VCL application consists of the following steps: Create a VCL Form with Buttons and ListBox controls. Write the code to add strings to a list. Write the code to delete a string from the list. Run the application.
Displaying an Auto-Created VCL Form | Using RAD Studio, the following procedure creates a modal form at design time that is displayed later during program execution. Building this VCL application consists of the following steps: Create the project directory. Create two forms for the project. Link the forms. Create a control on the main form to display the modal form; then write the event handler. Build and run the application.
Displaying a Bitmap Image in a VCL Forms Application | This procedure loads a bitmap image from a file and displays it to a VCL form. Create a VCL form with a button control. Provide a bitmap image. Code the button's onClick event handler to load and display a bitmap image. Build and run the application.
Displaying a Full View Bitmap Image in a VCL Forms Application | This procedure loads a bitmap image from a file and displays it in its entirety to a VCL form. The procedure uses the Height and Width properties of the Bitmap object to display a full view of the image. Create a VCL form with a button control. Provide a bitmap image. Code the button's onClick event handler to load and display a bitmap image. Build and run the application.
Drawing a Polygon in a VCL Forms Application | This procedure draws a polygon in a VCL form. Create a VCL form. Code the form's OnPaint event handler to draw a polygon. Build and run the application.
Drawing Rectangles and Ellipses in a VCL Forms Application | This procedure draws a rectangle and ellipse in a VCL form. Create a VCL form. Code the form's OnPaint event handler to draw a rectangle and ellipse. Build and run the application.
Drawing a Rounded Rectangle in a VCL Forms Application | This procedure draws a rounded rectangle in a VCL form. Create a VCL form and code the form's OnPaint event handler. Build and run the application.
Drawing Straight Lines In a VCL Forms Application | This procedure draws two diagonal straight lines on an image in a VCL form. Create a VCL form. Code the form's OnPaint event handler to draw the straight lines. Build and run the application.
Dynamically Creating a VCL Modal Form | You may not want all your VCL application's forms in memory at once. To reduce the amount of memory required at load time, your application can create forms only when it needs to make them available for use. A dialog box, for example, needs to be in memory only during the time the user interacts with it. Using RAD Studio, the following procedure creates a modal form dynamically. The main difference between dynamically creating a form and displaying an auto-created VCL form is that you remove the second form's invocation at startup and write code to dynamically create the form.... more
Dynamically Creating a VCL Modeless Form | A modless form is a window that is displayed until it is either obscured by another window or until it is closed or minimuzed by the user. Using RAD Studio, the following procedure creates a modeless form dynamically. Building this VCL application consists of the following steps: Create the project directory. Create two forms for the project. Remove the second form's invocation at startup. Link the forms. Create a control on the main form to create and display the modal form; then write the event handler. Build and run the application.
Iterating Through Strings in a List | This VCL application first creates a list of strings. Then it iterates through the strings, changing all string characters to uppercase. It consists of the following steps: Create a VCL Form with Buttons and TListBox controls. Write the code to create a string list and add strings to it. Write the code to iterate through the string list to process string characters. Run the application.
Building a Multithreaded Application | These are the essential steps to building a VCL Forms multithreaded application with a thread object using RAD Studio.
Writing Cleanup Code |
Avoiding Simultaneous Thread Access to the Same Memory | Use these basic techniques to prevent other threads from accessing the same memory as your thread: Lock objects. Use critical sections. Use a multi-read exclusive-write synchronizer
Defining the Thread Object |
Handling Exceptions |
Initializing a Thread |
Using the Main VCL Thread | Using the main VCL thread consists of the following basic steps: Create a separate routine to handle Windows messages received by components in your application. Call CheckSynchronize periodically. Declare thread-local variables, as necessary, for exclusive use by your thread.
Waiting for Threads | The following are procedures that can be used to wait for threads. Wait for a thread to finish executing. Wait for a task to complete. Check if another thread is waiting for your thread to terminate.
Writing the Thread Function (Procedure) | The Execute method is your thread function. You can think of it as a program that is launched by your application, except that it shares the same process space. Writing the thread function is a little trickier than writing a separate program, because you must make sure that you do not overwrite memory that is used by other processes in your application. On the other hand, because the thread shares the same process space with other threads, you can use the shared memory to communicate between threads.
Placing A Bitmap Image in a Control in a VCL Forms Application | This procedure adds a bitmap image to a combo box in a VCL forms application. Create a VCL form. Place components on the form. Set component properties in the Object Inspector. Write event handlers for the component's drawing action. Build and run the application.
Reading a String and Writing It To a File | Creating this VCL application consists of the following steps: Create a VCL Form with a button control. Write the code to read the string and write it to a file. Run the application.
Renaming Files | Creating this VCL application consists of the following steps: Create a project directory containing a file to rename. Create a VCL Form with button and label controls. Write the code to rename the file. Run the application.
Adding and Sorting Strings | Creating this VCL application consists of the following steps: Create a VCL Form with Button, Label, and TListBox controls. Write the code to add and sort strings. Run the application.
Creating a VCL Forms ActiveX Button | Like a Delphi control, an ActiveX control generates program code when you place the component on a form or other logical container in the IDE. The main difference between an ActiveX control and a Delphi control is that an ActiveX control is language independent. You can create ActiveX controls for deployment to a variety of programming environments on Windows, not just Delphi or C++Builder. This procedure uses the VCL forms ActiveX wizard to create an ActiveX control. To test the control, you can install it on your machine as a VCL component in the IDE. To install the control, you... more
Creating a VCL Forms ActiveX Active Form | Like a Delphi control, an ActiveX control generates program code when you place the component on a form or other logical container in the IDE. The main difference between an ActiveX control and a Delphi control is that an ActiveX control is language independent. You can create ActiveX controls for deployment to a variety of programming environments on Windows, not just Delphi or C++Builder, for example. This procedure uses the VCL forms ActiveX Active Form wizard to create an Active Form containing two components. To test the control, you can deploy it to the Web. This procedure consists of the... more
Building a VCL Forms Web Browser Application | Creating the Web browser application consists of the following steps: Create a VCL Form with a button control. Add a TWebBrowser component to the form. Add controls to enter a URL and launch the browser. Write the code to launch the browser when a button is clicked. Run the application.
Creating an Application that Uses Ribbon Controls | This procedure describes how to create an application that uses ribbon controls. The core ribbon functionality is derived from the TRibbon component. While the ribbon uses other components, none of the core components are registered on the tool palette. Components: TRibbon: Main visual component that provides most functionality. TRibbonApplicationMenuBar: Component that provides the functionality of the application menu. TRibbonQuickAccessToolbar: Component that provides the functionality of the Quick Access Toolbar TRibbonPage: Component that represents the page of the ribbon that is currently visible TRibbonGroup: Component that all of the pages commands are displayed in. Commands must be placed in a group.... more
Adding Commands to the Ribbon | This topic follows in sequence the creation of a ribbon application using either the Ribbon Application Wizard or the manual steps described in Creating an Application that Uses Ribbon Controls. This topic assumes that you are familiar with the TActionManager component and the components associated with its use. Numerous new properties have been added to help support the ribbon requirements. Many existing properties have no effect when modified on a command that is displayed on the ribbon. For instance: Small buttons always display their glyph to the left of the caption. Large buttons always display their glyph at... more

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!