Writing servers that support Web Services

In addition to the invokable interfaces and the classes that implement them, your server requires two components a dispatcher and an invoker. The dispatcher (THTTPSoapDispatcher) receives incoming SOAP messages and passes them on to the invoker. The invoker (THTTPSoapPascalInvoker) interprets the SOAP message, identifies the invokable interface it calls, executes the call, and assembles the response message. Note THTTPSoapDispatcher and THTTPSoapPascalInvoker are designed to respond to HTTP...

Stream methods for reading and writing

The Read method reads a specified number of bytes from the stream, starting at its current Position, into a buffer. Read then advances the current position by the number of bytes actually transferred. The prototype for Read is function Read(var Buffer Count Longint) Longint Read is useful when the number of bytes in the file is not known. Read returns the number of bytes actually transferred, which may be less than Count if the stream did not contain Count bytes of data past the current...

Implementing drag and dock in controls

Descendants of TWinControl can act as docking sites and descendants of TControl can act as child windows that are docked into docking sites. For example, to provide a docking site at the left edge of a form window, align a panel to the left edge of the form and make the panel a docking site. When dockable controls are dragged to the panel and released, they become child controls of the panel. Making a windowed control a docking site Making a control a dockable child Controlling how child...

Creating projects

All application development revolves around projects. When you create an application in Delphi you are creating a project. A project is a collection of files that make up an application. Some of these files are created at design time. Others are generated automatically when you compile the project source code. You can view the contents of a project in a project management tool called the Project Manager. The Project Manager lists, in a hierarchical view, the unit names, the forms contained in...

Creating SQL statements for update components

To update a record in an associated dataset, an update object uses one of three SQL statements. Each update object can only update a single table, so the object's update statements must each reference the same base table. The three SQL statements delete, insert, and modify records cached for update. You must provide these statements as update object's DeleteSQL, InsertSQL, and ModifySQL properties. You can provide these values at design time or at runtime. For example, the following code...

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

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

COM interface pointers

An interface pointer is a pointer to an object instance that points, in turn, to the implementation of each method in the interface. The implementation is accessed through an array of pointers to these methods, which is called a vtable. Vtables are similar to the mechanism used to support virtual functions in Delphi. Because of this similarity, the compiler can resolve calls to methods on the interface the same way it resolves calls to methods on Delphi classes. The vtable is shared among all...

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

Setting persistent field properties and events

You can set properties and customize events for persistent field components at design time. Properties control the way a field is displayed by a data-aware component, for example, whether it can appear in a TDBGrid, or whether its value can be modified. Events control what happens when data in a field is fetched, changed, set, or validated. To set the properties of a field component or write customized event handlers for it, select the component in the Fields editor, or select it from the...

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

Naming a connection description

Although you can always specify a connection using only the DatabaseName and Params properties, it can be more convenient to name a specific combination and then just identify the connection by name. You can name dbExpress database and parameter combinations, which are then saved in a file called dbxconnections.ini. The name of each combination is called a connection name. Once you have defined the connection name, you can identify a database connection by simply setting the ConnectionName...

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

Using ADO datasets

ADO dataset components encapsulate the ADO Recordset object. They inherit the common dataset capabilities described in Chapter 24, Understanding datasets, using ADO to provide the implementation. In order to use an ADO dataset, you must familiarize yourself with these common features. In addition to the common dataset features, all ADO datasets add properties, events, and methods for Connecting to an ADO datastore. Accessing the underlying Recordset object. Filtering records based on bookmarks....

Drawing ownerdraw items

When an application needs to draw or redraw an owner-draw control, the operating system generates draw-item events for each visible item in the control. Depending on the control, the item may also receive draw events for the item as a part of the item. To draw each item in an owner-draw control, attach an event handler to the draw-item event for that control. The names of events for owner drawing typically start with one of the following OnDraw, such as OnDrawItem or OnDrawCell OnCustomDraw,...

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

Importing resource files

You can build menus with other applications, so long as the menus are in the standard Windows resource .RC file format. You can import such menus directly into your project, saving you the time and effort of rebuilding menus that you created elsewhere. 1 In the Menu Designer, place your cursor where you want the menu to appear. The imported menu can be part of a menu you are designing, or an entire menu in itself. 2 Right-click and choose Insert From Resource. The Insert Menu From Resource...

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 the Event Object wizard

