unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls, ExtCtrls, ScktComp, XPMan;
type TEigenschaften =
Record // Speichert die Eigenschaften einer Zelle
Farbe : TColor;
// Hintergrundfarbe
Schrift : TFont;
// Schrift
end;
type
TForm1 =
class(TForm)
Panel1: TPanel;
Button1: TButton;
Edit2: TEdit;
Button2: TButton;
Memo2: TMemo;
BitBtn1: TBitBtn;
Button3: TButton;
Button4: TButton;
XPManifest1: TXPManifest;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
ComboBox1: TComboBox;
Label2: TLabel;
Button5: TButton;
FontDialog1: TFontDialog;
ClientSocket1: TClientSocket;
ServerSocket1: TServerSocket;
ComboBox2: TComboBox;
Edit1: TEdit;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Edit2KeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
procedure Button5Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
Server:TServerSocket;
Client:TClientSocket;
MSG:
String;
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var i: integer;
begin
for i:=0
to ComponentCount-1
do
if Components[i]
is TPanel
then (Components[i]
as TPanel).ParentBackground:=false;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Server.Open;
try
Client.Socket.SendText((Edit1.Text)+'
: '+Edit2.Text);
Panel4.Caption:= ('
Gesendet an: ')+ ComboBox1.Text;
Panel4.Visible:= True;
Memo2.Lines.Add((Edit1.Text)+'
: '+Edit2.Text);
Edit2.Clear;
Edit2.Repaint;
except
Showmessage('
Erst mit IP Verbinden');
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Client:= TClientSocket.Create(Form1);
try
Panel3.Caption:= ('
Verbunden mit: ')+ ComboBox1.Text;
Client.Port:= (Combobox2.ItemIndex);
Client.Host:= (ComboBox1.Text);
Client.Open;
Panel3.Visible:= True;
Panel2.Visible:= False;
except
Client.Free;
Showmessage('
Client Fehler');
end;
end;
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
MSG:= Socket.ReceiveText;
Memo2.Lines.Add(
{(Socket.LocalHostEdit1.Text)+': '+}MSG);
Panel4.Visible:= True;
Panel4.Caption:= ('
Gesendet an: ')+ ComboBox1.Text;
Edit2.Font:= FontDialog1.Font;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Memo2.Clear;
end;
procedure TForm1.Edit2KeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
If key = VK_return
then
Button2.Click;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
FontDialog1.Execute;
Edit2.Font:= FontDialog1.Font;
Edit2.repaint;
Memo2.Font:= FontDialog1.Font;
Memo2.repaint;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
Server.Free;
Client.Free;
Panel2.Visible:= True;
Panel3.Visible:= False;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Server:= TServerSocket.Create(Form1);
try
Server.Port:= (Combobox2.ItemIndex);
Server.Open;
Server.OnClientRead:= ServerSocket1ClientRead;
except
Server.Free;
Showmessage('
Server Fehler');
end;
end;
end.