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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Fetching XML data packets

Before the XML broker can supply XML data packets to the components that generate HTML pages, it must fetch them from the application server. To do this, it uses the IAppServer interface, which it acquires from a connection component. Note Even when using SOAP, where the application server supports IAppServerSOAP, the XML broker uses IAppServer because the connection component acts as an adapter between the two interfaces. You must set the following properties so that the XML producer can use...

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

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

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

Converting field values

Conversion properties attempt to convert one data type to another. For example, the AsString property converts numeric and Boolean values to string representations. The following table lists field component conversion properties, and which properties are recommended for field components by field-component class Note that some columns in the table refer to more than one conversion property such as AsFloat, AsCurrency, and AsBCD . This is because all field data types that support one of those...

Composing client requests

When an HTML hypertext link is selected or the user otherwise specifies a URL , the browser collects information about the protocol, the specified domain, the path to the information, the date and time, the operating environment, the browser itself, and other content information. It then composes a request. For example, to display a page of images based on criteria selected by clicking buttons on a form, the client might construct this URL which specifies an HTTP server in the www.TSite.com...

Using the as operator with interfaces

Classes that implement interfaces can use the as operator for dynamic binding on the interface. In the following example, procedure PaintObjects P TInterfacedObject var X IPaint X P as IPaint statements end the variable P of type TInterfacedObject, can be assigned to the variable X, which is an IPaint interface reference. Dynamic binding makes this assignment possible. For this assignment, the compiler generates code to call the Querylnterface method of P's IInterface interface. This is because...

Debugging dbExpress applications

While you are debugging your database application, it may prove useful to monitor the SQL messages that are sent to and from the database server through your connection component, including those that are generated automatically for you for example by a provider component or by the dbExpress driver . Using TSQLMonitor to monitor SQL commands TSQLConnection uses a companion component, TSQLMonitor, to intercept these messages and save them in a string list. TSQLMonitor works much like the SQL...

Using the properties of the Canvas object

You can set the color of a pen as you would any other Color property at runtime. A pen's color determines the color of the lines the pen draws, including lines drawn as the boundaries of shapes, as well as other lines and polylines. To change the pen color, assign a value to the Color property of the pen. To let the user choose a new color for the pen, put a color grid on the pen's toolbar. A color grid can set both foreground and background colors. For a non-grid pen style, you must consider...

WinCLX versus VisualCLX

CLX applications use the Borland Component Library for Cross-Platform CLX in place of the Visual Component Library VCL . Both the VCL and CLX include the same four out of five sublibraries, as described in Understanding the component library on page 3-1. The classes and properties in these sublibraries have the same names. The only differences between the VCL and CLX are the classes in the WinCLX and VisualCLX sublibraries. VCL applications use WinCLX whereas CLX applications use VisualCLX....

Identifying the database

AliasName and DriverName are mutually exclusive properties that identify the database server to which the TDatabase component connects. AliasName specifies the name of an existing BDE alias to use for the database component. The alias appears in subsequent drop-down lists for dataset components so that you can link them to a particular database component. If you specify AliasName for a database component, any value already assigned to DriverName is cleared because a driver name is always part...

Using Web connections

HTTP lets you create clients that can communicate with an application server that is protected by a firewall. HTTP messages provide controlled access to internal applications so that you can distribute your client applications safely and widely. Like socket connections, HTTP messages provide a lowest common denominator that you know will be available for connecting to the application server. For more information about HTTP messages, see Chapter 33, Creating Internet server applications. Instead...

Using the Execute method

Before TADOCommand can execute its command, it must have a valid connection to a data store. This is established just as with an ADO dataset. See Connecting an ADO dataset to a data store on page 27-10 for details. To execute the command, call the Execute method. Execute is an overloaded method that lets you choose the most appropriate way to execute the command. For commands that do not require any parameters and for which you do not need to know how many records were affected, call Execute...