Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > C++ Builder
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 03-12-2017
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Poder: 11
aguml Va por buen camino
Imagen de fondo en formulario

Hola amigos, tengo un form al que le quiero poner una imagen como fondo pero el problema es que en dicho form tengo TPanels y objetos similares y al ejecutar los objetos de ese tipo no son transparentes y tapan la imagen de fondo del form. ¿Que debo hacer para que esos elementos sean transparentes?
Responder Con Cita
  #2  
Antiguo 04-12-2017
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Poder: 11
aguml Va por buen camino
He encontrado esto en Delphi: https://stackoverflow.com/questions/...el-transparent
Pero no entiendo nada.
Y esto en builder: http://www.delphigroups.info/3/2/174853.html
Pero tampoco soy capaz de entender lo que hace aunque creo que lo que hace es crear un nuevo componente TPanel y crearle la propiedad de transparencia pero no sé bien que hace y me gustaría que alguien pudiera ayudarme a hacerlo funcionar porque la cuestión no es copiar y pegar código sino entenderlo.
¿Podéis ayudarme?
Responder Con Cita
  #3  
Antiguo 05-12-2017
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.233
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Los componentes de la VCL no están pensados inicialmente para soportar transparencias, así que todo lo que hagas en ese sentido deberá ser "manual" y seguramente no muy eficiente.
¿Tienes posibilidad de usar en este caso FireMonkey? Te facilitaría mucho las cosas.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
  #4  
Antiguo 05-12-2017
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Poder: 11
aguml Va por buen camino
La verdad es que no sé ni qué es eso. ¿No hay componentes de terceros que ofrezcan esa opción? He estado mirando los de alpha skins y alguno más pero no veo cómo hacerlo transparente.
Responder Con Cita
  #5  
Antiguo 05-12-2017
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola.

Derivando de un TPanel te hice un ejemplo básico como para que puedas ir trabajando sobre él:
Código PHP:
...

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 ) {
    
// ...
   
}
   
// ...
};


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;

Muestra:


Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....

Última edición por ecfisa fecha: 05-12-2017 a las 22:03:10.
Responder Con Cita
  #6  
Antiguo 05-12-2017
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Poder: 11
aguml Va por buen camino
La verdad es que no sabría hacer para crear lo que haces y me harías un gran favor si me describirse los pasos para hacerlo y me comentase que va haciendo el código. Nunca he creado un componente y estoy muy perdido para hacer lo que haces.
Responder Con Cita
  #7  
Antiguo 05-12-2017
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola.

El ejemplo no es difícil de implementar, sólo debes copiar el código de la declaración de la clase derivada en la unidad que vayas a usarlo.

Basándote en ese código, luego no te será muy difícil crear tu componente panel transparente; de echo vas a encontrar en la web varios tutoriales muy didácticos sobre creación de componentes en C++ Builder.

Te adjunto el código fuente del ejemplo para que puedas probarlo y revisarlo. ( C++ Builder 6 )

Saludos
Archivos Adjuntos
Tipo de Archivo: zip PanelClear.zip (2,22 MB, 3 visitas)
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita
  #8  
Antiguo 06-12-2017
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Poder: 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
  #9  
Antiguo 06-12-2017
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Poder: 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
  #10  
Antiguo 06-12-2017
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Cita:
Empezado por aguml Ver Mensaje
...
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
Que raro... acabo de descargarlo y ejecuta sin siquiera advertencias

Con respecto a los componentes, el código sólo era para derivados de TPanel; lamentablemente no funcionará para todos los controles. Hacer un conjunto grande de componentes que tengan la propiedad de ser transparentes es una tarea bastante árdua.

Si es tu intención (o necesidad) usar esa propiedad sobre un grupo grande de controles, lo mas simple sería buscar alguna biblioteca de terceros que ya lo implemente.

Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....

Última edición por ecfisa fecha: 06-12-2017 a las 19:35:44.
Responder Con Cita
  #11  
Antiguo 06-12-2017
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Poder: 11
aguml Va por buen camino
¿Conoces algún pack de tercero que tenga esa opción?
Responder Con Cita
  #12  
Antiguo 07-12-2017
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola.

No, lamento no conocer ninguno, pero encontré un artículo que tal vez te resulte interesante: An easy way to create transparent button

En tanto que para los controles TGroupBox y TRadioGroup, podes usar:
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)
{
  ::
SetWindowLong(GroupBox1->HandleGWL_EXSTYLE,
    
GetWindowLong(GroupBox1->HandleGWL_EXSTYLE) | WS_EX_TRANSPARENT);

  ::
SetWindowLong(RadioGroup1->HandleGWL_EXSTYLE,
    
GetWindowLong(RadioGroup1->HandleGWL_EXSTYLE) | WS_EX_TRANSPARENT);
}

}
... 
Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita
  #13  
Antiguo 07-12-2017
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Poder: 11
aguml Va por buen camino
La verdad es que solo necesito que tengan transparencia los checkboxs, radiogroups, groupboxs, labels, y paneles. Los paneles ya están listos, según me indicas, con ese código ya tendría listo los radiogroups y groupboxs y me quedaría solo los checkbox y labels y no recuerdo si el label ya trae esa propiedad.
Responder Con Cita
  #14  
Antiguo 07-12-2017
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola.

Con el TLabel no tendrías problemas ya que posee la propiedad Transparent.

Y ya que estamos, código para el CheckBox,

CheckBoxClear.h:
Código PHP:
#ifndef CheckBoxClearH
#define CheckBoxClearH

#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>

class TCheckBoxClear : public TCheckBox {
private:
  
TCanvas *FCanvas;
  
TRect FCaptionR;
  
TRect FGlyphR;
protected:
  
void __fastcall CreateParamsTCreateParams &Params );
  
void __fastcall CreateWndvoid );
  
void __fastcall SetButtonStylevoid );
  
void __fastcall CNDrawItemTWMDrawItem &msg );
  
BEGIN_MESSAGE_MAP
    VCL_MESSAGE_HANDLER
CN_DRAWITEMTWMDrawItemCNDrawItem )
  
END_MESSAGE_MAPTCheckBox )
public:
  
__fastcall TCheckBoxClearTComponent *Owner ) : TCheckBoxOwner ) {};
  
//...
};

#endif 
CheckBoxClear.cpp:
Código PHP:
#define OEMRESOURCE

#pragma hdrstop

#include "CheckBoxClear.h"

#pragma package(smart_init)

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

void __fastcall TCheckBoxClear::CreateWndvoid )
{
  
TCheckBox::CreateWnd();
  
SetButtonStyle();
}

void __fastcall TCheckBoxClear::SetButtonStyle()
{
  const 
BS_MASK 0x000F;
  
unsigned int Style;

  if ( 
HandleAllocated() ) {
    
Style BS_CHECKBOX BS_OWNERDRAW;
    if ( 
GetWindowLongHandleGWL_STYLE) & BS_MASK != Style )
      
SendMessageHandleBM_SETSTYLEStyle);
  }
}

void __fastcall TCheckBoxClear::CNDrawItemTWMDrawItem &msg )
{
  const 
int H 0xD;
  const 
int W 0xD;
  
FGlyphR        msg.DrawItemStruct->rcItem;
  
FGlyphR.Right  20;
  
FCaptionR      msg.DrawItemStruct->rcItem;
  
FCaptionR.Left FGlyphR.Right;

  
FCanvas = new TCanvas;
  
__try {
    
FCanvas->Handle       msg.DrawItemStruct->hDC;
    
FCanvas->Brush->Style bsClear;

    
// Draw TBitmap
    
int xysx=0sy=0;
    
Graphics::TBitmap *Glyph = new Graphics::TBitmap;
    try {
      
Glyph->Handle = ::LoadBitmapNULLMAKEINTRESOURCEOBM_CHECKBOXES ) );
      
FGlyphR.Top + (FGlyphR.Bottom FGlyphR.Top H) / 2;
      
2;
      if( 
State == cbChecked sx += H;
      if( 
State == cbGrayed )  sx *= W;
      
FCanvas->CopyRect(Rect(xyx+Wx+H) ,Glyph->Canvas,
        
Rect(sxsysx+Wsy+H));
    }
    
__finally {
      
delete Glyph;
    }

    
// Draw Caption
    
long fmt DT_VCENTER |  DT_SINGLELINE DT_LEFT;
    
fmt DrawTextBiDiModeFlagsfmt );
    
