Marco Web Center |
Home: Code Repository: Mastering Delphi 5Project CLIENT1
Project StructureCLIENT1.DPRprogram Client1; uses Forms, Client1Form in 'Client1Form.pas' {Form1}; {$R *.RES} begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end. CLIENT1FORM.PASunit Client1Form; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ScktComp; type TForm1 = class(TForm) ClientSocket1: TClientSocket; EditMsg: TEdit; btnSend: TButton; cbActivate: TCheckBox; EditServer: TEdit; Server: TLabel; Label1: TLabel; procedure btnSendClick(Sender: TObject); procedure ClientSocket1Connect(Sender: TObject; Socket: TCustomWinSocket); procedure ClientSocket1Disconnect(Sender: TObject; Socket: TCustomWinSocket); procedure cbActivateClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.btnSendClick(Sender: TObject); begin ClientSocket1.Socket.SendText (EditMsg.Text); end; procedure TForm1.ClientSocket1Connect(Sender: TObject; Socket: TCustomWinSocket); begin Caption := 'Connected'; end; procedure TForm1.ClientSocket1Disconnect(Sender: TObject; Socket: TCustomWinSocket); begin Caption := 'Disconnected'; end; procedure TForm1.cbActivateClick(Sender: TObject); begin if not ClientSocket1.Active then ClientSocket1.Address := EditServer.Text; ClientSocket1.Active := cbActivate.Checked; end; end. CLIENT1FORM.DFMobject Form1: TForm1 Left = 197 Top = 114 Width = 304 Height = 202 Caption = 'Client' Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = True PixelsPerInch = 96 TextHeight = 13 object Server: TLabel Left = 32 Top = 16 Width = 84 Height = 13 Caption = 'Server IP address' end object Label1: TLabel Left = 32 Top = 80 Width = 43 Height = 13 Caption = 'Message' end object EditMsg: TEdit Left = 32 Top = 96 Width = 121 Height = 21 TabOrder = 0 Text = 'Hello' end object btnSend: TButton Left = 184 Top = 96 Width = 75 Height = 25 Caption = '&Send' TabOrder = 1 OnClick = btnSendClick end object cbActivate: TCheckBox Left = 184 Top = 32 Width = 97 Height = 17 Caption = '&Activate' TabOrder = 2 OnClick = cbActivateClick end object EditServer: TEdit Left = 32 Top = 32 Width = 121 Height = 21 TabOrder = 3 Text = '222.1.1.2' end object ClientSocket1: TClientSocket Active = False Address = '222.1.1.1' ClientType = ctNonBlocking Port = 50 OnConnect = ClientSocket1Connect OnDisconnect = ClientSocket1Disconnect Left = 112 Top = 120 end end
|
||
© Copyright Marco Cantù, 1995-2020, All rights reserved |