Project: SimpleClient.dproj |
Project Structure |
|
SimpleClient.dpr |
program SimpleClient;
uses
Forms,
SimpleClient_MainForm in 'SimpleClient_MainForm.pas' {FormSimpleClient},
SimpleServer_TLB in 'SimpleServer_TLB.pas';
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TFormSimpleClient, FormSimpleClient);
Application.Run;
end. |
SimpleClient_MainForm.pas |
unit SimpleClient_MainForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Spin, SimpleServer_TLB;
type
TFormSimpleClient = class(TForm)
Label1: TLabel;
Label2: TLabel;
SpinEdit1: TSpinEdit;
Button1: TButton;
Button2: TButton;
SpinEdit2: TSpinEdit;
Button3: TButton;
Button4: TButton;
Button5: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
Num1, Num2 : INumberProp;
end;
var
FormSimpleClient: TFormSimpleClient;
implementation
{$R *.dfm}
procedure TFormSimpleClient.Button1Click(Sender: TObject);
begin
// change
Num1.Value := SpinEdit1.Value;
Label1.Caption := 'Num1: ' + IntToStr (Num1.Value);
end;
procedure TFormSimpleClient.Button2Click(Sender: TObject);
begin
// increase
Num1.Increase;
Label1.Caption := 'Num1: ' + IntToStr (Num1.Value);
end;
procedure TFormSimpleClient.Button3Click(Sender: TObject);
begin
Num2.Value := SpinEdit2.Value;
Label2.Caption := 'Num2: ' + IntToStr (Num2.Value);
end;
procedure TFormSimpleClient.Button4Click(Sender: TObject);
begin
Num2.Increase;
Label2.Caption := 'Num2: ' + IntToStr (Num2.Value);
end;
procedure TFormSimpleClient.Button5Click(Sender: TObject);
var
Num3: INumberProp;
begin
// create a new temporary COM object
Num3 := CoNumberProp.Create;
Num3.Value := 100;
Num3.Increase;
ShowMessage ('Num3: ' + IntToStr (Num3.Value));
end;
procedure TFormSimpleClient.FormCreate(Sender: TObject);
begin
// create first object
Num1 := CoNumberProp.Create;
Num1.Value := SpinEdit1.Value;
Label1.Caption := 'Num1: ' + IntToStr (Num1.Value);
Button1.Enabled := True;
Button2.Enabled := True;
// create second object
Num2 := CoNumberProp.Create;
Label2.Caption := 'Num2: ' + IntToStr (Num2.Value);
Button3.Enabled := True;
Button4.Enabled := True;
end;
end. |
SimpleClient_MainForm.pas.dfm |
object FormSimpleClient: TFormSimpleClient
Left = 0
Top = 0
Caption = 'SimpleClient'
ClientHeight = 244
ClientWidth = 287
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 40
Top = 24
Width = 27
Height = 13
Caption = 'Num1'
end
object Label2: TLabel
Left = 168
Top = 24
Width = 27
Height = 13
Caption = 'Num2'
end
object SpinEdit1: TSpinEdit
Left = 40
Top = 48
Width = 73
Height = 22
MaxValue = 0
MinValue = 0
TabOrder = 0
Value = 22
end
object Button1: TButton
Left = 40
Top = 88
Width = 75
Height = 25
Caption = '&Change'
Enabled = False
TabOrder = 1
OnClick = Button1Click
end
object Button2: TButton
Left = 40
Top = 128
Width = 75
Height = 25
Caption = '&Next'
Enabled = False
TabOrder = 2
OnClick = Button2Click
end
object SpinEdit2: TSpinEdit
Left = 168
Top = 48
Width = 73
Height = 22
MaxValue = 0
MinValue = 0
TabOrder = 3
Value = 22
end
object Button3: TButton
Left = 168
Top = 88
Width = 75
Height = 25
Caption = 'C&hange'
Enabled = False
TabOrder = 4
OnClick = Button3Click
end
object Button4: TButton
Left = 168
Top = 128
Width = 75
Height = 25
Caption = 'N&ext'
Enabled = False
TabOrder = 5
OnClick = Button4Click
end
object Button5: TButton
Left = 88
Top = 176
Width = 105
Height = 25
Caption = 'Compute (Num3)'
TabOrder = 6
OnClick = Button5Click
end
end |
SimpleServer_TLB.pas |
unit SimpleServer_TLB;
// ************************************************************************ //
// WARNING
// -------
// The types declared in this file were generated from data read from a
// Type Library. If this type library is explicitly or indirectly (via
// another type library referring to this type library) re-imported, or the
// 'Refresh' command of the Type Library Editor activated while editing the
// Type Library, the contents of this file will be regenerated and all
// manual modifications will be lost.
// ************************************************************************ //
// $Rev: 17252 $
// File generated on 11/4/2008 12:33:17 AM from Type Library described below.
// ************************************************************************ //
// Type Lib: C:\Users\Marco\Documents\books2008\tiburon\sourcecode\08\SimpleServer\SimpleServer.dll (1)
// LIBID: {6D563F05-A924-4C69-91EB-FAC149485901}
// LCID: 0
// Helpfile:
// HelpString: SimpleServer Library
// DepndLst:
// (1) v2.0 stdole, (C:\Windows\system32\stdole2.tlb)
// ************************************************************************ //
{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
{$VARPROPSETTER ON}
{$ALIGN 4}
interface
uses Windows, ActiveX, Classes, Graphics, OleServer, StdVCL, Variants;
// *********************************************************************//
// GUIDS declared in the TypeLibrary. Following prefixes are used:
// Type Libraries : LIBID_xxxx
// CoClasses : CLASS_xxxx
// DISPInterfaces : DIID_xxxx
// Non-DISP interfaces: IID_xxxx
// *********************************************************************//
const
// TypeLibrary Major and minor versions
SimpleServerMajorVersion = 1;
SimpleServerMinorVersion = 0;
LIBID_SimpleServer: TGUID = '{6D563F05-A924-4C69-91EB-FAC149485901}';
IID_INumberProp: TGUID = '{4D24B32A-DE61-4EBE-AE53-6DF2D3DC80DA}';
CLASS_NumberProp: TGUID = '{BDC9A273-A973-4DB4-ADE7-8F0A49004D29}';
type
// *********************************************************************//
// Forward declaration of types defined in TypeLibrary
// *********************************************************************//
INumberProp = interface;
// *********************************************************************//
// Declaration of CoClasses defined in Type Library
// (NOTE: Here we map each CoClass to its Default Interface)
// *********************************************************************//
NumberProp = INumberProp;
// *********************************************************************//
// Interface: INumberProp
// Flags: (256) OleAutomation
// GUID: {4D24B32A-DE61-4EBE-AE53-6DF2D3DC80DA}
// *********************************************************************//
INumberProp = interface(IUnknown)
['{4D24B32A-DE61-4EBE-AE53-6DF2D3DC80DA}']
function Get_Value: Integer; safecall;
procedure Set_Value(New: Integer); safecall;
procedure Increase; safecall;
property Value: Integer read Get_Value write Set_Value;
end;
// *********************************************************************//
// The Class CoNumberProp provides a Create and CreateRemote method to
// create instances of the default interface INumberProp exposed by
// the CoClass NumberProp. The functions are intended to be used by
// clients wishing to automate the CoClass objects exposed by the
// server of this typelibrary.
// *********************************************************************//
CoNumberProp = class
class function Create: INumberProp;
class function CreateRemote(const MachineName: string): INumberProp;
end;
implementation
uses ComObj;
class function CoNumberProp.Create: INumberProp;
begin
Result := CreateComObject(CLASS_NumberProp) as INumberProp;
end;
class function CoNumberProp.CreateRemote(const MachineName: string): INumberProp;
begin
Result := CreateRemoteComObject(MachineName, CLASS_NumberProp) as INumberProp;
end;
end. |
HTML file generated by PasToWeb, a tool by Marco Cantù
Copyright 2008 Marco Cantù |
|