DrawText(msg.DrawItemStruct->hDCCaption.c_str(),
      
Caption.Length(), &FCaptionRfmt);
  }
  
__finally {
    
delete FCanvas;
  }

Prueba:
Código PHP:
...
#include "CheckBoxClear.h"

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  
// Label transparente
  
Label1->Transparent true;

 
// CheckBox transparente
  
TCheckBoxClear *cbc = new TCheckBoxClearthis );
  
cbc->Left    200;
  
cbc->Top     110;
  
cbc->Name    "CheckBoxClear1";
  
cbc->Caption cbc->Name;
  
cbc->Parent  this;
  ... 
Muestra:


Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita
  #15  
Antiguo 08-12-2017
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Poder: 11
aguml Va por buen camino
Gracias amigo, los código del radiogroup y del listbox no me surten ningún efecto.
He estado probando los componentes de TMS que entre todo lo que trae vienen esos componentes con transparencia pero van de pena y tan lento que se puede ver cómo aplica la transparencia. Lo que tú estás haciendo es infinitamente más eficiente.
Si pudieras revisar esos dos componentes te estaría muy agradecido.
Ya luego me tocaría empollar y ver cómo pasarlos a componentes.
Encontré este código para un radiogroup por si es de utilidad:
Código PHP:
private:    // User declarations
    
void __fastcall NewGBWndProcTMessage& );
    
TWndMethod OldGBWndProc;
//-------------------------------------------------------------
__fastcall TForm1::TForm1(TComponentOwner)
        : 
TForm(Owner)
{
    
RadioGroup1->Brush->Style bsClear;
    
long exstyle GetWindowLongGroupBox1->HandleGWL_EXSTYLE );
    ::
SetWindowLongGroupBox1->HandleGWL_EXSTYLEexstyle WS_EX_TRANSPARENT );
    
OldGBWndProc GroupBox1->WindowProc;
    
GroupBox1->WindowProc NewGBWndProc;
}
//-------------------------------------------------------------
__fastcall TForm1::~TForm1()
{
    
GroupBox1->WindowProc OldGBWndProc;
}
//-------------------------------------------------------------
void __fastcall TForm1::NewGBWndProcTMessage &Message )
{
    if( 
Message.Msg == WM_CTLCOLORSTATIC )
      {
          
HWND hWnd reinterpret_cast<HWND>( Message.LParam );
          if( 
hWnd == RadioButton1->Handle || hWnd == RadioButton2->Handle )
            {
                
HDC hDC reinterpret_cast<HDC>( Message.WParam );
                
SetBkModehDCTRANSPARENT );
                
Message.Result reinterpret_cast<LONG>( GetStockObject(NULL_BRUSH) );
                return;
            }
      }
    
OldGBWndProcMessage );
}
//------------------------------------------------------------- 

Última edición por aguml fecha: 08-12-2017 a las 03:10:16.
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Fondo en formulario que no se ve Ramsay Varios 1 06-02-2016 03:23:35
Otra forma de cambiar color fondo formulario chino150 Varios 2 16-02-2011 10:46:58
Mantener el Formulario principal en el fondo. Critter Lazarus, FreePascal, Kylix, etc. 5 25-10-2010 11:04:27
Poner un control en el fondo de un formulario MDI Egroc Varios 6 31-03-2007 03:56:57
Imagen de Fondo lucasarts_18 Gráficos 7 16-06-2005 18:03:04


La franja horaria es GMT +2. Ahora son las 10:03:35.


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
Copyright 1996-2007 Club Delphi