Ver Mensaje Individual
  #9  
Antiguo 06-12-2017
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Reputación: 11
aguml Va por buen camino
Asi lo tengo ahora mismo:
El .h del Form:
Código PHP:
//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <Graphics.hpp>
#include "MyPanelClear.h"
#include "MyGroupBoxClear.h"
#include "MyRadioGroupClear.h"
#include "MyCheckBoxClear.h"
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:    // IDE-managed Components
    
TImage *Image1;
    
TButton *btShowPanelClear;
    
TButton *btShowGroupBoxClear;
    
TButton *btShowRadioGroup;
    
void __fastcall btShowPanelClearClick(TObject *Sender);
    
void __fastcall btShowGroupBoxClearClick(TObject *Sender);
    
void __fastcall btShowRadioGroupClick(TObject *Sender);
    
void __fastcall FormCreate(TObject *Sender);
    
void __fastcall FormClose(TObject *SenderTCloseAction &Action);
private:    
// User declarations
    
TPanelClear *pc;
    
TGroupBoxClear *gbc;
    
TCheckBoxClear *cbc1;
    
TRadioGroupClear *rgc;
public:        
// User declarations
    
__fastcall TForm1(TComponentOwner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif 
El .cpp del Form:
Código PHP:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

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

void __fastcall TForm1::btShowPanelClearClick(TObject *Sender)
{
  if(
pc != NULL)
    
delete pc;

  
pc = new TPanelClear(this);
  
pc->Left    5;
  
pc->Top     10;
  
pc->Height  130;
  
pc->Width   175;
  
pc->Name    "PanelClear1";
  
pc->Caption pc->Name;
  
pc->Parent  this;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::btShowGroupBoxClearClick(TObject *Sender)
{
    if(
gbc != NULL)
        
delete gbc;
    
gbc = new TGroupBoxClear(this);
    
gbc->Left    185;
    
gbc->Top     5;
    
gbc->Height  135;
    
gbc->Width   200;
    
gbc->Name    "GroupBoxClear1";
    
gbc->Caption gbc->Name;
    
gbc->Parent  this;

    
//No se crea dentro del GroupBoxClear
    
if(cbc1 != NULL)
        
delete cbc1;
        
    
cbc1 = new TCheckBoxClear(this);
    
cbc1->Left 10;
    
cbc1->Top 10;
    
cbc1->Name "CheckBox1";
    
cbc1->Caption cbc1->Name;
    
cbc1->Parent gbc;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::btShowRadioGroupClick(TObject *Sender)
{
    if(
rgc != NULL)
        
delete rgc;

    
rgc = new TRadioGroupClear(this);
    
rgc->Left    5;
    
rgc->Top     150;
    
rgc->Height  130;
    
rgc->Width   175;
    
rgc->Name    "RadioGroupClear1";
    
rgc->Caption rgc->Name;
    
rgc->Parent  this;
    
rgc->Items->Add("opcion1");
    
rgc->Items->Add("opcion2");
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
    
pc=NULL;
    
gbc=NULL;
    
cbc1=NULL;
    
rgc=NULL;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormClose(TObject *SenderTCloseAction &Action)
{
    if(
rgc != NULL)
        
delete rgc;
    if(
gbc != NULL)
        
delete gbc;
    if(
cbc1 != NULL)
        
delete cbc1;
    if(
pc != NULL)
        
delete pc;
}
//--------------------------------------------------------------------------- 
El .h del TPanelClear:
Código PHP:
#ifndef MyPanelClearH
#define MyPanelClearH
//---------------------------------------------------------------------------
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TPanelClear : public TPanel {
protected:
    
void __fastcall CreateParamsTCreateParams &Params );
    
void __fastcall Paint();
public:
    
__fastcall TPanelClearTComponent *Owner );
};
//---------------------------------------------------------------------------
#endif 
el .cpp del TPanelClear:
Código PHP:
#include "MyPanelClear.h"
//---------------------------------------------------------------------------

__fastcall TPanelClear::TPanelClearTComponent *Owner ) : TPanelOwner ) {
    
TPanel::TPanelOwner );
}
//---------------------------------------------------------------------------

void __fastcall TPanelClear::CreateParamsTCreateParams &Params ) {
    
TPanel::CreateParamsParams );
    
Params.ExStyle |= WS_EX_TRANSPARENT;
}
//---------------------------------------------------------------------------

void __fastcall TPanelClear::Paint() {
    
HDC DC   Canvas->Handle;
    
TRect R  ClientRect;
    
Graphics::TBitmap *BM = new Graphics::TBitmap;
    try {
      
BM->Height Height;
      
BM->Width  Width;
      
Canvas->Handle BM->Canvas->Handle;
      
TPanel::Paint();
      
Canvas->Handle DC;
      
Canvas->Brush->Style =  bsClear;
      
Canvas->BrushCopy(RBMRColor);
    }
    
__finally {
      
delete BM;
    }
}
//--------------------------------------------------------------------------- 
El .h del TGroupBoxClear:
Código PHP:
#ifndef MyGroupBoxClearH
#define MyGroupBoxClearH
//---------------------------------------------------------------------------
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TGroupBoxClear : public TGroupBox {
protected:
    
void __fastcall CreateParamsTCreateParams &Params );
    
