AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Dynamische Programmierung 2 Fragen

Ein Thema von geskill · begonnen am 14. Dez 2007 · letzter Beitrag vom 14. Dez 2007
 
Benutzerbild von geskill
geskill

Registriert seit: 17. Feb 2007
Ort: NRW
420 Beiträge
 
Delphi 2010 Professional
 
#1

Dynamische Programmierung 2 Fragen

  Alt 14. Dez 2007, 14:38
Hi,
Ich habe mir die Dynamische Programmierung genauer unter die Lupe genommen, soweit zu gut, leider habe ich 2 Fragen bzw. Probleme.

Erstens möchte ich "SRKIBNewForm : TForm;", "SRKIBNewButton : TButton;", "SRKIBNewWebLabel : TLabel;" in eine PRIVATE deklaration auslagern, da sonst das keiner benutzen soll. Leider kommt dann immer ein Fehler beim erstellen.

Zweitens habe ich ein Problem was das OnClick verhalten auf einen dynamisch erzeugten Button regelt (im TSRKInfoBox.TButtons.Create), ich habe es bereits in einer TYPE deklaration geschafft, jedoch funktioniert es bei mit nicht in einer verschachtelten deklaration.

EDIT:
Ich habe mal eine Testumgebung mit hochgeladen ist womit das ganze für euch vllt. einfacher ist...

Delphi-Quellcode:
unit uSRKInfoBox;

interface

  USES
    Windows, Graphics, StdCtrls, Forms, Controls, ShellApi;

  TYPE TSRKInfoBox = class
       PRIVATE
  TYPE TButtons = record
       PRIVATE

       PROCEDURE SetCaption(ACaption:String='Close');
       FUNCTION GetCaption:String;
       PROCEDURE SetOnClick(Sender: TObject);
       PROCEDURE SetVisible(AVisible:Boolean=TRUE);
       FUNCTION GetVisible:Boolean;
       PUBLIC
       PROCEDURE Create;
       PROPERTY Caption:String READ GetCaption WRITE SetCaption;
       PROCEDURE Show;
       PROPERTY Visible:Boolean READ GetVisible WRITE SetVisible;
       END;


       PROCEDURE SetCaption(ACaption:String);
       PROCEDURE SetColor(Color:TColor);
       PROCEDURE SetHeight(AHeight:Integer);
       PROTECTED
       FFTButtons : TButtons;
       PUBLIC
       PROCEDURE Create;
       PROPERTY Caption:String WRITE SetCaption;
       PROPERTY Color:TColor WRITE SetColor;
       PROCEDURE Free;
       PROPERTY Height:Integer WRITE SetHeight;


       PROCEDURE Show;
       PROPERTY CloseButton:TButtons READ FFTButtons;
       END;



  VAR
    SRKIB:TSRKInfoBox;

    SRKIBNewForm : TForm;
    SRKIBNewButton : TButton;
    SRKIBNewWebLabel : TLabel;

implementation

PROCEDURE TSRKInfoBox.Create;
BEGIN
  SRKIBNewForm := TForm.Create(Application.Owner);
  WITH SRKIBNewForm DO BEGIN
  BorderIcons := [biSystemMenu];
  BorderStyle := bsToolWindow;
  Position := poDesktopCenter;
  END;
END;

PROCEDURE TSRKInfoBox.SetCaption(ACaption:String);
BEGIN
  SRKIBNewForm.Caption := ACaption;
END;

PROCEDURE TSRKInfoBox.SetColor(Color:TColor);
BEGIN
  SRKIBNewForm.Color := Color;
END;

PROCEDURE TSRKInfoBox.Free;
BEGIN
  SRKIBNewForm.Free;
END;

PROCEDURE TSRKInfoBox.SetHeight(AHeight:Integer);
BEGIN
  SRKIBNewForm.Height := AHeight;
END;

PROCEDURE TSRKInfoBox.Show;
BEGIN
  SRKIBNewForm.Show;
END;

///////////////////////////////////////////////////////////////////////////

PROCEDURE TSRKInfoBox.TButtons.Create;
BEGIN
  SRKIBNewButton := TButton.Create(SRKIBNewForm);
  SRKIBNewButton.Parent := SRKIBNewForm;
  //-------------------------------------------\\
  SRKIBNewButton.OnClick := SRKIB.FFTButtons.SetOnClick;
  SRKIBNewButton.OnClick := SRKIB.TButtons.SetOnKlick;
  //-------------------------------------------\\
END;

PROCEDURE TSRKInfoBox.TButtons.SetCaption(ACaption:String='Close');
BEGIN
  SRKIBNewButton.Caption := ACaption;
END;

FUNCTION TSRKInfoBox.TButtons.GetCaption:String;
BEGIN
  result := SRKIBNewButton.Caption;
END;

PROCEDURE TSRKInfoBox.TButtons.SetOnClick(Sender: TObject);
BEGIN
  SRKIBNewButton.Free;
  SRKIBNewForm.Free;
END;

PROCEDURE TSRKInfoBox.TButtons.SetVisible(AVisible:Boolean=TRUE);
BEGIN
  SRKIBNewButton.Visible := AVisible;
END;

FUNCTION TSRKInfoBox.TButtons.GetVisible:Boolean;
BEGIN
  result := SRKIBNewButton.Visible;
END;

PROCEDURE TSRKInfoBox.TButtons.Show;
BEGIN
  SRKIBNewButton.Show;
END;
MFG
geskill

PS: Das Dynamische Feld wird von einem Formular gestartet, wobei folgende Proceduren benutzt werden

Delphi-Quellcode:
  SRKIB.Create;
  SRKIB.Caption := 'AAA';
  SRKIB.CloseButton.Create;
  SRKIB.CloseButton.Caption := 'a';
  SRKIB.CloseButton.Show;
  SRKIB.Show;
Angehängte Dateien
Dateityp: zip testumgebung_114.zip (226,0 KB, 3x aufgerufen)
Sebastian
  Mit Zitat antworten Zitat
 


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 14:17 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz