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);
}
}