BCB 窗体透明控件 (转)

BCB 窗体透明控件 (转)[@more@]本文根据 CandyCat   收藏的 《 编程实现窗体的半透明效果(作者:罗蔷)》一文修改而成,供BCB+ win2000使用。将 控件 安装即可使用   btw:分类里面,没有BCB,只好贴到 Delphi里面 头 文件: //--------------------------------------------------------------------------- #ifndef TransparentFormH
#define TransparentFormH
//---------------------------------------------------------------------------
#include
#include
#include
#include
//---------------------------------------------------------------------------
class PACKAGE TTransparentFo RM : public TComponent
{
private:
protected:
  int m_nAlphaValue;
  HWND m_hParentFormHandle;
  void __fastcall SetAlphaValue(int nAlpha);
  void __fastcall UpdateDisplay();
public:
  __fastcall TTransparentForm(TComponent* Owner);
__published:
  __property int AlphaValue = {read = m_nAlphaValue, write = SetAlphaValue, default = 0};
};
//---------------------------------------------------------------------------
#endif
cpp文件:   //--------------------------------------------------------------------------- #include
#pragma hdrstop #include "TransparentForm.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
// ValidCtrCheck is used to assure that the components created do not have
// any pure virtual functions.
//  
static inline void ValidCtrCheck(TTransparentForm *)
{
  new TTransparentForm(NULL);
}
//---------------------------------------------------------------------------
__fastcall TTransparentForm::TTransparentForm(TComponent* Owner)
  : TComponent(Owner)
{
  if (ComponentState.Contains(csDesigning))
  return;
  m_nAlphaValue = 255 ;
  m_hParentFormHandle = ((TForm *)(Owner))->Handle ;
  SetWindowLong(m_hParentFormHandle, GWL_EXSTYLE, GetWindowLong(m_hParentFormHandle, GWL_EXSTYLE) | WS_EX_LAYERED);
}
//---------------------------------------------------------------------------
namespace Transparentform
{
  void __fastcall PACKAGE Register()
  {
  TComponentClass classes[1] = {__classid(TTransparentForm)};
  RegisterComponents("Easysoft", classes, 0);
  }
}
//---------------------------------------------------------------------------
void __fastcall TTransparentForm::SetAlphaValue(int nAlpha)
{
  if (nAlpha >= 0 && nAlpha < 256)
  {
  m_nAlphaValue = nAlpha;
  UpdateDisplay();
  }
} void __fastcall TTransparentForm::UpdateDisplay()
{
  if (ComponentState.Contains(csDesigning))
  return;
  SetLayeredWindowAttributes(m_hParentFormHandle, 0, m_nAlphaValue, 2);
}
//wei@shijun.com
//http://www.shijun.com
//5/19/2001 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752043/viewspace-996103/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10752043/viewspace-996103/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值