unit ChatSystem;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants,
System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs, IdContext,
Vcl.ComCtrls,
Vcl.StdCtrls,
IdCustomTCPServer, IdTCPServer, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient,
Vcl.Menus,
Vcl.ExtCtrls, mmSystem, ClipBrd, User, Contnrs,
Data.DB, Datasnap.DBClient, Datasnap.Win.MConnect, Datasnap.Win.SConnect,
Vcl.OleCtrls, SHDocVw, JvExStdCtrls, JvRichEdit, ShellApi;
procedure renderLabels;
procedure addButton(id: Integer; Text:
String);
procedure addProgessbar(id: Integer);
procedure addImage(Text:
String);
procedure addText(Text:
String);
procedure addUserText(Text:
String);
procedure newMessage;
procedure Create;
implementation
uses Main, Optionen, Aufnahme, Beitreten, Erstellen, Favoriten, Feld, Player,
FileSystem;
var
Label_Create: TLabel;
Image_Create: TImage;
Progressbar_Create: TProgressBar;
Button_Create: TButton;
current_Height : Integer;
procedure Create;
begin
end;
procedure newMessage;
begin
renderLabels;
Form1.ScrollBar1.Position := current_Height - Form1.ScrollBar1.PageSize;
renderLabels;
end;
procedure renderLabels;
var
zahl: Integer;
begin
current_Height := 0;
for zahl := 0
to Form1.Text_Objects.count - 1
do
begin
case (Form1.Text_Objects[zahl]
as TComponent).Tag
of
0:
begin
// Label
(Form1.Text_Objects[zahl]
as TLabel).Top := current_Height -
Form1.ScrollBar1.Position;
current_Height := current_Height +
(Form1.Text_Objects[zahl]
as TLabel).Height;
end;
1:
begin
// Ausrechnen der Größe
(Form1.Text_Objects[zahl]
as TImage).Height :=
Form1.Panel1.Height
div 3;
(Form1.Text_Objects[zahl]
as TImage).Width :=
(Form1.Text_Objects[zahl]
as TImage)
.Picture.Width
div ((Form1.Text_Objects[zahl]
as TImage)
.Picture.Height
div (Form1.Text_Objects[zahl]
as TImage).Height);
// Ausrechen der Position
(Form1.Text_Objects[zahl]
as TImage).Top := current_Height -
Form1.ScrollBar1.Position;
current_Height := current_Height +
(Form1.Text_Objects[zahl]
as TImage).Height;
end;
2:
begin
// Progressbar
(Form1.Text_Objects[zahl]
as TProgressBar).Top := current_Height -
Form1.ScrollBar1.Position;
current_Height := current_Height +
(Form1.Text_Objects[zahl]
as TProgressBar).Height;
end;
3:
begin
// button
(Form1.Text_Objects[zahl]
as TButton).Top := current_Height -
Form1.ScrollBar1.Position;
current_Height := current_Height +
(Form1.Text_Objects[zahl]
as TButton).Height;
end;
end;
end;
current_Height := current_Height + 10;
if Form1.Panel1.Height < current_Height
then
begin
Form1.ScrollBar1.Max := current_Height;
Form1.ScrollBar1.PageSize := Form1.Panel1.Height;
Form1.ScrollBar1.Enabled := true;
end
else
begin
Form1.ScrollBar1.Enabled := false;
end;
Application.ProcessMessages;
end;
procedure addUserText(Text:
String);
begin
Label_Create := TLabel.Create(Form1.Panel1);
Label_Create.Parent := Form1.Panel1;
Label_Create.Caption := Text;
Label_Create.Top := 0;
Label_Create.Left := 0;
Label_Create.Autosize := false;
Label_Create.Font.size := 13;
Label_Create.Width := Form1.Panel1.Width;
Label_Create.Height := 20;
Label_Create.Font.Color := clHotLight;
Label_Create.Tag := 0;
Label_Create.OnMouseDown := Form1.onMouseClick;
Label_Create.Cursor := crHandPoint;
Form1.Text_Objects.Add(Label_Create);
//newMessage;
end;
procedure addText(Text:
String);
begin
Label_Create := TLabel.Create(Form1.Panel1);
Label_Create.Parent := Form1.Panel1;
Label_Create.Caption := Text;
Label_Create.Top := 0;
Label_Create.Left := 10;
Label_Create.Autosize := true;
Label_Create.Tag := 0;
Label_Create.OnMouseEnter := Form1.onMouseOver;
Label_Create.OnMouseLeave := Form1.onMouseOut;
Form1.Text_Objects.Add(Label_Create);
newMessage;
end;
procedure onMouseOver(Sender: TObject);
begin
case (Sender
as TComponent).Tag
of
0:
(Sender
as TLabel).Font.Style := (Sender
as TLabel).Font.Style + [fsBold];
end;
renderLabels;
end;
procedure onMouseOut(Sender: TObject);
begin
case (Sender
as TComponent).Tag
of
0:
(Sender
as TLabel).Font.Style := (Sender
as TLabel).Font.Style - [fsBold];
end;
renderLabels;
end;
procedure addImage(Text:
String);
begin
Image_Create := TImage.Create(Form1.Panel1);
Image_Create.Parent := Form1.Panel1;
Image_Create.Picture.LoadFromFile(Text);
Image_Create.Height := 150;
Image_Create.Width := Image_Create.Picture.Width
div
(Image_Create.Picture.Height
div Image_Create.Height);
Image_Create.Stretch := true;
Image_Create.Top := 0;
Image_Create.Left := 10;
Image_Create.Tag := 1;
Image_Create.OnMouseDown := Form1.onMouseClick;
Image_Create.DragMode := dmAutomatic;
Form1.Text_Objects.Add(Image_Create);
newMessage;
end;
procedure addProgessbar(id: Integer);
begin
Progressbar_Create := TProgressBar.Create(Form1.Panel1);
Progressbar_Create.Parent := Form1.Panel1;
Progressbar_Create.Left := 10;
Progressbar_Create.Top := 0;
Progressbar_Create.Max := 100;
Progressbar_Create.Position := 0;
Progressbar_Create.Height := 20;
Progressbar_Create.Width := 100;
Progressbar_Create.Tag := 2;
Progressbar_Create.MarqueeInterval := id;
Form1.Text_Objects.Add(Progressbar_Create);
newMessage;
end;
procedure addButton(id: Integer; Text:
String);
begin
Button_Create := TButton.Create(Form1.Panel1);
Button_Create.Parent := Form1.Panel1;
Button_Create.Caption := Text;
Button_Create.Left := 10;
Button_Create.Top := 0;
// Button_Create.Height := Form1.Canvas.TextHeight(Text) + 10;
// Button_Create.Width := Form1.Canvas.TextWidth(Text) + 10;
Button_Create.Tag := 3;
// Button_Create.TBDockHeight := id;
Form1.Text_Objects.Add(Button_Create);
newMessage;
end;
end.