Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   C++ Builder (https://www.clubdelphi.com/foros/forumdisplay.php?f=13)
-   -   Juntar dos componentes en una clase (https://www.clubdelphi.com/foros/showthread.php?t=83476)

DSK25 21-06-2013 19:55:26

Juntar dos componentes en una clase
 
Pues quiero crear una clase que derive del TPanel y que contenga un Panel y un listbox

TblPanel.h

Código:

//---------------------------------------------------------------------------
#ifndef TblPanelH
#define TblPanelH
//---------------------------------------------------------------------------
class TTblPanel : public TPanel
{
__published:
private:
    TTblPanel *TblPanel;
    TListBox *ListBox1;
    TPanel *Panel2;
public:
    __fastcall TTblPanel(TWinControl *Parent);
};
//---------------------------------------------------------------------------
#endif

TblPanel.cpp

Código:

//---------------------------------------------------------------------------
#include <vcl.h>
#include "TblPanel.h"
//---------------------------------------------------------------------------
__fastcall TTblPanel::TTblPanel(TWinControl *Parent)
    : TPanel(Owner)
{
    TTblPanel::Parent = Parent;
    TTblPanel::Height = 200;
    TTblPanel::Width = 160;
    TTblPanel::Visible = true;
    TTblPanel::Panel2->Caption = "yyy";
    TTblPanel::Panel2->Align = alTop;
    TTblPanel::ListBox1->Align = alClient;
}
//---------------------------------------------------------------------------

Al compilar me manda el error "Access violation address ...", alguien sabe en que fallo?

Ñuño Martínez 01-07-2013 18:00:44

Por lo que veo, fallas en que Panel2 no existe. Y posiblemente Listbox1 tampoco. Debes crear (o asignar la referencia) estos objetos antes de poder usarlos,


La franja horaria es GMT +2. Ahora son las 20:38:54.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi