Works in D5.01... I am thinking it works the way you wanted... i can send
you the source if you want (and the exe).
unit GDBEdit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, DBCtrls, Buttons, DB;
type
TGDBEdit = class(TGroupBox)
private
{ Private declarations }
function GetDataSource : TDataSource;
procedure SetDataSource(Value : TDataSource);
function GetDataField : string;
procedure SetDataField(Value : string);
function GetPanelColor : TColor;
procedure SetPanelColor(Value : TColor);
protected
procedure WmSize(var Message : TMessage); message WM_SIZE;
procedure ClearField(Sender : TObject);
{ Protected declarations }
public
{ Public declarations }
DBEdit : TDBEdit;
ClearButton : TBitBtn;
Panel : TPanel;
constructor Create(AOwner : TComponent); override;
published
{ Published declarations }
property PanelColor : TColor read GetPanelColor write SetPanelColor;
property DataSource : TDataSource read GetDataSource write
SetDataSource;
property DataField : string read GetDataField write SetDataField;
end;
procedure Register;
implementation
procedure TGDBEdit.SetDataSource(Value : TDataSource);
begin
DBEdit.DataSource := Value;
if (Value = nil) then begin
ClearButton.Enabled := false;
end
else begin
ClearButton.Enabled := true;
end;
end;
function TGDBEdit.GetDataSource : TDataSource;
begin
Result := DBEdit.DataSource;
end;
procedure TGDBEdit.SetDataField(Value : string);
begin
DBEdit.DataField := Value;
if (Value = '') then begin
ClearButton.Enabled := false;
end
else begin
ClearButton.Enabled := true;
end;
end;
function TGDBEdit.GetDataField : string;
begin
Result := DBEdit.DataField;
end;
procedure TGDBEdit.SetPanelColor(Value : TColor);
begin
Panel.Color := Value;
end;
function TGDBEdit.GetPanelColor : TColor;
begin
Result := Panel.Color;
end;
procedure TGDBEdit.WmSize(var Message : TMessage);
begin
inherited;
DBEdit.Left := Self.Width - 35;
Self.Caption := IntToStr(DBEdit.Left);
ClearButton.Left := Self.Width - 29;
end;
procedure TGDBEdit.ClearField(Sender : TObject);
begin
{ if (DataSource <> nil) then begin
if (DataField <> '') then begin}
ShowMessage('Here I am');
DBEdit.DataSource.DataSet.FieldByName(DBEdit.DataField).Clear;
// end;
// end;
end;
constructor TGDBEdit.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
Width := Self.Width - 35;
Height := 45;
Color := clYellow;
Panel := TPanel.Create(Self);
Panel.Parent := Self;
Panel.Align := alClient;
Panel.BevelInner := bvNone;
Panel.BevelOuter := bvNone;
Panel.Caption := '';
Panel.Color := $00C0DCC0;
DBEdit := TDBEdit.Create(Self);
DBEdit.Parent := Panel;
DBEdit.Left := 4;
DBEdit.Top := 4;
DBEdit.Width := 65;
ClearButton := TBitBtn.Create(Self);
ClearButton.Parent := Panel;
ClearButton.Kind := bkCancel;
ClearButton.Caption := '';
ClearButton.Width := 21;
ClearButton.Height := 21;
ClearButton.Top := 4;
ClearButton.Left := Self.Width - 29;
if (ComponentState <> [csDesigning]) then begin
ClearButton.OnClick := ClearField;
end;
//ClearButton.Enabled := false;
end;
procedure Register;
begin
RegisterComponents('Freeware', [TGDBEdit]);
end;
end.
(Embedded
image moved [EMAIL PROTECTED]
to file: 20/10/2000 13:06
pic20767.pcx)
Please respond to [EMAIL PROTECTED]
To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
cc:
Subject: RE: [DUG]: Redrawing Components
Thankyou for that. I have since confirmed it works in Delphi 3
I now have the dubious task of trying to figure out why it doesn't work in
Delphi 5, unfortunately I have little choice about using Delphi 5.
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of [EMAIL PROTECTED]
> Sent: Thursday, 19 October 2000 15:02
> To: Multiple recipients of list delphi
> Subject: Re: [DUG]: Redrawing Components
>
>
>
> Works for me.
>
> Although I uncommented the inherited line in WMSize. You should call
> inherited first.
> Is the button supposed to be over the edit control? I can click
> the button
> and have the showmessage display.
>
> JED
>
> PS: Nice colors :-)
>
> < lots of stuff cut >
>
> ------------------------------------------------------------------
> ---------
> New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Paintbrush