透明对话框

方法一:

void CDialog::Draw( const TRect& aRect ) const

{

CWindowGc& gc = SystemGc();

TRgb colorAlpha(KRgbBlack);

colorAlpha.SetAlpha(100);//0时为完全透明

gc.SetBrushStyle(CGraphicsContext::ESolidBrush);

gc.SetBrushColor(colorAlpha);

gc.DrawRect(aRect);

}

方法二:需要设备支持  EColor16MA

http://www.developer.nokia.com/Community/Wiki/%E5%A6%82%E4%BD%95%E5%88%9B%E5%BB%BA%E5%8D%8A%E9%80%8F%E6%98%8E%E7%AA%97%E5%8F%A3


前提条件

设备必须支持EColor16MA显示模式。使用以下代码可以检查设备支持的显示模式。

if(CCoeEnv::Static()->ScreenDevice()->DisplayMode()==EColor16MA)
   {
   // 支持EColor16MA
   }

方案

本方案最初由william.edwards在UIQ论坛的"半透明窗口"系列文章中阐明 (UIQ论坛已经关闭,但仍然可以使用Google搜索"Semi-Transparent Windows #1"和"Semi-Transparent Windows #2",然后查看缓存的网页).

void CControlOnTopCtrl::ConstructL(const TRect& aRect, RWindowGroup* aWindowGroup)
  {
  TRect rc(aRect);
  TInt w = rc.Width();
  TInt h = rc.Height();
 
  CreateWindowL(aWindowGroup);
  for (TInt i = 0; i < 2; i++)
    {
	w /= 2;
	h /= 2;
    }
 
  SetUniqueHandle(EMyCueControl);
 
  TRect rc_new(w, h, w+15, h+15);
  SetRect(rc_new);
// begin by chen, code from William's post
	// we need to set the display mode to ensure that it has an
	// alpha-component specified.  However, the system may instead return
	// another display mode.  We don't have to pay much attention, as the
	// call to SetTransparencyAlphaChannel will check wether the Window
	// Server and the window's display mode support this kind of
	// transparency
	Window().SetRequiredDisplayMode(EColor16MA);
	TRgb backgroundColour = KRgbWhite; // for example
	if(KErrNone == Window().SetTransparencyAlphaChannel())
		{
		// we now have a semi-transparent window,
		// so we have to not clear the window region in an
		// opaque colour before drawing it each time;
		// 0 alpha is completely transparent,
		// 255 alpha is completely opaque
		backgroundColour.SetAlpha(0);
		}
	Window().SetBackgroundColor(backgroundColour);
// end by chen
  ActivateL();
  }

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值