Using remotable objects

Use TRemotable as a base class when defining a class to represent a complex data type on an invokable interface. For example, in the case where you would ordinarily pass a record or struct as a parameter, you would instead define a TRemotable descendant where every member of the record or struct is a published property on your new class. You can control whether the published properties of your TRemotable descendant appear as element nodes or attributes in the corresponding SOAP encoding of the...

Writing cleanup code

You can centralize the code that cleans up when your thread finishes executing. Just before a thread shuts down, an OnTerminate event occurs. Put any clean-up code in the OnTerminate event handler to ensure that it is always executed, no matter what execution path the Execute method follows. The OnTerminate event handler is not run as part of your thread. Instead, it is run in the context of the main VCL or CLX thread of your application. This has two implications You can't use any thread-local...

Example of adding silent video clips

Suppose you want to display an animated logo as the first screen that appears when your application starts. After the logo finishes playing the screen disappears. To run this example, create a new project and save the Unitl.pas file as Frmlogo.pas and save the Projectl.dpr file as Logo.dpr. Then 1 Double-click the animate icon from the Win32 page of the Component palette. 2 Using the Object Inspector, set its Name property to Logo1. 3 Select its FileName property, click the ellipsis ( ) button,...

TControl branch

The TControl branch consists of components that descend from TControl but not TWinControl (TWidgetControl in CLX applications). Classes in this branch are controls visual objects that the user can see and manipulate at runtime. All controls have properties, methods, and events in common that relate to how the control looks, such as its position, the cursor associated with the control's window, methods to paint or move the control, and events to respond to mouse actions. Controls in this branch,...

Working with XML components

The VCL (or CLX) defines a number of classes and interfaces for working with XML documents. These simplify the process of loading, editing, and saving XML documents. The starting point for working with an XML document is the TXMLDocument component. The following steps describe how to use TXMLDocument to work directly with an XML document 1 Add a TXMLDocument component to your form or data module. TXMLDocument appears on the Internet page of the Component palette. 2 Set the DOMVendor property to...

Deploying Web applications

Some Delphi applications are designed to be run over the World Wide Web, such as those in the form of Server-side Extension DLLs (ISAPI and Apache), CGI applications, and ActiveForms. The steps for deploying Web applications are the same as those for general applications, except the application's files are deployed on the Web server. Here are some special considerations for deploying Web applications For BDE database applications, the Borland Database Engine (or alternate database engine) is...

Connecting to a data store using TADOConnection

One or more ADO dataset and command components can share a single connection to a data store by using TADOConnection. To do so, associated dataset and command components with the connection component through their Connection properties. At design-time, select the desired connection component from the drop-down list for the Connection property in the Object Inspector. At runtime, assign the reference to the Connection property. For example, the following line associates a TADODataSet component...

Executing the SQL statements

When you use multiple update objects, you do not associate the update objects with a dataset by setting its UpdateObject property. As a result, the appropriate statements are not automatically executed when you apply updates. Instead, you must explicitly invoke the update object in code. There are two ways to invoke the update object. Which way you choose depends on whether the SQL statement uses parameters to represent field values If the SQL statement to execute uses parameters, call the...

Internationalizing applications

You need to complete the following steps to create internationalized applications Enable your code to handle strings from international character sets. Design your user interface to accommodate the changes that result from localization. Isolate all resources that need to be localized. You must make sure that the code in your application can handle the strings it will encounter in the various target locales. The Western editions (including English, French, and German) of Windows use the ANSI...

Working with lists

