terça-feira, 14 de março de 2017

Como criar um TPanel dentro de outro TPanel - Borland BCB6

Crie uma aplicação com o BCB6

No arquivo.cpp escreva:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
   : TForm(Owner)
{

 this->teste1 = new TPanel(this);
 teste1->Parent = this;
 teste1->Caption = "painel1";
 teste1->Width = 300;
 teste1->Height = 400;
 teste1->Left = 500;


 this->teste2 = new TPanel(this->teste1);
 this->teste2->Parent = this->teste1;
 this->teste2->Caption = "painel2";
 //this->teste2->Align = alTop;
 //teste1->Align = alTop;
}
//---------------------------------------------------------------------------



No Arquivo.h, escreva:

//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components

private: // User declarations
public: // User declarations
   __fastcall TForm1(TComponent* Owner);
        TPanel *teste1;
        TPanel *teste2;

};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

Nenhum comentário:

Postar um comentário