CStatic::SetIcon Transparent

18 篇文章 0 订阅

Refer:

http://www.eggheadcafe.com/software/aspnet/32055514/cstaticseticon-transparent.aspx

http://www.codeproject.com/script/Forums/View.aspx?fid=1647&msg=2519409


如何设置static控件的Icon为透明


Pseudo code for this is as follows,


1) add the icon as member variable.


class CMyDialog : public CDialog
{
........
HICON m_hStaticIcon;// CStatic m_StaticIcon;
........
}




2) load the icon


BOOL CMyDialog::OnInitDialog()
{
.........
/*m_StaticIcon.Create(_T(""), WS_CHILD | WS_VISIBLE | SS_ICON, CRect(0, 0,
0, 0), this);*/
m_hStaticIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(ICON_ID));
/*m_StaticIcon.SetIcon(hIcon);*/
.........
}


In CMyDialog:OnPaint(), I have painted a region of CDialog with
GradientFill(...), and on this area I want a static icon,


3) Now draw the icon over the painted region.


void CMyDialog::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
.....
.....
}
else
{
CDialog::OnPaint();
CClientDC dc(this);


// painted the region with gradient fill
// after that draw the icon over the gradient region


dc.DrawIcon(100, 100, m_hStaticIcon);
}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值