AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

problem bei einer Komponentenentwicklung

Ein Thema von bergamo34 · begonnen am 20. Apr 2004
Antwort Antwort
bergamo34

Registriert seit: 23. Jan 2004
19 Beiträge
 
#1

problem bei einer Komponentenentwicklung

  Alt 20. Apr 2004, 04:43
habe Probleme beim Erstellen einer neuen Komponente aus TEdit und TDBGrid.

Es kommt folgende Fehlermeldung wenn Spalten für die SubKomponente 'GridList' eingestellt sind.

Fehlermeldung:
..EReadError...'Eigenschaft GridList existiert nicht'.

kann jemand mir sagen, wo ich den Fehler mache?


Code:
unit EditLookList;

interface

uses
  Windows, Controls, SysUtils, Classes, StdCtrls, DBGrids, DBCtrls,
  Messages, Forms, Menus, Graphics;

type
{-- TBoundGrid -----------}
  TBoundGrid = class(TDBGrid)
  private
    { Private-Deklarationen }
  protected
    { Protected-Deklarationen }
  public
    constructor Create(AOwner: TComponent); override;
    { Public-Deklarationen }
  published
    { Published-Deklarationen }
    property Options;
  end;

  TGridPosition = (lpAbove, lpBelow, lpLeft, lpRight);

{-- TCustomEditList -----------}
  TCustomEditList = class(TEdit)
  private
    FGrid: TBoundGrid;
    FGridPosition: TGridPosition;
    FGridSpacing: Integer;

    procedure SetGridPosition(const Value: TGridPosition);
    procedure SetGridSpacing(const Value: Integer);
    { Private-Deklarationen }
  protected
    procedure SetParent(AParent: TWinControl); override;
    procedure Notification(AComponent: TComponent; Operation: TOperation); override;
    procedure CMEnter(var Message: TCMEnter); message CM_ENTER;
    procedure CMExit(var Message: TCMExit); message CM_EXIT;
    { Protected-Deklarationen }
  public
    constructor Create(AOwner: TComponent); override;
    procedure SetBounds(ALeft: Integer; ATop: Integer; AWidth: Integer; AHeight: Integer); override;
    procedure SetupInternalGrid;
    property Grid: TBoundGrid read FGrid;
    { Public-Deklarationen }
  published
    property GridPosition: TGridPosition read FGridPosition write SetGridPosition;
    property GridSpacing: Integer read FGridSpacing write SetGridSpacing;
    { Published-Deklarationen }
  end;


  TEditLookList = class(TCustomEditList)
  private
    { Private-Deklarationen }
  protected
    { Protected-Deklarationen }
  public
    { Public-Deklarationen }
  published
    property GridPosition default lpAbove;
    property GridSpacing default 3;
    property Grid;
    { Published-Deklarationen }
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Beispiele', [TEditLookList]);
end;

{ TBoundGrid }

constructor TBoundGrid.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Name := 'SubGrid'; { do not localize }
  SetSubComponent(True);
  if Assigned(AOwner) then
    Caption := AOwner.Name;

end;


{ TCustomEditList }

procedure TCustomEditList.CMEnter(var Message: TCMEnter);
begin
  inherited;
  if not FGrid.Visible then
    FGrid.Visible := True;

end;

procedure TCustomEditList.CMExit(var Message: TCMExit);
begin
  inherited;
//  if FGrid.Visible then
//    FGrid.Visible := False;
   
end;

constructor TCustomEditList.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FGridPosition := lpBelow;
  FGridSpacing := 3;
  SetupInternalGrid;

end;

procedure TCustomEditList.Notification(AComponent: TComponent;
  Operation: TOperation);
begin
  inherited Notification(AComponent, Operation);
  if (AComponent = FGrid) and (Operation = opRemove) then
    FGrid := nil;

end;

procedure TCustomEditList.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
begin
  inherited SetBounds(ALeft, ATop, AWidth, AHeight);
  SetGridPosition(FGridPosition);

end;

procedure TCustomEditList.SetGridPosition(const Value: TGridPosition);
var
  P: TPoint;
begin
  if FGrid = nil then exit;
  FGridPosition := Value;
  case Value of
    lpAbove: P := Point(Left, Top - FGrid.Height - FGridSpacing);
    lpBelow: P := Point(Left, Top + Height + FGridSpacing);
    lpLeft : P := Point(Left - FGrid.Width - FGridSpacing,
                    Top + ((Height - FGrid.Height) div 2));
    lpRight: P := Point(Left + Width + FGridSpacing,
                    Top + ((Height - FGrid.Height) div 2));
  end;
  FGrid.SetBounds(P.x, P.y, FGrid.Width, FGrid.Height);

end;

procedure TCustomEditList.SetGridSpacing(const Value: Integer);
begin
  FGridSpacing := Value;
  SetGridPosition(FGridPosition);

end;

procedure TCustomEditList.SetParent(AParent: TWinControl);
begin
  inherited SetParent(AParent);
  if FGrid = nil then exit;
  FGrid.Parent := AParent;
  FGrid.Visible := True;

end;

procedure TCustomEditList.SetupInternalGrid;
begin
  if Assigned(FGrid) then exit;
  FGrid := TBoundGrid.Create(Self);
  FGrid.FreeNotification(Self);

end;




end.
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:33 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz