Ver Mensaje Individual
  #8  
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
He estado probando tu codigo y me encuentro con una serie de problemas a extrapolarlo a otros componentes que necesito tambien hacerlos transparentes y que irán dentro de dicho TPanelClear. Son TGroupBox, TRadioGroup, y TCheckBox. Ademas de que no consigo hacer a ninguno de ellos transparentes con tu codigo, el TCheckBox no me deja ni compilar porque dice que Canvas no se reconoce. Te pego el codigo:
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)
{
}
//---------------------------------------------------------------------------

class TPanelClear : public TPanel {
protected:
  
void __fastcall CreateParamsTCreateParams &Params ) {
     
TPanel::CreateParamsParams );
     
Params.ExStyle |= WS_EX_TRANSPARENT;
  }
  
void __fastcall 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;
    }
  }
public:
   
__fastcall TPanelClearTComponent *Owner ) : TPanelOwner ) {
      
TPanel::TPanelOwner );
  }
};
//---------------------------------------------------------------------------

void __fastcall TForm1::btShowPanelClearClick(TObject *Sender)
{
  
TPanelClear *pc = new TPanelClear(this);
  
pc->Left    5;
  
pc->Top     5;
  
pc->Height  50;
  
pc->Width   200;
  
pc->Name    "PanelClear1";
  
pc->Caption pc->Name;
  
pc->Parent  this;
}
//---------------------------------------------------------------------------

class TGroupBoxClear : public TGroupBox {
protected:
  
void __fastcall CreateParamsTCreateParams &Params ) {
     
TGroupBox::CreateParamsParams );
     
Params.ExStyle |= WS_EX_TRANSPARENT;
  }
  
void __fastcall 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;
    }
  }
public:
   
__fastcall TGroupBoxClearTComponent *Owner ) : TGroupBoxOwner ) {
      
TGroupBox::TGroupBoxOwner );
  }
};
//---------------------------------------------------------------------------

class TCheckBoxClear : public TCheckBox {
protected:
  
void __fastcall CreateParamsTCreateParams &Params ) {
     
TCheckBox::CreateParamsParams );
     
Params.ExStyle |= WS_EX_TRANSPARENT;
  }
  
void __fastcall Paint() {
    
HDC DC   Canvas->Handle;  //Undefined symbol 'Canvas'
    
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;
    }
  }
public:
   
__fastcall TCheckBoxClearTComponent *Owner ) : TCheckBoxOwner ) {
      
TCheckBox::TCheckBoxOwner );
  }
};
//---------------------------------------------------------------------------

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

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

class TRadioGroupClear : public TRadioGroup {
protected:
  
void __fastcall CreateParamsTCreateParams &Params ) {
     
TRadioGroup::CreateParamsParams );
     
Params.ExStyle |= WS_EX_TRANSPARENT;
  }
  
void __fastcall Paint() {
    
HDC DC   Canvas->Handle;  //Undefined symbol 'Canvas'
    
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;
    }
  }
public:
   
__fastcall TRadioGroupClearTComponent *Owner ) : TRadioGroupOwner ) {
      
TRadioGroup::TRadioGroupOwner );
  }
};
//---------------------------------------------------------------------------

void __fastcall TForm1::btShowRadioGroupClick(TObject *Sender)
{
    
TRadioGroupClear *rgc = new TRadioGroupClear(this);
    
rgc->Left    5;
    
rgc->Top     5;
    
rgc->Height  100;
    
rgc->Width   200;
    
rgc->Name    "GroupBoxClear1";
    
rgc->Caption rgc->Name;
    
rgc->Parent  this;
    
rgc->Items->Add("opcion1");
    
rgc->Items->Add("opcion2");
}
//--------------------------------------------------------------------------- 
PD: Tu proyecto no me compilaba porque me decia que habia un error de linkado porque faltaba el nombre: "[Linker Fatal Error] Fatal: Expected a file name:"
Una vez consiguiese hacer que todo funcione correctamente la idea ya seria crear componentes con dichos codigos a ver si soy capaz
Responder Con Cita