BaseCLX includes many classes that represents lists or collections of items. They vary depending on the types of items they contain, what operations they support, and whether they are persistent. The following table lists various list classes, and indicates the types of items they contain Table 5.6 Classes for managing lists Table 5.6 Classes for managing lists A memory-managed list of object instances A memory-managed list of components (that is, instances of classes A first-in first-out list...

Using object fields

Object fields are fields that represent a composite of other, simpler datatypes. These include ADT (Abstract Data Type) fields, Array fields, DataSet fields, and Reference fields. All of these field types either contain or reference child fields or other data sets. ADT fields and array fields are fields that contain child fields. The child fields of an ADT field can be any scalar or object type (that is, any other field type). These child fields may differ in type from each other. An array...

Understanding multitiered database applications

Multi-tiered applications use the components on the DataSnap page, the Data Access page, and possibly the WebServices page of the Component palette, plus a remote data module that is created by a wizard on the Multitier or WebServices page of the New Items dialog. They are based on the ability of provider components to package data into transportable data packets and handle updates received as transportable delta packets. Understanding multi-tiered database applications The components needed...

Using database information in responses

The response to an HTTP request message may include information taken from a database. Specialized content producers on the Internet palette page can generate the HTML to represent the records from a database in an HTML table. As an alternate approach, special components on the InternetExpress page of the component palette let you build Web servers that are part of a multi-tiered database application. See Building Web applications using InternetExpress on page 31-33 for details. Console CGI...

Using Delphi or IDL syntax

The Text page of the Type Library editor displays your type information in one of two ways Using an extension of Delphi syntax. Note When working on a CORBA object, you use neither of these on the text page. Instead, you must use the CORBA IDL. You can select which language you want to use by changing the setting in the Environment Options dialog. Choose Tools Environment Options, and specify either Pascal or IDL as the Language on the Type Library page of the dialog. Note The choice of Delphi...

Directory structure on Linux

In Linux, any file or device can be mounted anywhere on the file system. Linux pathnames use forward slashes whereas Windows pathnames use backslashes. The initial slash stands for the root directory. Following are some of the commonly used directories in Linux. Table 15.7 Common Linux directories The root or top directory of the entire Linux file system root The root file system the Superuser's home directory home username Files owned by the user where username is the user's login name. boot...

Displaying a single record

In many applications, you may only want to provide information about a single record of data at a time. For example, an order-entry application may display the information about a single order without indicating what other orders are currently logged. This information probably comes from a single record in an orders dataset. Applications that display a single record are usually easy to read and understand, because all database information is about the same thing (in the previous case, the same...

Mapping between XML nodes and data packet fields

XML provides a text-based way to store or describe structured data. Datasets provide another way to store and describe structured data. To convert an XML document into a dataset, therefore, you must identify the correspondences between the nodes in an XML document and the fields in a dataset. Consider, for example, an XML document that represents a set of email messages. It might look like the following (containing a single message) < xml version 1.0 standalone yes > < email> <...

Licensing ActiveX controls

Licensing an ActiveX control consists of providing a license key at design-time and supporting the creation of licenses dynamically for controls created at runtime. To provide design-time licenses, the ActiveX wizard creates a key for the control, which it stores in a file with the same name as the project with the LIC extension. This .LIC file is added to the project. The user of the control must have a copy of the .LIC file to open the control in a development environment. Each control in the...

Using dataaware ActiveX controls

When you use a data-aware ActiveX control in a Delphi application, you must associate it with the database whose data it represents. To do this, you need a data source component, just as you need a data source for any data-aware VCL control. After you place the data-aware ActiveX control in the form designer, assign its DataSource property to the data source that represents the desired dataset. Once you have specified a data source, you can use the Data Bindings editor to link the control's...

Refining line drawing

With fields in place to track various points, you can refine an application's line drawing. When drawing lines, track the point where the line starts with the Origin field. Origin must be set to the point where the mouse-down event occurs, so the mouse-up event handler can use Origin to place the beginning of the line, as in this code procedure TForm1.FormMouseDown(Sender TObject Button TMouseButton Shift TShiftState X, Y Integer) Drawing True Canvas.MoveTo(X, Y) Origin Point(X, Y) record where...

The structure of metadata datasets

For each type of metadata you can access using TSQLDataSet, there is a predefined set of columns fields that are populated with information about the items of the requested type. When you request information about tables stTables or stSysTables , the resulting dataset includes a record for each table. It has the following columns Table 28.1 Columns in tables of metadata listing tables A record number that uniquely identifies each record. The name of the catalog database that contains the table....

Creating and editing packages

Creating a package involves specifying A list of other packages to be required by, or linked to, the new package. A list of unit files to be contained by, or bound into, the package when it is compiled. The package is essentially a wrapper for these source-code units. The Contains clause is where you put the source-code units for custom components that you want to compile into a package. The Package editor generates a package source file .dpk . To create a package, follow the procedure below....

Understanding invokable interfaces

Servers that support Web Services are built using invokable interfaces. Invokable interfaces are interfaces that are compiled to include runtime type information RTTI . On the server, this RTTI is used when interpreting incoming method calls from clients so that they can be correctly marshaled. On clients, this RTTI is used to dynamically generate a method table for making calls to the methods of the interface. To create an invokable interface, you need only compile an interface with the M...

Handling events in an automation controller

When you generate a Component wrapper for an object whose type library you import, you can respond to events simply using the events that are added to the generated component. If you do not use a Component wrapper, however, or if the server uses COM events , you must write the event sink code yourself. Handling Automation events programmatically Before you can handle events, you must define an event sink. This is a class that implements the event dispatch interface that is defined in the...

Serverside scripting in Web Snap

Page producer templates can include scripting languages such as JScript or VBScript. The page producer executes the script in response to a request for the producer's content. Because the Web server application evaluates the script, it is called serverside script, as opposed to client-side script which is evaluated by the browser . This section provides a conceptual overview of server-side scripting and how it is used by WebSnap applications. The WebSnap server-side scripting referencetopic in...

Converting Web server application target types

One powerful feature of Web Broker and WebSnap is that they offer several different target server types. The IDE allows you to easily convert from one target type to another. Because Web Broker and WebSnap have slightly different design philosophies, you must use a different conversion method for each architecture. To convert your Web Broker application target type, use the following steps 1 Right-click the Web module and choose Add To Repository. 2 In the Add To Repository dialog box, give...

Loading an XML schema or data packet

Before you can define a mapping and generate a transformation file, you must first load descriptions of the XML document and the data packet between which you are mapping. You can load an XML document or schema by choosing FilelOpen and selecting the document or schema in the resulting dialog. You can load a data packet by choosing FilelOpen and selecting a data packet file in the resulting dialog. The data packet is simply the file generated when you call a client dataset's SaveToFile method....

Displaying ADT and array fields

Sometimes the fields of the grid's dataset do not represent simple values such as text, graphics, numerical values, and so on. Some database servers allow fields that are a composite of simpler data types, such as ADT fields or array fields. There are two ways a grid can display composite fields It can flatten out the field so that each of the simpler types that make up the field appears as a separate field in the dataset. When a composite field is flattened out, its constituents appear as...

Using TInvokeable VariantType

To provide support for properties and methods, the class you create to enable the new custom variant type should descend from TInvokeableVariantType instead of directly from TCustomVariantType. TInvokeableVariantType defines four methods that you can implement to support properties and methods on your custom variant type. For example, the VarConv unit uses TInvokeableVariantType as the base class for TConvertVariantType so that the resulting custom variants can support properties. The following...

Using the Decision Cube editor

You can use the Decision Cube editor to set the DimensionMap properties of decision cubes. You can display the Decision Cube editor through the Object Inspector, as described in the previous section, or by right-clicking a decision cube on a form at design time and choosing Decision Cube editor. The Decision Cube Editor dialog box has two tabs Dimension Settings, used to activate or disable available dimensions, rename and reformat dimensions, put dimensions in a permanently drilled state, and...

Remotable object example

This example shows how to create a remotable object for a parameter on an invokable interface where you would otherwise use an existing class. In this example, the existing class is a string list TStringList . To keep the example small, it does not reproduce the Objects property of the string list. Because the new class is not scalar, it descends from TRemotable rather than TRemotableXS. It includes a published property for every property of the string list you want to communicate between the...

Deploying database applications

Applications that access databases involve special installation considerations beyond copying the application's executable file onto the host computer. Database access is most often handled by a separate database engine, the files of which cannot be linked into the application's executable file. The data files, when not created beforehand, must be made available to the application. Multi-tier database applications require additional handling on installation, because the files that make up the...

Specifying a connection using SOAP

You can establish a connection to a SOAP application server using the TSoapConnection component. TSoapConnection is very similar to TWebConnection, because it also uses HTTP as a transport protocol. Thus, you can use TSoapConnection from any machine that has a TCP IP address, and it can take advantage of SSL security and to communicate with a server that is protected by a firewall. The SOAP connection component establishes a connection to a Web Service provider that implements the...

Parts of a Uniform Resource Locator

The Uniform Resource Locator URL is a complete description of the location of a resource that is available over the net. It is composed of several parts that may be accessed by an application. These parts are illustrated in Figure 33.1 Figure 33.1 Parts of a Uniform Resource Locator Host ScriptName PathInfo Query The first portion not technically part of the URL identifies the protocol http . This portion can specify other protocols such as https secure http , ftp, and so on. The Host portion...

Using an Object Repository item in a project

To access items in the Object Repository, choose File New Other. The New Items dialog appears, showing all the items available. Depending on the type of item you want to use, you have up to three options for adding the item to your project Choose Copy to make an exact copy of the selected item and add the copy to your project. Future changes made to the item in the Object Repository will not be reflected in your copy, and alterations made to your copy will not affect the original Object...

About Web Broker and Web Snap

Part of the function of any application is to make data accessible to the user. In a standard application you accomplish this by creating traditional front end elements, like dialogs and scrolling windows. Developers can specify the exact layout of these objects using familiar form design tools. Web server applications must be designed differently, however. All information passed to users must be in the form of HTML pages which are transferred through HTTP. Pages are generally interpreted on...

Writing an object that supports the neutral threading model

Under COM , you can use another threading model that is in between free threading and apartment threading the neutral model. Like the free-threading model, this model allows multiple threads to access your object at the same time. There is no extra marshaling to transfer to the thread on which the object was created. However, your object is guaranteed to receive no conflicting calls. Writing an object that uses the neutral threading model follows much the same rules as writing an...

Using the file handle

When you instantiate TFileStream you get access to the file handle. The file handle is contained in the Handle property. On Windows, Handle is a Windows file handle. On Linux versions of CLX, it is a Linux file handle. Handle is read-only and reflects the mode in which the file was opened. If you want to change the attributes of the file Handle, you must create a new file stream object. Some file manipulation routines take a file handle as a parameter. Once you have a file stream, you can use...

Stateful and stateless objects

Like any COM object, transactional objects can maintain internal state across multiple interactions with a client. For example, the client could set a property value in one call, and expect that property value to remain unchanged when it makes the next call. Such an object is said to be stateful. Transactional objects can also be stateless, which means the object does not hold any intermediate state while waiting for the next call from a client. When a transaction is committed or aborted, all...

Using the WSDL importer

To use the WSDL importer, choose Filel Newl Other, and on the WebServices page double-click the icon labeled WSDL importer. In the dialog that appears, specify the file name of a WSDL document or XML file or provide the URL where that document is published. Note If you do not know the URL for the WSDL document you want to import, you can browse for one by clicking the button labeled Search UDDI. This launches the UDDI browser, which is described in Browsing for Business services on page 38-14....

Decision cube properties and events

The DimensionMap properties of TDecisionCube not only control which dimensions and summaries appear but also let you set date ranges and specify the maximum number of dimensions the decision cube may support. You can also indicate whether or not to display data during design. You can display names, categories values, subtotals, or data. Display of data at design time can be time consuming, depending on the data source. When you click the ellipsis next to DimensionMap in the Object Inspector,...

Avoiding simultaneous access

To avoid clashing with other threads when accessing global objects or variables, you may need to block the execution of other threads until your thread code has finished an operation. Be careful not to block other execution threads unnecessarily. Doing so can cause performance to degrade seriously and negate most of the advantages of using multiple threads. Some objects have built-in locking that prevents the execution of other threads from using that object instance. For example, canvas...

Creating a customized grid

A customized grid is one for which you define persistent column objects that describe how a column appears and how the data in the column is displayed. A customized grid lets you configure multiple grids to present different views of the same dataset different column orders, different field choices, and different column colors and fonts, for example . A customized grid also enables you to let users modify the appearance of the grid at runtime without affecting the fields used by the grid or the...

Adding audio andor video clips to an application

With the media player component, you can add audio and or video clips to your application. It opens a media device and plays, stops, pauses, records, etc., the audio and or video clips used by the media device. The media device may be hardware or Note Audio support is not available in cross-platform applications. To add an audio and or video clip to an application 1 Double-click the media player icon on the System page of the Component palette. This automatically put a media player control on...

Creating HTTP response messages

When the Web server application creates a TWebRequest descended object for an incoming HTTP request message, it also creates a corresponding object descended from TWebResponse to represent the response message that will be sent in return. For example, in NSAPI and ISAPI applications, the response message is encapsulated by a TISAPIResponse object, and Console CGI applications use TCGIResponse objects. The action items that generate the response to a Web client request fill in the properties of...

Creating Web pages with an Internet Express page producer

Each InternetExpress page producer generates an HTML document that appears in the browsers of your application's clients. If your application includes several separate Web documents, use a separate page producer for each of them. The InternetExpress page producer TInetXPageProducer is a special page producer component. As with other page producers, you can assign it as the Producer property of an action item or call it explicitly from an OnAction event handler. For more information about using...

Using a remote interfaced object

If you do not use the global function to obtain the invokable interface you want to call, you can create an instance of THTTPRio for the desired interface Note It is important that you do not explicitly destroy the THTTPRio instance. If it is created without an Owner as in the previous line of code , it automatically frees itself when its interface is released. If it is created with an Owner, the Owner is responsible for freeing the THTTPRio instance. Once you have an instance of THTTPRio,...

HTTP request header information

HTTP request messages contain many headers that describe information about the client, the target of the request, the way the request should be handled, and any content sent with the request. Each header is identified by a name, such as Host followed by a string value. For example, consider the following HTTP request GET HTTP 1.0 Connection Keep-Alive User-Agent Mozilla 3.0b4Gold WinNT I Host www.TSite.com 1024 Accept image gif, image x-xbitmap, image jpeg, image pjpeg, The first line...

Inprocess outofprocess and remote servers

With COM, a client does not need to know where an object resides, it simply makes a call to an object's interface. COM performs the necessary steps to make the call. These steps differ depending on whether the object resides in the same process as the client, in a different process on the client machine, or in a different machine across the network. The different types of servers are known as In-process server A library DLL running in the same process space as the client, for example, an...

Applying updates from XML delta packets

When you add the XML broker to the Web module or data module containing a TWebDispatcher , it automatically registers itself with the Web dispatcher as an autodispatching object. This means that, unlike other components, you do not need to create an action item for the XML broker in order for it to respond to update messages from a Web browser. These messages contain XML delta packets that should be applied to the application server. Typically, they originate from a button that you create on...

Defining header classes

For each header you want to define, create a descendant of TSOAPHeader. TSOAPHeader is a descendant of TRemotable. That is, SOAP header objects are simply special types of remotable objects. As with any remotable object, you can add published properties to your TSOAPHeader descendant to represent the information that your header communicates. Once you have defined a SOAP header class, it must be registered with the remotable type registry. For more information about remotable objects, see Using...

Adding a toolbar using a panel component

To add a toolbar to a form using the panel component, 1 Add a panel component to the form from the Standard page of the Component palette . 2 Set the panel's Align property to alTop. When aligned to the top of the form, the panel maintains its height, but matches its width to the full width of the form's client area, even if the window changes size. 3 Add speed buttons or other controls to the panel. Speed buttons are designed to work on toolbar panels. A speed button usually has no caption,...

Using databases

Delphi includes many components for accessing databases and representing the information they contain. They are grouped according to the data access mechanism The BDE page of the Component palette contains components that use the Borland Database Engine BDE . The BDE defines a large API for interacting with databases. Of all the data access mechanisms, the BDE supports the broadest range of functions and comes with the most supporting utilities. It is the best way to work with data in Paradox...

Creating and editing standard data modules

To create a standard data module for a project, choose FilelNew l Data Module. The IDE opens a data module container on the desktop, displays the unit file for the new module in the Code editor, and adds the module to the current project. At design time, a data module looks like a standard form with a white background and no alignment grid. As with forms, you can place nonvisual components from the Component palette onto a module, and edit their properties in the Object Inspector. You can...

Building an Internet Express application

The following steps describe one way to build a Web application using InternetExpress. The result is an application that creates HTML pages that let users interact with the data from an application server via a javascript-enabled Web browser. You can also build an InternetExpress application using the Site Express architecture by using the InternetExpress page producer TInetXPageProducer . 1 Choose File l New l Other to display the New Items dialog box, and on the New page select Web Server...

Making the table a detail of another dataset

A table type dataset's MasterSource and MasterFields properties can be used to establish one-to-many relationships between two datasets. The MasterSource property is used to specify a data source from which the table gets data from the master table. This data source can be linked to any type of dataset. For instance, by specifying a query's data source in this property, you can link a client dataset as the detail of the query, so that the client dataset tracks events occurring in the query. The...

Using a client dataset to cache updates

By default, when you edit data in most datasets, every time you delete or post a record, the dataset generates a transaction, deletes or writes that record to the database server, and commits the transaction. If there is a problem writing changes to the database, your application is notified immediately the dataset raises an exception when you post the record. If your dataset uses a remote database server, this approach can degrade performance due to network traffic between your application and...

Service applications

Service applications take requests from client applications, process those requests, and return information to the client applications. They typically run in the background, without much user input. A Web, FTP, or e-mail server is an example of a service application. To create an application that implements a Win32 service 1 Choose File New Other, and double-click Service Application in the New Items dialog box. This adds a global variable named Application to your project, which is of type...

Creating a grid that contains other dataaware controls

A TDBCtrlGrid control displays multiple fields in multiple records in a tabular grid format. Each cell in a grid displays multiple fields from a single row. To use a database control grid 1 Place a database control grid on a form. 2 Set the grid's DataSource property to the name of a data source. 3 Place individual data controls within the design cell for the grid. The design cell for the grid is the top or leftmost cell in the grid, and is the only cell into which you can place other controls....

Creating packages and DLLs

Dynamic link libraries DLLs are modules of compiled code that work in conjunction with an executable to provide functionality to an application. You can create DLLs in cross-platform programs. However, on Linux, DLLs and packages recompile as shared objects. DLLs and libraries should handle all exceptions to prevent the display of errors and warnings through Windows dialogs. The following compiler directives can be placed in library project files Table 8.1 Compiler directives for libraries...

Creating Web Broker applications

You can use Web Broker also called NetCLX architecture to create Web server applications such as CGI applications or dynamic-link libraries DLLs . These Web server applications can contain any nonvisual component. Components on the Internet page of the Component palette enable you to create event handlers, programmatically construct HTML or XML documents, and transfer them to the client. To create a new Web server application using the Web Broker architecture, choose FilelNewlOther and...

Adding a speed button to a panel

To add a speed button to a toolbar panel, place the speed button component from the Additional page of the Component palette on the panel. The panel, rather than the form, owns the speed button, so moving or hiding the panel also moves or hides the speed button. The default height of the panel is 41, and the default height of speed buttons is 25. If you set the Top property of each button to 8, they'll be vertically centered. The default grid setting snaps the speed button to that vertical...

Setting filter options

The FilterOptions property lets you specify whether a filter that compares string-based fields accepts records based on partial comparisons and whether string comparisons are case-sensitive. FilterOptions is a set property that can be an empty set the default , or that can contain either or both of the following values Disable partial string matching that is, don't match strings that end with an For example, the following statements set up a filter that ignores case when comparing values in the...

Using project templates

Templates are predesigned projects that you can use as starting points for your own work. To create a new project from a template 1 Choose File l New l Other to display the New Items dialog box. 3 Select the project template you want and choose OK. 4 In the Select Directory dialog, specify a directory for the new project's files. The template files are copied to the specified directory, where you can modify them. The original project template is unaffected by your changes.

Sending and receiving headers

Once you have defined and registered header classes, they are available for your application to use. When your application receives a request, the headers on that message are automatically converted into the corresponding TSOAPHeader descendants that you have defined. Your application identifies the appropriate header class by matching the name of the header node against the type name you used when you registered the header class. Any headers for which it can't find a match in the remotable...

Environmental differences between Windows and Linux

Currently, cross-platform means an application that can compile virtually unchanged on both the Windows and Linux operating systems. However, there are many differences between Linux and the Windows operating environments. Table 15.6 Differences in the Linux and Windows operating environments File name case sensitivity Line ending characters End of file character Batch files shell scripts In Linux, file names are case sensitive. The file Test.txt is not the same file as test.txt. You need to...

Using the clipboard with graphics

You can use the Windows clipboard to copy and paste graphics within your applications or to exchange graphics with other applications. The VCL's clipboard object makes it easy to handle different kinds of information, including graphics. Before you can use the clipboard object in your application, you must add the Clipbrd QClipbrd in CLX applications unit to the uses clause of any unit that needs to access clipboard data. For CLX applications, data that is stored on the clipboard is stored as a...

Creating an ActiveX control

An ActiveX control is a software component that integrates into and extends the functionality of any host application that supports ActiveX controls, such as C Builder, Delphi, Visual Basic, Internet Explorer, and given a plug-in Netscape Navigator. ActiveX controls implement a particular set of interfaces that allow this integration. For example, Delphi comes with several ActiveX controls, including charting, spreadsheet, and graphics controls. You can add these controls to the Component...

Types of datasets

Using TDataSet descendants on page 24-2 classifies TDataSet descendants by the method they use to access their data. Another useful way to classify TDataSet descendants is to consider the type of server data they represent. Viewed this way, there are three basic classes of datasets Table type datasets Table type datasets represent a single table from the database server, including all of its rows and columns. Table type datasets include TTable, TADOTable, TSQLTable, and TIBTable. Table type...

Customizing drag and drop with a drag object

You can use a TDragObject descendant to customize an object's drag-and-drop behavior. The standard drag-over and drag-and-drop events indicate the source of the dragged item and the coordinates of the mouse cursor over the accepting control. To get additional state information, derive a custom drag object from TDragObject or TDragObjectEx VCL only and override its virtual methods. Create the custom drag object in the OnStartDrag event. Normally, the source parameter of the drag-over and...

Creating an Active Server Object

An Active Server Object is an Automation object that has access to information about the entire ASP application and the HTTP messages it uses to communicate with browsers. It descends from TASPObject or TASPMTSObject which is in turn a descendant of TAutoObject , and supports Automation protocols, exposing itself for other applications or the script in the Active Server page to use. You create an Active Server Object using the Active Server Object wizard. Your Active Server Object project can...

Defining thread objects

For most applications, you can use a thread object to represent an execution thread in your application. Thread objects simplify writing multi-threaded applications by encapsulating the most commonly needed uses of threads. Note Thread objects do not allow you to control the security attributes or stack size of your threads. If you need to control these, you must use the BeginThread function. Even when using BeginThread, you can still benefit from some of the thread synchronization objects and...

Working with passwordprotected Paradox and dBASE tables

A session component can store passwords for password-protected Paradox and dBASE tables. Once you add a password to the session, your application can open tables protected by that password. Once you remove the password from the session, your application can't open tables that use the password until you add it again. database doesn't exist for session so, create and open it The AddPassword method provides an optional way for an application to provide a password for a session prior to opening an...

Setting the appearance of the cool bar

The cool bar component offers several useful configuration options. Table 9.9 lists some actions you can set to change a tool button's appearance Table 9.9 Setting a cool button s appearance To make the cool bar Set the toolbar's Resize automatically to accommodate the bands it AutoSize property to True. contains Bands maintain a uniform height Reorient to vertical rather than horizontal Prevent the Text properties of the bands from displaying at runtime Keep users from changing the bands'...

Allowing toggle buttons

Sometimes you want to be able to click a button in a group that's already pressed and have it pop up, leaving no button in the group pressed. Such a button is called a toggle. Use AllowAllUp to create a grouped button that acts as a toggle click it once, it's down click it again, it pops up. To make a grouped speed button a toggle, set its AllowAllUp property to True. Setting AllowAllUp to True for any speed button in a group automatically sets the same property value for all buttons in the...

Accessing a data module from a form

To associate visual controls on a form with a data module, you must first add the data module to the form's uses clause. You can do this in several ways In the Code editor, open the form's unit file and add the name of the data module to the uses clause in the interface section. Click the form's unit file, choose Filel Use Unit, and enter the name of the module or pick it from the list box in the Use Unit dialog. For database components, in the data module click a dataset or query component to...

Developing applications with Delphi

Borland Delphi is an object-oriented, visual programming environment to develop 32-bit applications for deployment on Windows and Linux. Using Delphi, you can create highly efficient applications with a minimum of manual coding. Delphi provides a suite of Rapid Application Development RAD design tools, including programming wizards and application and form templates, and supports object-oriented programming with a comprehensive class library that includes The Visual Component Library VCL ,...

Waiting for other threads

If your thread must wait for another thread to finish some task, you can tell your thread to temporarily suspend execution. You can either wait for another thread to completely finish executing, or you can wait for another thread to signal that it has completed a task. Waiting for a thread to finish executing To wait for another thread to finish executing, use the WaitFor method of that other thread. WaitFor doesn't return until the other thread terminates, either by finishing its own Execute...

Controlling grid drawing

Your first level of control over how a grid control draws itself is setting column properties. The grid automatically uses the font, color, and alignment properties of a column to draw the cells of that column. The text of data fields is drawn using the DisplayFormat or EditFormat properties of the field component associated with the column. You can augment the default grid display logic with code in a grid's OnDrawColumnCell event. If the grid's DefaultDrawing property is True, all the normal...

Creating an Active Form for the client application

1 Because the client application will be deployed as an ActiveX control, you must have a Web server that runs on the same system as the client application. You can use a ready-made server such as Microsoft's Personal Web server or you can write your own using the socket components described in Chapter 39, Working with sockets. 2 Create the client application following the steps described in Creating the client application on page 31-22, except start by choosing Filel New I ActiveX I Active...

Using TIni File and TMem IniFile

The ini file format is still popular, many configuration files such as the DSK Desktop settings file are in this format. This format is especially useful in cross-platform applications, where you can't always count on a system Registry for storing configuration information. BaseCLX provides two classes, TIniFile and TMemIniFile, to make reading and writing ini files very easy. TIniFile works directly with the ini file on disk while TMemIniFile buffers all changes in memory and does not write...

Creating and opening files using file streams

To create or open a file and get access to its handle, you simply instantiate a TFileStream. This opens or creates a specified file and provides methods to read from or write to it. If the file cannot be opened, the TFileStream constructor raises an exception. constructor Create const filename string Mode Word The Mode parameter specifies how the file should be opened when creating the file stream. The Mode parameter consists of an open mode and a share mode OR'ed together. The open mode must...

Adding silent video clips to an application

With the animation control, you can add silent video clips to your application 1 Double-click the TAnimate icon on the Win32 Common Control in CLX applications page of the Component palette. This automatically puts an animation control on the form window in which you want to display the video clip. 2 Using the Object Inspector, select the Name property and enter a new name for your animation control. You will use this name when you call the animation control. Follow the standard rules for...

Common properties and methods of Canvas

Table 12.2 lists the commonly used properties of the Canvas object. For a complete list of properties and methods, see the TCanvas component in online Help. Table 12.2 Common properties of the Canvas object Font Specifies the font to use when writing text on the image. Set the properties of the TFont object to specify the font face, color, size, and style of the font. Brush Determines the color and pattern the canvas uses for filling graphical shapes and backgrounds. Set the properties of the...

Activating a session

Active is a Boolean property that determines if database and dataset components associated with a session are open. You can use this property to read the current state of a session's database and dataset connections, or to change it. If Active is False the default , all databases and datasets associated with the session are closed. If True, databases and datasets are open. A session is activated when it is first created, and subsequently, whenever its Active property is changed to True from...

Creating persistent fields

Persistent field components created with the Fields editor provide efficient, readable, and type-safe programmatic access to underlying data. Using persistent field components guarantees that each time your application runs, it always uses and displays the same columns, in the same order even if the physical structure of the underlying database has changed. Data-aware components and program code that rely on specific fields always work as expected. If a column on which a persistent field...

Building a Web Service server

Use the following steps to build a server application that implements a Web Service 1 Choose File l New l Other and on the WebServices tab, double-click the Soap Server Application icon to launch the SOAP Server Application wizard. The wizard creates a new Web server application that includes the components you need to respond to SOAP requests. For details on the SOAP application wizard and the code it generates, see Using the SOAP application wizard on page 38-10. 2 When you exit the SOAP...

Responding to a mousedown action

The following code displays the string 'Here ' at the location on a form clicked with the mouse procedure TForm1.FormMouseDown Sender TObject Button TMouseButton Shift TShiftState X, Y Integer Canvas.TextOut X, Y, 'Here ' write text at X, Y end When the application runs, you can press the mouse button down with the mouse cursor on the form and have the string, Here appear at the point clicked. This code sets the current drawing position to the coordinates where the user presses the button...

Importing type library information

To make information about the COM server available to your client application, you must import the information about the server that is stored in the server's type library. Your application can then use the resulting generated classes to control the server object. There are two ways to import type library information You can use the Import Type Library dialog to import all available information about the server types, objects, and interfaces. This is the most general method, because it lets you...

Using multiple update objects

When more than one base table referenced in the update dataset needs to be updated, you need to use multiple update objects one for each base table updated. Because the dataset component's UpdateObject only allows one update object to be associated with the dataset, you must associate each update object with a dataset by setting its DataSet property to the name of the dataset. Tip When using multiple update objects, you can use TBDEClientDataSet instead of TClientDataSet with an external...

Applying BDEbased cached updates

Applying updates is a two-phase process that should occur in the context of a database component's transaction so that your application can recover gracefully from errors. For information about transaction handling with database components, see Managing transactions on page 23-6. When applying updates under database transaction control, the following events take place 1 A database transaction starts. 2 Cached updates are written to the database phase 1 . If you provide it, an OnUpdateRecord...

Writing the thread function

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 don't overwrite memory that is used by other threads 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...

Navigating datasets

Each active dataset has a cursor, or pointer, to the current row in the dataset. The current row in a dataset is the one whose field values currently show in single-field, data-aware controls on a form, such as TDBEdit, TDBLabel, and TDBMemo. If the dataset supports editing, the current record contains the values that can be manipulated by edit, insert, and delete methods. You can change the current row by moving the cursor to point at a different row. The following table lists methods you can...

Implementing binary operations

To allow the custom variant type to work with standard binary operators , -, , , div, mod, shl, shr, and, or, xor listed in the System unit , you must override the BinaryOp method. BinaryOp has three parameters the value of the left-hand operand, the value of the right-hand operand, and the operator. Implement this method to perform the operation and return the result using the same variable that contained the left-hand operand. For example, the following BinaryOp method comes from the...

Pooling remote data modules

Object pooling allows you to create a cache of remote data modules that are shared by their clients, thereby conserving resources. How this works depends on the type of remote data module and on the connection protocol. If you are creating a transactional data module that will be installed to COM , you can use the COM Component Manager to install the application server as a pooled object. See Object pooling on page 46-8 for details. Even if you are not using a transactional data module, you can...

Using a client dataset with filebased data

Client datasets can work with dedicated files on disk as well as server data. This allows them to be used in file-based database applications and briefcase model applications. The special files that client datasets use for their data are called MyBase. Tip All client datasets are appropriate for a briefcase model application, but for a pure MyBase application one that does not use a provider , it is preferable to use TClientDataSet, because it involves less overhead. In a pure MyBase...

Hiding the main form

You can prevent the main form from appearing when your application starts by using the global Application variable described in , Working at the application level, on page 9-2 . 1 Choose ProjectlView Source to display the main project file. 2 Add the following code after the call to Application.CreateForm and before the call Forml.Visible False the name of your main form may differ Note You can set the form's Visible property to False using the Object Inspector at design time rather than...

Setting up a transaction object on the server side

To control transaction context from the server side, you create an instance of ObjectContext. In the following example, the Transfer method is in the transactional object. In using ObjectContext this way, the instance of the object we are creating will inherit all the transaction attributes of the object that creates it.We wrap the call in a call to OleCheck because the methods of IObjectContext are exposed by Windows directly and are therefore not declared as safecall. procedure...

Requirements for a transactional object

In addition to the COM requirements, a transactional object must meet the following The object must have a standard class factory. This is automatically supplied by the wizard when you create the object. The server must expose its class object by exporting the standard DllGetClassObject method. Code to do this is supplied by the wizard. All object interfaces and CoClasses must be described by a type library, which is created automatically by the wizard. You can add methods and properties to...

Using the BDE to cache updates

The recommended approach for caching updates is to use a client dataset TBDEClientDataSet or to connect the BDE-dataset to a client dataset using a dataset provider. The advantages of using a client dataset are discussed in Using a client dataset to cache updates on page 29-16. For simple cases, however, you may choose to use the BDE to cache updates instead. BDE-enabled datasets and TDatabase components provide built-in properties, methods, and events for handling cached updates. Most of these...