Click here to Skip to main content
15,893,266 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionPng Image button problem. Pin
yu-jian20-Nov-12 6:53
yu-jian20-Nov-12 6:53 
C++
void CPNGButton::OnLButtonDown(UINT nFlags, CPoint point)
{
	SetCapture();
	SetPNG2Button(m_strMouseDownImagePath);
	CStatic::OnLButtonDown(nFlags, point);
}

void CPNGButton::OnLButtonUp(UINT nFlags, CPoint point)
{
	SetPNG2Button(m_strMouseMoveImagePath);
	CStatic::OnLButtonUp(nFlags, point);
}

void CPNGButton::OnMouseMove(UINT nFlags, CPoint point)
{
	SetCapture();
	CRect rc;
	GetClientRect(rc);
	if (rc.PtInRect(point))
	{
		if (!m_isPointInWnd)
		{
			OnMouseEnter();
			m_isPointInWnd = TRUE;
		}
	}
	else
	{
		SetPNG2Button(m_strMouseAwayImagePath);
		ReleaseCapture();
		m_isPointInWnd = FALSE;
	}
	CStatic::OnMouseMove(nFlags, point);
}

void CPNGButton::OnMouseEnter()
{
	SetPNG2Button(m_strMouseMoveImagePath);
}


I create a CPNGButton class to display a button. Using three images to display three different status. No mouse, mouse move, L Button down. CPNGButton is a child class of CStatic. Now if this CPNGButton button is a Minize button, when click this button. After restore the MainFrame, how to restore the minimize button status. Just to how to capture the mouse away from this minimize button?

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.