You can create event objects using the Event Object wizard. The wizard first checks whether the current project contains any implementation code, because projects containing COM event objects do not include an implementation. They can only contain event object definitions. You can, however, include multiple COM event objects in a single project. To bring up the Event Object wizard, 2 Select the tab labeled ActiveX. 3 Double-click the COM Event Object icon. In the Event Object wizard, specify...

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

The Rave Visual Designer

To launch the Rave Visual Designer, do one of the following Choose Tools I Rave Designer. Double-click a TRvProject component on a form. Right-click a TRvProject component on a form, and choose Rave Visual Designer. Use the component .toolbars to add components to the Page Designer click a toolbar button and then click the grid . Use the editor toolbars to change the report project or components. Use the Property Panel to set the properties, methods, and events for the selected component. Use...

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

Determining the order of merged menu items Group Index property

The GroupIndex property determines the order in which the merging menu items appear in the shared menu bar. Merging menu items can replace those on the main menu bar, or can be inserted. The default value for GroupIndex is 0. Several rules apply when specifying a value for GroupIndex Lower numbers appear first farther left in the menu. For instance, set the GroupIndex property to 0 zero for a menu that you always want to appear leftmost, such as a File menu. Similarly, specify a high number it...

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

Using the UDDI browser

The first step after you launch the UDDI browser from the WSDL importer is to indicate the UDDI registry you want to search. The public registries should all contain the same information, but there can be differences. In addition, you may be using an internal, private registry. Select a public registry from the drop-down in the upper left corner, or type in the address of a private registry you want to use. The next step is to locate the business from which you want to import a Web Service....

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

Generating transformation files

To generate a transformation file, use the following steps 1 First select the radio button that indicates what the transformation creates Choose the Datapacket to XML button if the mapping goes from data packet to XML document. Choose the XML to Datapacket button if the mapping goes from XML document to data packet. 2 If you are generating a data packet, you will also want to use the radio buttons in the Create Datapacket As section. These buttons let you specify how the data packet will be...

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

Creating an index with Index FieldNames

If there is no defined index that implements the sort order you want, you can create a pseudo-index using the IndexFieldNames property. Note IndexName and IndexFieldNames are mutually exclusive. Setting one property clears values set for the other. The value of IndexFieldNames is a string. To specify a sort order, list each column name to use in the order it should be used, and delimit the names with semicolons. Sorting is by ascending order only. Case-sensitivity of the sort depends on the...

Reading and writing components

TStream defines specialized methods, ReadComponent and WriteComponent, for reading and writing components. You can use them in your applications as a way to save components and their properties when you create or alter them at runtime. ReadComponent and WriteComponent are the methods that the IDE uses to read components from or write them to form files. When streaming components to or from a form file, stream classes work with the TFiler classes, TReader and TWriter, to read objects from the...

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 an XML document as the source for a provider

The TXMLTransformProvider component lets you use an XML document as if it were a database table. TXMLTransformProvider packages the data from an XML document and applies updates from clients back to that XMl document. It appears to clients such as client datasets or XML brokers like any other provider component. For information on provider components, see Chapter 30, Using provider components. For information on using provider components with client datasets, see Using a client dataset with a...

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

Writing multithreaded applications

Several objects make writing multi-threaded applications easier. Multi-threaded applications are applications that include several simultaneous paths of execution. While using multiple threads requires careful thought, it can enhance your programs Avoiding bottlenecks. With only one thread, a program must stop all execution when waiting for slow processes such as accessing files on disk, communicating with other machines, or displaying multimedia content. The CPU sits idle until the process...

Adding color patterns or pictures to menus buttons and toolbars

You can use the Background and BackgroundLayout properties to specify a color, pattern, or bitmap to use on a menu item or button. These properties also let you set up a banner the runs up the left or right side of a menu. You assign backgrounds and layouts to subitems from their action client objects. If you want to set the background of the items in a menu, in the form designer click on the menu item that contains the items. For example, selecting File lets you change the background of items...

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

Applying cached updates using a database

