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
  #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 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
 



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 11:40:29.


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