Product Documentation

VCL/CLX Developers Guide

Previous Topic

Next Topic

Working without the Visual Components

All the samples discussed above used the visual components defined in the c-tree Plus palette. It is possible to develop the same work declaring the components in the program. This declaration is more general, in the sense that it allows for a component defined in one form to be used in other forms. On the other hand, it is very important that the object is destroyed before closing the program to avoid memory leakage. When the component is dropped in the form, it is destroyed when the form is destroyed. This doesn't happen when the object is instantiated and created in run time, and it has to be destroyed with the method Free. This is valid for all objects created at run time.

To declare, instantiate, and logon to a CtSession component, use the code:

Delphi Example


procedure Form1.LogonSession();

var

CtSession1: TCtSession;

begin

try

CtSession1:=TCtSession.Create(Self);

CtSession1.Server := 'FAIRCOMS';

CtSession1.User := 'ADMIN';

CtSession1.Password := 'ADMIN';

CtSession1.Active := True;

except

on E : ECtError do

Application.ShowException(E);

end;

end;

C++ Example


void Form1:: LogonSession()

{

try

{

}

catch (ECtError& E)

{

Application->ShowException(&E);

}

}

The other components work the same.

TOCIndex