home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Programming Unleashed
/
Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso
/
chap32
/
cli-serv
/
mainc.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1995-03-20
|
3KB
|
121 lines
unit Mainc;
{ Program copyright (c) 1995 by Charles Calvert }
{ Project Name: CLI-SERV }
{
Every call to LoadResource needs to be followed
by a call to FreeResource. Also, LockResource is
paired with UnLockResource. I provide examples
below that demonstrate how this works.
}
interface
uses
SysUtils, WinTypes, WinProcs,
Messages, Classes, Graphics,
Controls, Forms, Dialogs,
DdeMan, StdCtrls, ExtCtrls,
Buttons, Menus;
type
TClientOne = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Conv1: TDdeClientConv;
Client1: TDdeClientItem;
Client2: TDdeClientItem;
Client3: TDdeClientItem;
Poke1: TBitBtn;
Poke2: TBitBtn;
Poke3: TBitBtn;
MainMenu1: TMainMenu;
Options1: TMenuItem;
Clear1: TMenuItem;
Close1: TMenuItem;
procedure Client1Change(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Poke1Click(Sender: TObject);
procedure Poke2Click(Sender: TObject);
procedure Poke3Click(Sender: TObject);
procedure Clear1Click(Sender: TObject);
procedure Close1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
Resource: THandle;
public
{ Public declarations }
end;
var
ClientOne: TClientOne;
implementation
{$R *.DFM}
{$R MILTON1.RES}
procedure TClientOne.Client1Change(Sender: TObject);
begin
Label1.Caption := Client1.Text;
Label4.Caption := Client2.Text;
Label6.Caption := Client3.Text;
end;
procedure TClientOne.FormCreate(Sender: TObject);
begin
Client1.DDEItem := 'DDEItem1';
Client2.DDEItem := 'DDEItem2';
Client3.DDEItem := 'DDEItem3';
Resource := LoadResource(hInstance,
FindResource(hInstance, 'Milton', 'TEXT'));
end;
procedure TClientOne.FormDestroy(Sender: TObject);
begin
FreeResource(Resource);
end;
procedure TClientOne.Poke1Click(Sender: TObject);
begin
Conv1.PokeData('DDEItem1', 'Sambo');
end;
procedure TClientOne.Poke2Click(Sender: TObject);
var
S: string;
SPtr: array[0..200] of Char;
begin
S := '';
InputQuery('Talk to a DDE Server', 'Enter Data to Poke', S);
Conv1.PokeData('DDEItem2', StrPCopy(SPtr, S));
end;
procedure TClientOne.Poke3Click(Sender: TObject);
var
Poem: PChar;
begin
Poem := PChar(LockResource(Resource));
Conv1.PokeData('DDEItem3', Poem);
UnLockResource(Resource);
end;
procedure TClientOne.Clear1Click(Sender: TObject);
begin
Conv1.ExecuteMacro('Clear', True);
end;
procedure TClientOne.Close1Click(Sender: TObject);
begin
Conv1.ExecuteMacro('Close', True);
end;
end.