Click here to Skip to main content
15,903,741 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCStatic::SetIcon Transparent. Pin
Paresh Chitte21-Apr-08 19:59
Paresh Chitte21-Apr-08 19:59 
GeneralRe: CStatic::SetIcon Transparent. Pin
Hamid_RT21-Apr-08 20:06
Hamid_RT21-Apr-08 20:06 
GeneralRe: CStatic::SetIcon Transparent. Pin
Paresh Chitte21-Apr-08 20:30
Paresh Chitte21-Apr-08 20:30 
GeneralRe: CStatic::SetIcon Transparent. Pin
Rajkumar R21-Apr-08 21:39
Rajkumar R21-Apr-08 21:39 
GeneralRe: CStatic::SetIcon Transparent. Pin
Paresh Chitte22-Apr-08 0:09
Paresh Chitte22-Apr-08 0:09 
GeneralRe: CStatic::SetIcon Transparent. Pin
Rajkumar R22-Apr-08 2:19
Rajkumar R22-Apr-08 2:19 
GeneralRe: CStatic::SetIcon Transparent. Pin
Paresh Chitte22-Apr-08 18:07
Paresh Chitte22-Apr-08 18:07 
GeneralRe: CStatic::SetIcon Transparent. Pin
Rajkumar R22-Apr-08 19:19
Rajkumar R22-Apr-08 19:19 
I would suggest very simple approach as you want to display only the icon, use DrawIcon, inplace of doing a lot of stuff over CStatic.

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);*/
.........
}



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

3) Now you 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);
                // you painted the region with gradient fill
                // after that draw the icon over the gradient region
		dc.DrawIcon(100, 100, m_hStaticIcon);
	}
}

GeneralRe: CStatic::SetIcon Transparent. Pin
Paresh Chitte23-Apr-08 1:08
Paresh Chitte23-Apr-08 1:08 
GeneralExitWindowsEx Pin
john563221-Apr-08 19:37
john563221-Apr-08 19:37 
GeneralRe: ExitWindowsEx Pin
Hamid_RT21-Apr-08 19:47
Hamid_RT21-Apr-08 19:47 
GeneralRe: ExitWindowsEx Pin
john563221-Apr-08 20:13
john563221-Apr-08 20:13 
GeneralRe: ExitWindowsEx Pin
Rajkumar R21-Apr-08 20:19
Rajkumar R21-Apr-08 20:19 
GeneralRe: ExitWindowsEx Pin
john563221-Apr-08 20:20
john563221-Apr-08 20:20 
GeneralRe: ExitWindowsEx Pin
Rajkumar R21-Apr-08 20:24
Rajkumar R21-Apr-08 20:24 
GeneralRe: ExitWindowsEx Pin
Hamid_RT21-Apr-08 20:34
Hamid_RT21-Apr-08 20:34 
QuestionCom Ports Pin
usyra4221-Apr-08 19:34
usyra4221-Apr-08 19:34 
GeneralRe: Com Ports Pin
Rajkumar R21-Apr-08 19:43
Rajkumar R21-Apr-08 19:43 
GeneralRe: Com Ports Pin
usyra4221-Apr-08 20:35
usyra4221-Apr-08 20:35 
GeneralRe: Com Ports Pin
Rajkumar R21-Apr-08 20:45
Rajkumar R21-Apr-08 20:45 
GeneralRe: Com Ports Pin
usyra4221-Apr-08 21:58
usyra4221-Apr-08 21:58 
Generalspeed up serial communication Pin
vijay.victory21-Apr-08 19:21
vijay.victory21-Apr-08 19:21 
GeneralRe: speed up serial communication Pin
Cedric Moonen21-Apr-08 20:21
Cedric Moonen21-Apr-08 20:21 
GeneralRe: speed up serial communication Pin
vijay.victory22-Apr-08 0:07
vijay.victory22-Apr-08 0:07 
GeneralRe: speed up serial communication Pin
CPallini21-Apr-08 21:45
mveCPallini21-Apr-08 21:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.