文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>BCB 窗体透明控件

BCB 窗体透明控件

时间:2010-09-17  来源:chulia

http://www.wangchao.net.cn/bbsdetail_19296.html

 

本文根据 CandyCat 收藏的 《编程实现窗体的半透明效果(作者:罗蔷)》一文修改而成,供BCB+Win2000使用。
  将控件安装即可使用
  btw:分类里面,没有BCB,只好贴到delphi里面
  ////////////////////////////////////////////////////////////////////////////////////////////////
  头文件:
  //---------------------------------------------------------------------------
  #ifndef TransparentFormH
  #define TransparentFormH
  //---------------------------------------------------------------------------
  #include <SysUtils.hpp>
  #include <Controls.hpp>
  #include <Classes.hpp>
  #include <Forms.hpp>
  //---------------------------------------------------------------------------
  class PACKAGE TTransparentForm : 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 <vcl.h>
  #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);
  }
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  //[email protected]
  //http://www.shijun.com
  //5/19/2001(王朝网络 wangchao.net.cn)

  标签: BCB  控件  窗体  透明 
相关阅读 更多 +
排行榜 更多 +
马里奥赛车世界游戏手机版下载

马里奥赛车世界游戏手机版下载

赛车竞速 下载
无畏契约皮肤开箱器手游下载

无畏契约皮肤开箱器手游下载

休闲益智 下载
旭日之城官方正版下载

旭日之城官方正版下载

策略塔防 下载