Re: CStatic::SetIcon Transparent.
class CMyDialog : public CDialog
{
........
CStatic m_StaticIcon;
........
}
HBRUSH CMyDialog:nCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog:nCtlColor(pDC, pWnd, nCtlColor);
switch(nCtlColor)
{
case CTLCOLOR_STATIC:
if (pWnd->m_hWnd == m_StaticIcon.m_hWnd)
{
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)(GetStockObject(NULL_BRUSH));
}
break;
}
return hbr;
}
BOOL CMyDialog:nInitDialog()
{
.........
m_StaticIcon.Create(_T(""), WS_CHILD | WS_VISIBLE | SS_ICON,
CRect(0, 0, 0, 0), this);
HICON hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(ICON_ID));
m_StaticIcon.SetIcon(hIcon);
.........
}
In CMyDialog:nPaint(), I have painted a region of CDialog with
GradientFill(...), and on this area I want a static icon, which needs to be
transparent. So that I can see the background of CStatic icon as gradient.
Regards,
Paresh.
"somefoobar@gmail.com" wrote:
Can you paste the code that you have? That should help in identifying
the problem.
On Apr 22, 11:34 am, Paresh <Par...@discussions.microsoft.com> wrote:
Hi,
I am using the API CStatic::SetIcon to associate the icon with the static
control. I have placed this control on CDialog, (Dialog background is
gradient painted). I want this CStatic control to be transparent (so that the
background of CStatic would be gradient, which is of Dialogs background
color). However, icon image is transparent. How could I do this ?
Any help would be highly appreciated.
Thanks,
Paresh.