Eigene visuelle-Klasse



  • Hallo, ich möchte mir eine eigene virtuelle Klasse erstellen. Diese soll von TPanel abgeleitet werden.
    Ich habe jetzt allerdings das Problem, das ich es nicht hinbekomme, dass das erzeugte Objekt auch angezeigt wird. Das ist bestimmt nur ein generelles Problem und ich sehe den Wald vor lauter Bäumen nicht.
    Was habe ich vergessen bzw muss noch gemacht werden.
    Getestet mit dem C++Builder 2006.

    //
    //
    // Die Header-Datei
    //---------------------------------------------------------------------------
    
    #ifndef MyOwnCompoH
    #define MyOwnCompoH
    //---------------------------------------------------------------------------
    #include <SysUtils.hpp>
    #include <Classes.hpp>
    #include <Controls.hpp>
    #include <Buttons.hpp>
    //---------------------------------------------------------------------------
    class MyOwnCompo : public TPanel
    {
    private:
        TBitBtn*    _bitBtn1;
    protected:
    public:
        __fastcall MyOwnCompo(TComponent* Owner);
        void __fastcall create();
    __published:
    };
    //---------------------------------------------------------------------------
    #endif
    //
    //
    // Die Implementierung
    //---------------------------------------------------------------------------
    __fastcall MyOwnCompo::MyOwnCompo(TComponent* Owner)
        : TPanel(Owner),
        _bitBtn1(NULL)
    {
        TBitBtn* _bitBtn1 = new TBitBtn(this);
        _bitBtn1->Parent = this;
        _bitBtn1->Caption = "Hallo";
        _bitBtn1->Visible = true;
        this->Visible = true;
    }
    
    //
    // So rufe ich die ganze Sache auf.
    //
        MyOwnCompo* myOwnCompo = new MyOwnCompo(Form1); // Eigentlich hatte ich erwartet, dass dies bereits reichen sollte !!
    
        myOwnCompo->Top  = 20;
        myOwnCompo->Left = 20;
        myOwnCompo->Width = 100;
        myOwnCompo->Height = 50;
    


  • Hallo,
    unter

    MyOwnCompo* myOwnCompo = new MyOwnCompo(Form1);
    

    mal

    myOwnCompo->Parent = this;
    

    versucht?



  • So läuft es.
    Besten dank!

    oldmanII


Anmelden zum Antworten