unit ControlTextBoxErw;
interface
uses
System.Drawing, System.Collections, System.ComponentModel,
System.Windows.Forms, System.Data, System.Resources;
type
AssistClickHandler =
Procedure(sender: System.
Object; e: EventArgs);
TextBoxErw =
class(System.Windows.Forms.UserControl)
{$REGION 'Vom Designer verwalteter Code'}
strict private
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
components: System.ComponentModel.IContainer;
Panel1: System.Windows.Forms.Panel;
TextBox: System.Windows.Forms.TextBox;
AssistButton: System.Windows.Forms.Button;
LookUpButton: System.Windows.Forms.Button;
DrillDownButton: System.Windows.Forms.Button;
/// <summary>
/// Erforderliche Methode zur Unterstützung des Designers -
/// ändern Sie die Methode nicht mit dem Quelltext-Editor
/// </summary>
procedure InitializeComponent;
procedure Assist_Click(sender: System.
Object; e: System.EventArgs);
{$ENDREGION}
strict protected
procedure OnSizeChanged(e: EventArgs);
override;
procedure OnPaint(e: PaintEventArgs);
override;
/// <summary>
/// Ressourcen nach der Verwendung bereinigen
/// </summary>
procedure Dispose(Disposing: Boolean);
override;
private
{ Private-Deklarationen }
var fAssistClick: AssistClickHandler;
PropertyHatAssistButton: boolean;
PropertyHatLookUpButton: boolean;
PropertyHatDrillDownButton: boolean;
Procedure Zeichnen();
protected
Procedure OnAssistClick;
public
constructor Create;
published
property Text;
[Category('
Eigene Properties')]
[Description('
Control hat DrillDown-Button')]
property HatDrillDownButton: Boolean
read PropertyHatDrillDownButton
write PropertyHatDrillDownButton
default false;
[Category('
Eigene Properties')]
[Description('
Control hat Lookup-Button')]
property HatLookUpButton: Boolean
read PropertyHatLookUpButton
write PropertyHatLookUpButton
default false;
[Category('
Eigene Properties')]
[Description('
Control hat Assist-Button')]
property HatAssistButton: Boolean
read PropertyHatAssistButton
write PropertyHatAssistButton
default false;
[Category('
Eigene Ereignisse')]
[Description('
tritt auf wenn der Assist-Button gedrückt wird')]
property AssistClick: AssistClickHandler add fAssistClick remove fAssistclick;
end;
[assembly: RuntimeRequiredAttribute(TypeOf(TextBoxErw))]
implementation
uses
System.Globalization;
{$AUTOBOX ON}
{$REGION 'Vom Windows Form-Designer erzeugter Code'}
/// <summary>
/// Erforderliche Methode zur Unterstützung des Designers --
/// ändern Sie die Methode nicht mit dem Quelltext-Editor
/// </summary>
procedure TextBoxErw.InitializeComponent;
var
resources: System.Resources.ResourceManager;
begin
Self.components := System.ComponentModel.Container.Create;
resources := System.Resources.ResourceManager.Create(TypeOf(TextBoxErw));
Self.Panel1 := System.Windows.Forms.Panel.Create;
Self.LookUpButton := System.Windows.Forms.Button.Create(Self.components);
Self.AssistButton := System.Windows.Forms.Button.Create(Self.components);
Self.TextBox := System.Windows.Forms.TextBox.Create(Self.components);
Self.DrillDownButton := System.Windows.Forms.Button.Create(Self.components);
Self.Panel1.SuspendLayout;
Self.SuspendLayout;
//
// Panel1
//
Self.Panel1.BackColor := System.Drawing.SystemColors.Window;
Self.Panel1.BorderStyle := System.Windows.Forms.BorderStyle.Fixed3D;
Self.Panel1.Controls.Add(Self.LookUpButton);
Self.Panel1.Controls.Add(Self.AssistButton);
Self.Panel1.Controls.Add(Self.TextBox);
Self.Panel1.Controls.Add(Self.DrillDownButton);
Self.Panel1.Dock := System.Windows.Forms.DockStyle.Fill;
Self.Panel1.Location := System.Drawing.Point.Create(0, 0);
Self.Panel1.
Name := '
Panel1';
Self.Panel1.Size := System.Drawing.Size.Create(128, 21);
Self.Panel1.TabIndex := 0;
//
// LookUpButton
//
Self.LookUpButton.BackColor := System.Drawing.SystemColors.Control;
Self.LookUpButton.Image := (System.Drawing.Image(resources.GetObject('
Look' +
'
UpButton.Image')));
Self.LookUpButton.Location := System.Drawing.Point.Create(92, 0);
Self.LookUpButton.
Name := '
LookUpButton';
Self.LookUpButton.Size := System.Drawing.Size.Create(16, 16);
Self.LookUpButton.TabIndex := 2;
Self.LookUpButton.TabStop := False;
Self.LookUpButton.Visible := False;
//
// AssistButton
//
Self.AssistButton.BackColor := System.Drawing.SystemColors.Control;
Self.AssistButton.Image := (System.Drawing.Image(resources.GetObject('
Assi' +
'
stButton.Image')));
Self.AssistButton.Location := System.Drawing.Point.Create(108, 0);
Self.AssistButton.
Name := '
AssistButton';
Self.AssistButton.Size := System.Drawing.Size.Create(16, 16);
Self.AssistButton.TabIndex := 1;
Self.AssistButton.TabStop := False;
Self.AssistButton.Visible := False;
//
// TextBox
//
Self.TextBox.AutoSize := False;
Self.TextBox.BorderStyle := System.Windows.Forms.BorderStyle.None;
Self.TextBox.Location := System.Drawing.Point.Create(1, 1);
Self.TextBox.
Name := '
TextBox';
Self.TextBox.Size := System.Drawing.Size.Create(55, 20);
Self.TextBox.TabIndex := 0;
Self.TextBox.Text := '
TextBox';
//
// DrillDownButton
//
Self.DrillDownButton.BackColor := System.Drawing.SystemColors.Control;
Self.DrillDownButton.Image := (System.Drawing.Image(resources.GetObject('
D' +
'
rillDownButton.Image')));
Self.DrillDownButton.Location := System.Drawing.Point.Create(76, 0);
Self.DrillDownButton.
Name := '
DrillDownButton';
Self.DrillDownButton.Size := System.Drawing.Size.Create(16, 16);
Self.DrillDownButton.TabIndex := 2;
Self.DrillDownButton.TabStop := False;
Self.DrillDownButton.Visible := False;
//
// TextBoxErw
//
Self.BackColor := System.Drawing.SystemColors.HotTrack;
Self.Controls.Add(Self.Panel1);
Self.
Name := '
TextBoxErw';
Self.Size := System.Drawing.Size.Create(128, 21);
Self.Panel1.ResumeLayout(False);
Self.ResumeLayout(False);
end;
{$ENDREGION}
constructor TextBoxErw.Create;
begin
inherited Create;
//
// Erforderlich für die Unterstützung des Windows Forms-Designers
//
InitializeComponent;
//
// TODO: Fügen Sie nach dem Aufruf von InitializeComponent Konstruktorcode hinzu.
//
end;
procedure TextBoxErw.Assist_Click(sender: System.
Object; e: System.EventArgs);
begin
OnAssistClick();
end;
Procedure TextBoxErw.OnAssistClick;
begin;
if assigned(fAssistClick)
then
fAssistClick(self, EventArgs.Create);
end;
procedure TextBoxErw.OnSizeChanged(e: EventArgs);
begin;
Zeichnen();
inherited OnSizeChanged(e);
end;
procedure TextBoxErw.OnPaint(e: PaintEventArgs);
begin;
Zeichnen();
inherited OnPaint(e);
end;
procedure TextBoxErw.Zeichnen();
var FreieLinksBreite: integer;
begin;
FreieLinksBreite := self.Width-3;
if Self.PropertyHatDrillDownButton
then begin
FreieLinksBreite := FreieLinksBreite - self.DrillDownButton.Width;
self.DrillDownButton.Top := 0;
self.DrillDownButton.Left := FreieLinksBreite;
self.DrillDownButton.Height := self.Height-4;
self.DrillDownButton.Visible := true;
end;
if Self.PropertyHatLookUpButton
then begin
FreieLinksBreite := FreieLinksBreite - self.LookUpButton.Width;
self.LookUpButton.Top := 0;
self.LookUpButton.Left := FreieLinksBreite;
self.LookUpButton.Height := self.Height-4;
self.LookUpButton.Visible := true;
end;
if Self.PropertyHatAssistButton
then begin
FreieLinksBreite := FreieLinksBreite - self.AssistButton.Width;
self.AssistButton.Top := 0;
self.AssistButton.Left := FreieLinksBreite;
self.AssistButton.Height := self.Height-4;
self.AssistButton.Visible := true;
end;
TextBox.width := FreieLinksBreite-1;
end;
procedure TextBoxErw.Dispose(Disposing: Boolean);
begin
if Disposing
then
begin
if Components <>
nil then
Components.Dispose();
end;
inherited Dispose(Disposing);
end;
end.