Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

 
 
Herramientas Buscar en Tema Desplegado
  #9  
Antiguo 06-12-2017
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Poder: 14
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 *Sender, TCloseAction &Action);
private:    
// User declarations
    
TPanelClear *pc;
    
TGroupBoxClear *gbc;
    
TCheckBoxClear *cbc1;
    
TRadioGroupClear *rgc;
public:        
// User declarations
    
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
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(TComponent* Owner)
    : 
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 *Sender, TCloseAction &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 CreateParams( TCreateParams &Params );
    
void __fastcall Paint();
public:
    
__fastcall TPanelClear( TComponent *Owner );
};
//---------------------------------------------------------------------------
#endif 
el .cpp del TPanelClear:
Código PHP:
#include "MyPanelClear.h"
//---------------------------------------------------------------------------

__fastcall TPanelClear::TPanelClear( TComponent *Owner ) : TPanel( Owner ) {
    
TPanel::TPanel( Owner );
}
//---------------------------------------------------------------------------

void __fastcall TPanelClear::CreateParams( TCreateParams &Params ) {
    
TPanel::CreateParams( Params );
    
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(R, BM, R, Color);
    }
    
__finally {
      
delete BM;
    }
}
//--------------------------------------------------------------------------- 
El .h del TGroupBoxClear:
Código PHP:
#ifndef MyGroupBoxClearH
#define MyGroupBoxClearH
//---------------------------------------------------------------------------
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TGroupBoxClear : public TGroupBox {
protected:
    
void __fastcall CreateParams( TCreateParams &Params );
    
void __fastcall Paint();
public:
    
__fastcall TGroupBoxClear( TComponent *Owner );
};
//---------------------------------------------------------------------------
#endif 
El .cpp del TGroupBoxClear:
Código PHP:
#include "MyGroupBoxClear.h"
//---------------------------------------------------------------------------

__fastcall TGroupBoxClear::TGroupBoxClear( TComponent *Owner ) : TGroupBox( Owner ) {
    
TGroupBox::TGroupBox( Owner );
}
//---------------------------------------------------------------------------

void __fastcall TGroupBoxClear::CreateParams( TCreateParams &Params ) {
    
TGroupBox::CreateParams( Params );
    
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(R, BM, R, Color);
    }
    
__finally {
      
delete BM;
    }
}
//--------------------------------------------------------------------------- 
El .h del RadioGroupClear:
Código PHP:
#ifndef MyRadioGroupClearH
#define MyRadioGroupClearH
//---------------------------------------------------------------------------
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TRadioGroupClear : public TRadioGroup {
protected:
    
void __fastcall CreateParams( TCreateParams &Params );
    
void __fastcall Paint();
public:
    
__fastcall TRadioGroupClear( TComponent *Owner );
};
//---------------------------------------------------------------------------
#endif 
El .cpp del TRadioGroupClear:
Código PHP:
#include "MyRadioGroupClear.h"
//---------------------------------------------------------------------------

__fastcall TRadioGroupClear::TRadioGroupClear( TComponent *Owner ) : TRadioGroup( Owner ) {
    
TRadioGroup::TRadioGroup( Owner );
}
//---------------------------------------------------------------------------

void __fastcall TRadioGroupClear::CreateParams( TCreateParams &Params ) {
    
TRadioGroup::CreateParams( Params );
    
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(R, BM, R, Color);
    }
    
__finally {
      
delete BM;
    }
}
//--------------------------------------------------------------------------- 
El .h del TCheckBoxClear:
Código PHP:
#ifndef MyCheckBoxClearH
#define MyCheckBoxClearH
//---------------------------------------------------------------------------
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TCheckBoxClear : public TCheckBox {
protected:
    
void __fastcall CreateParams( TCreateParams &Params );
    
void __fastcall Paint();
public:
    
__fastcall TCheckBoxClear( TComponent *Owner );
};
//---------------------------------------------------------------------------
#endif 
El .cpp del TCheckBoxClear:
Código PHP:
#include "MyCheckBoxClear.h"
//---------------------------------------------------------------------------

__fastcall TCheckBoxClear::TCheckBoxClear( TComponent *Owner ) : TCheckBox( Owner ) {
    
TCheckBox::TCheckBox( Owner );
};
//---------------------------------------------------------------------------

void __fastcall TCheckBoxClear::CreateParams( TCreateParams &Params ) {
    
TCheckBox::CreateParams( Params );
    
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(R, BM, R, Color);
    }
    
__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
 



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 02:23:35
Otra forma de cambiar color fondo formulario chino150 Varios 2 16-02-2011 09:46:58
Mantener el Formulario principal en el fondo. Critter Lazarus, FreePascal, Kylix, etc. 5 25-10-2010 10:04:27
Poner un control en el fondo de un formulario MDI Egroc Varios 6 31-03-2007 02:56:57
Imagen de Fondo lucasarts_18 Gráficos 7 16-06-2005 17:03:04


La franja horaria es GMT +2. Ahora son las 22:49:19.


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