Ver Mensaje Individual
  #14  
Antiguo 07-12-2017
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 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