Example #1
0
void CPicTracker::DrawDot(CDC* pDC) const
{
	// set initial DC state
	VERIFY(pDC->SaveDC() != 0);
	pDC->SetMapMode(MM_TEXT);
	pDC->SetViewportOrg(0, 0);
	pDC->SetWindowOrg(0, 0);

   CRect rect = GetPointRect();

   CPen* pOldPen = (CPen*)pDC->SelectStockObject(BLACK_PEN);
	CBrush* pOldBrush = (CBrush*)pDC->SelectStockObject(WHITE_BRUSH);

   pDC->Rectangle(rect);

   CRect AnchoreRect;
   AnchoreRect = GetAnchorRect(rect.right,rect.top);
   pDC->Rectangle(AnchoreRect);
   AnchoreRect = GetAnchorRect(rect.left,rect.top);
   pDC->Rectangle(AnchoreRect);
   AnchoreRect = GetAnchorRect(rect.right,rect.bottom);
   pDC->Rectangle(AnchoreRect);
   AnchoreRect = GetAnchorRect(rect.left,rect.bottom);
   pDC->Rectangle(AnchoreRect);

   // cleanup pDC state
	if (pOldPen != NULL)
		pDC->SelectObject(pOldPen);
	if (pOldBrush != NULL)
		pDC->SelectObject(pOldBrush);
	VERIFY(pDC->RestoreDC(-1));
}
Example #2
0
UINT CPicTracker::HitTest(CPoint point) const
{
   CRect rect = GetPointRect();

   CRect AnchoreRect;
   AnchoreRect = GetAnchorRect(rect.right,rect.top);
   if(AnchoreRect.PtInRect(point))
      return (UINT)hitOnPoint;
   AnchoreRect = GetAnchorRect(rect.left,rect.top);
   if(AnchoreRect.PtInRect(point))
      return (UINT)hitOnPoint;
   AnchoreRect = GetAnchorRect(rect.right,rect.bottom);
   if(AnchoreRect.PtInRect(point))
      return (UINT)hitOnPoint;
   AnchoreRect = GetAnchorRect(rect.left,rect.bottom);
   if(AnchoreRect.PtInRect(point))
      return (UINT)hitOnPoint;

   if(rect.PtInRect(point))
      return (UINT)hitInside;

   return (UINT)hitNothing;
}
CHERRY_RET CCherryNotificationDialog::Create(DWORD dwStyle, UINT nWidth, UINT nHeight, CWnd* pParentWnd, UINT nID, UINT nDurationSec)
{
	CHERRY_RET cherryRet = CCherryException::ERROR_CHERRY_SUCCESS;

	try
	{
		if (GetSafeHwnd())
		{
			if (m_nDurationTimerRet != 0)
			{
				KillTimer(m_nDurationTimerRet);
				m_nDurationTimerRet = 0;
			}

			if (m_nFadingTimerRet != 0)
			{
				KillTimer(m_nFadingTimerRet);
				m_nFadingTimerRet = 0;
			}

			DestroyWindow();
			//Initialize();
		}

		m_nDurationSec = m_nDurationSecCount = (int)nDurationSec;

		CRect rect = GetAnchorRect(nWidth, nHeight);

		dwStyle |= WS_POPUP | WS_VISIBLE;

		if (!CCherryDialog::CreateEx(WS_EX_TOPMOST | WS_EX_LAYERED | WS_EX_TOOLWINDOW, AfxRegisterWndClass(0), NULL, dwStyle, rect, pParentWnd, nID))
			throw CCherryException::ERROR_NOTIFICATIONDIALOG_CREATE_FAIL;
	}
	catch (const CHERRY_RET &errorRet)
	{
		cherryRet = errorRet;
	}

	return cherryRet;
}