void __fastcall Paint();
public:
    
__fastcall TGroupBoxClearTComponent *Owner );
};
//---------------------------------------------------------------------------
#endif 
El .cpp del TGroupBoxClear:
Código PHP:
#include "MyGroupBoxClear.h"
//---------------------------------------------------------------------------

__fastcall TGroupBoxClear::TGroupBoxClearTComponent *Owner ) : TGroupBoxOwner ) {
    
TGroupBox::TGroupBoxOwner );
}
//---------------------------------------------------------------------------

void __fastcall TGroupBoxClear::CreateParamsTCreateParams &Params ) {
    
TGroupBox::CreateParamsParams );
    
Params.ExStyle |= WS_EX_TRANSPARENT;
}
//---------------------------------------------------------------------------

void __fastcall TGroupBoxClear::Paint() {
    
HDC DC   Canvas->Handle;
    
TRect R  ClientRect;
    
Graphics::TBitmap *BM = new Graphics::TBitmap;
    try {
      
BM->Height Height;
      
BM->Width  Width;
      
Canvas->Handle BM->Canvas->Handle;
      
TGroupBox::Paint();
      
Canvas->Handle DC;
      
Canvas->Brush->Style =  bsClear;
      
Canvas->BrushCopy(RBMRColor);
    }
    
__finally {
      
delete BM;
    }
}
//--------------------------------------------------------------------------- 
El .h del RadioGroupClear:
Código PHP:
#ifndef MyRadioGroupClearH
#define MyRadioGroupClearH
//---------------------------------------------------------------------------
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TRadioGroupClear : public TRadioGroup {
protected:
    
void __fastcall CreateParamsTCreateParams &Params );
    
void __fastcall Paint();
public:
    
__fastcall TRadioGroupClearTComponent *Owner );
};
//---------------------------------------------------------------------------
#endif 
El .cpp del TRadioGroupClear:
Código PHP:
#include "MyRadioGroupClear.h"
//---------------------------------------------------------------------------

__fastcall TRadioGroupClear::TRadioGroupClearTComponent *Owner ) : TRadioGroupOwner ) {
    
TRadioGroup::TRadioGroupOwner );
}
//---------------------------------------------------------------------------

void __fastcall TRadioGroupClear::CreateParamsTCreateParams &Params ) {
    
TRadioGroup::CreateParamsParams );
    
Params.ExStyle |= WS_EX_TRANSPARENT;
}
//---------------------------------------------------------------------------

void __fastcall TRadioGroupClear::Paint() {
    
HDC DC   Canvas->Handle;
    
TRect R  ClientRect;
    
Graphics::TBitmap *BM = new Graphics::TBitmap;
    try {
      
BM->Height Height;
      
BM->Width  Width;
      
Canvas->Handle BM->Canvas->Handle;
      
TRadioGroup::Paint();
      
Canvas->Handle DC;
      
Canvas->Brush->Style =  bsClear;
      
Canvas->BrushCopy(RBMRColor);
    }
    
__finally {
      
delete BM;
    }
}
//--------------------------------------------------------------------------- 
El .h del TCheckBoxClear:
Código PHP:
#ifndef MyCheckBoxClearH
#define MyCheckBoxClearH
//---------------------------------------------------------------------------
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TCheckBoxClear : public TCheckBox {
protected:
    
void __fastcall CreateParamsTCreateParams &Params );
    
void __fastcall Paint();
public:
    
__fastcall TCheckBoxClearTComponent *Owner );
};
//---------------------------------------------------------------------------
#endif 
El .cpp del TCheckBoxClear:
Código PHP:
#include "MyCheckBoxClear.h"
//---------------------------------------------------------------------------

__fastcall TCheckBoxClear::TCheckBoxClearTComponent *Owner ) : TCheckBoxOwner ) {
    
TCheckBox::TCheckBoxOwner );
};
//---------------------------------------------------------------------------

void __fastcall TCheckBoxClear::CreateParamsTCreateParams &Params ) {
    
TCheckBox::CreateParamsParams );
    
Params.ExStyle |= WS_EX_TRANSPARENT;
}
//---------------------------------------------------------------------------

void __fastcall TCheckBoxClear::Paint() {
    
HDC DC   Canvas->Handle;
    
TRect R  ClientRect;
    
Graphics::TBitmap *BM = new Graphics::TBitmap;
    try {
      
BM->Height Height;
      
BM->Width  Width;
      
Canvas->Handle BM->Canvas->Handle;
      
TCheckBox::Paint();
      
Canvas->Handle DC;
      
Canvas->Brush->Style =  bsClear;
      
Canvas->BrushCopy(RBMRColor);
    }
    
__finally {
      
delete BM;
    }
}
//--------------------------------------------------------------------------- 
No me gusta tener todas las clases juntas y las he separado cada una en su propio archivo para tenerlo mas claro todo a la hora de examinarlo pero los problemas siguen siendo los mismos.
Responder Con Cita