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 Buscar Temas de Hoy Marcar Foros Como Leídos

 
 
Herramientas Buscar en Tema Desplegado
  #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: 38
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 CreateParams( TCreateParams &Params );
  
void __fastcall CreateWnd( void );
  
void __fastcall SetButtonStyle( void );
  
void __fastcall CNDrawItem( TWMDrawItem &msg );
  
BEGIN_MESSAGE_MAP
    VCL_MESSAGE_HANDLER
( CN_DRAWITEM, TWMDrawItem, CNDrawItem )
  
END_MESSAGE_MAP( TCheckBox )
public:
  
__fastcall TCheckBoxClear( TComponent *Owner ) : TCheckBox( Owner ) {};
  
//...
};

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

#pragma hdrstop

#include "CheckBoxClear.h"

#pragma package(smart_init)

void __fastcall TCheckBoxClear::CreateParams( TCreateParams &Params )
{
  
TCustomCheckBox::CreateParams( Params );
  
Params.ExStyle |= WS_EX_TRANSPARENT;
}

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

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

  if ( 
HandleAllocated() ) {
    
Style = BS_CHECKBOX | BS_OWNERDRAW;
    if ( 
GetWindowLong( Handle, GWL_STYLE) & BS_MASK != Style )
      
SendMessage( Handle, BM_SETSTYLE, Style, 1 );
  }
}

void __fastcall TCheckBoxClear::CNDrawItem( TWMDrawItem &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 x, y, sx=0, sy=0;
    
Graphics::TBitmap *Glyph = new Graphics::TBitmap;
    try {
      
Glyph->Handle = ::LoadBitmap( NULL, MAKEINTRESOURCE( OBM_CHECKBOXES ) );
      
y = FGlyphR.Top + (FGlyphR.Bottom - FGlyphR.Top - H) / 2;
      
x = 2;
      if( 
State == cbChecked ) sx += H;
      if( 
State == cbGrayed )  sx *= W;
      
FCanvas->CopyRect(Rect(x, y, x+W, x+H) ,Glyph->Canvas,
        
Rect(sx, sy, sx+W, sy+H));
    }
    
__finally {
      
delete Glyph;
    }

    
// Draw Caption
    
long fmt = DT_VCENTER |  DT_SINGLELINE | DT_LEFT;
    
fmt = DrawTextBiDiModeFlags( fmt );
    
DrawText(msg.DrawItemStruct->hDC, Caption.c_str(),
      
Caption.Length(), &FCaptionR, fmt);
  }
  
__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 TCheckBoxClear( this );
  
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
 


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 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:56:24.


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