To apply cached updates to one or more datasets in the context of a database connection, call the database component's ApplyUpdates method. The following code applies updates to the CustomersQuery dataset in response to a button click event procedure TForm1.ApplyButtonClick Sender TObject begin for local databases such as Paradox, dBASE, and FoxPro set TransIsolation to DirtyRead if not Databasel.IsSQLBased and not Databasel.Translsolation tiDirtyRead then Databasel.Translsolation tiDirtyRead...

Using Indexes to search for records

You can search against any dataset using the Locate and Lookup methods of TDataSet. However, by explicitly using indexes, some table type datasets can improve over the searching performance provided by the Locate and Lookup methods. ADO datasets all support the Seek method, which moves to a record based on a set of field values for fields in the current index. Seek lets you specify where to move the cursor relative to the first or last matching record. TTable and all types of client dataset...

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

Dynamic field components

Dynamically generated field components are the default. In fact, all field components for any dataset start out as dynamic fields the first time you place a dataset on a data module, specify how that dataset fetches its data, and open it. A field component is dynamic if it is created automatically based on the underlying physical characteristics of the data represented by a dataset. Datasets generate one field component for each column in the underlying data. The exact TField descendant created...

Objects components and controls

Figure 3.2 is a greatly simplified view of the inheritance hierarchy that illustrates the relationship between objects, components, and controls. Figure 3.1 A simplified hierarchy diagram Figure 3.1 A simplified hierarchy diagram TPersistent TComponent V-TControl TPersistent TComponent V-TControl Objects TGraphicControM Objects TWidgetControl in cross-platform applications. Every object class inherits from TObject. Objects that can appear in the Form Designer inherit from TPersistent or...

Designing a COM object

When designing the COM object, you need to decide what COM interfaces you want to implement. You can write a COM object to implement an interface that has already been defined, or you can define a new interface for your object to implement. In addition, you can have your object support more than one interface. For information about standard COM interfaces that you might want to support, see the MSDN documentation. To create a COM object that implements an existing interface, use the COM Object...

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

Connecting to the database server

The first step when working with a unidirectional dataset is to connect it to a database server. At design time, once a dataset has an active connection to a database server, the Object Inspector can provide drop-down lists of values for other properties. For example, when representing a stored procedure, you must have an active connection before the Object Inspector can list what stored procedures are available on the server. The connection to a database server is represented by a separate...

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

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

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

Navigating records in a filtered dataset

There are four dataset methods that navigate among records in a filtered dataset. The following table lists these methods and describes what they do Table 24.6 Filtered dataset navigational methods FindFirst Move to the first record that matches the current filter criteria. The search for the first matching record always begins at the first record in the unfiltered dataset. FindLast Move to the last record that matches the current filter criteria. FindNext Moves from the current record in the...

Managing database connections

You can use a session component to manage the database connections within it. The session component includes properties and methods you can use to Close database connections. Close and free all inactive temporary database connections. Locate specific database connections. Iterate through all open database connections. To open a database connection within a session, call the OpenDatabase method. OpenDatabase takes one parameter, the name of the database to open. This name is a bDe alias or the...

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

Using BaseCLX

There are a number of units in the component library that provide the underlying support for most of the component libraries. These units include the global routines that make up the runtime library, a number of utility classes such as those that represent streams and lists, and the classes TObject, TPersistent, and TComponent. Collectively, these units are called BaseCLX. BaseCLX does not include any of the components that appear on the Component palette. Rather, the classes and routines in...

Refreshing the type library

Regenerates the Delphi type library units in memory only. It does not save any files to disk. Notifies the IDE's module manager to update the implementation, if the type library is associated with a CoClass that was generated by a wizard. To refresh the type library choose the Refresh icon on the Type Library editor toolbar. Note If you have renamed items in the type library, refreshing the implementation may create duplicate entries. In this case, you must move your code to the correct entry...

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

Creating toolbars and menus

Note This section describes the recommended method for creating menus and toolbars in Windows applications. For cross-platform development, you need to use TToolBar and the menu components, such as TMainMenu, organizing them using action lists TActionList . See Setting up action lists on page 9-26. You use the Action Manager to automatically generate toolbars and main menus based on the actions contained in your application. The Action Manager manages standard actions and any custom actions...

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