Example #1
0
/************************************************************************
PositionScrollBars  ListCtrl 기본 스크롤바를 숨기고 비트맵 스크롤 바로 변경한다.
@PARAM  : 
@RETURN : 
@REMARK : 
    http://www.codeguru.com/forum/showthread.php?s=36a2689f1a0c1395ba30950f993c559b&threadid=178221&highlight=hide+scrollbars
@AUTHOR : youngchang ([email protected])
@HISTORY :
    2006/01/02:CREATED
************************************************************************/
void CFishListCtrl::PositionScrollBars()
{
    enum { SCROLLBAR_WIDTH=12, SCROLLBAR_HEIGHT=12};

	CWnd* pParent = GetParent();
	
	CRect windowRT;
	GetWindowRect(&windowRT);

	int nTitleBarHeight = 0;
	
	if(pParent->GetStyle() & WS_CAPTION)
		nTitleBarHeight = GetSystemMetrics(SM_CYSIZE);

    // WINDOW SYSTEM VALUE
	int nDialogFrameHeight = 0;
	int nDialogFrameWidth = 0;
    int cxvs    =   0;
    int cyvs    =   0;
    int cxhs    =   0;
    int cyhs    =   0;

    if (pParent->GetStyle() & WS_VSCROLL)   {
        cxvs = GetSystemMetrics (SM_CXVSCROLL);
        cyvs = GetSystemMetrics (SM_CYVSCROLL);
    }

    if (pParent->GetStyle() & WS_HSCROLL)   {
        cxhs = GetSystemMetrics (SM_CXHSCROLL);
        cyhs = GetSystemMetrics (SM_CYHSCROLL);
    }
    
	if((pParent->GetStyle() & WS_BORDER))	{
		nDialogFrameHeight = GetSystemMetrics(SM_CYDLGFRAME);
		nDialogFrameWidth = GetSystemMetrics(SM_CYDLGFRAME);
	}
	
	if(pParent->GetStyle() & WS_THICKFRAME)    {
		nDialogFrameHeight+=1;
		nDialogFrameWidth+=1;
	}
	
	pParent->ScreenToClient(&windowRT);

    windowRT.InflateRect(nDialogFrameWidth,
        nTitleBarHeight+nDialogFrameHeight,
        nDialogFrameWidth,
        nTitleBarHeight+nDialogFrameHeight);

    // Vertical Scrollbar
    BOOL bVShow, bHShow;
	BOOL bVChanged = FALSE, bHChanged = FALSE;
    CRect regionRT  =   windowRT;
    if (GetScrollLimit(SB_VERT) != 0)
    {
		if(!m_SkinVerticleScrollbar.IsWindowVisible()) bVChanged = TRUE;

        regionRT.left   =   windowRT.left-nDialogFrameWidth;
        regionRT.right  =   windowRT.right-nDialogFrameWidth - SCROLLBAR_WIDTH;
        m_SkinVerticleScrollbar.ShowWindow(SW_NORMAL);
        bVShow  =   TRUE;
    }   else    {
		if(m_SkinVerticleScrollbar.IsWindowVisible()) bVChanged = TRUE;

        m_SkinVerticleScrollbar.ShowWindow(SW_HIDE);
        bVShow  =   FALSE;
    }

    // Horizontal Scrollbar
    if (GetScrollLimit(SB_HORZ) != 0)
    {
		if(!m_SkinHorizontalScrollbar.IsWindowVisible()) bHChanged = TRUE;

        regionRT.top    =   windowRT.top-nTitleBarHeight-nDialogFrameHeight;
        regionRT.bottom =   windowRT.bottom-nTitleBarHeight-nDialogFrameHeight - SCROLLBAR_HEIGHT;
        m_SkinHorizontalScrollbar.ShowWindow(SW_NORMAL);
        bHShow  =   TRUE;
    }   else        {
		if(m_SkinHorizontalScrollbar.IsWindowVisible()) bHChanged = TRUE;

        m_SkinHorizontalScrollbar.ShowWindow(SW_HIDE);
        bHShow  =   FALSE;
    }

    if (bVChanged) m_ctrlHeader.Invalidate(FALSE);

    HRGN iehrgn = CreateRectRgn(regionRT.left, regionRT.top, regionRT.right, regionRT.bottom);
    SetWindowRgn(iehrgn, TRUE);

    // SCROLLBAR SIZE SET
	CRect vBar(windowRT.right-nDialogFrameWidth - SCROLLBAR_WIDTH, 
        windowRT.top-nTitleBarHeight-nDialogFrameHeight- SCROLLBAR_WIDTH + 1, 
        windowRT.right+0-nDialogFrameWidth, 
        windowRT.bottom-nTitleBarHeight-nDialogFrameHeight);
	CRect hBar(windowRT.left-nDialogFrameWidth, 
        windowRT.bottom-nTitleBarHeight-nDialogFrameHeight - SCROLLBAR_HEIGHT, 
        bVShow ? windowRT.right-nDialogFrameWidth - SCROLLBAR_WIDTH:windowRT.right-nDialogFrameWidth, 
        windowRT.bottom+0-nTitleBarHeight-nDialogFrameHeight);

    // SCROLLBAR WINDOWS RESIZING
	m_SkinVerticleScrollbar.SetWindowPos(NULL,vBar.left,vBar.top,vBar.Width(),vBar.Height(),SWP_NOZORDER);
	m_SkinHorizontalScrollbar.SetWindowPos(NULL,hBar.left,hBar.top,hBar.Width(),hBar.Height(),SWP_NOZORDER);
	
	m_SkinHorizontalScrollbar.UpdateThumbPosition();
	m_SkinVerticleScrollbar.UpdateThumbPosition();
}
Example #2
0
void CTabsDlg::DockWindow(int ID , bool dock)
{
	DockedWindowInfo *info = NULL;
	m_Windows.Lookup((WORD)ID , (void* &)info);

	ASSERT(info);
	ASSERT(m_Tabs.GetSafeHwnd());

	ShowAllWindows(FALSE);

	if (!dock) {
		//make a containing window and assign the dialog to it
		CRect rect;
		CString classname = AfxRegisterWndClass(CS_DBLCLKS , 0 , 0 , 0);
		info->m_State = DockedWindowInfo::FLOATING;

		info->m_Window->GetWindowRect(rect);
		info->m_Container.CreateEx(WS_EX_TOOLWINDOW , classname , info->m_Title , WS_THICKFRAME | WS_SYSMENU | WS_POPUP | WS_CAPTION, rect , this , 0);
		info->m_Window->SetParent(&info->m_Container);
		info->m_Window->ShowWindow(TRUE);

		info->m_Container.SetDockManager(this);
		info->m_Container.ShowWindow(TRUE);
		info->m_Container.SetDialog(info->m_Window , info->m_ID);

		if (info->m_TabControlIndex >= 0) {
			m_Tabs.DeleteItem(info->m_TabControlIndex);
		}

		if (m_Tabs.GetItemCount() > 0) {
			m_Tabs.SetCurFocus(0);
		}

		CString placementName = info->m_Title + "Placement";
		LoadWindowPlacement(info->m_Container , placementName);
	} else {
		info->m_State = DockedWindowInfo::DOCKED;

		info->m_TabControlIndex = m_Tabs.InsertItem(TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM , 0 , info->m_Title , info->m_ImageID , (LPARAM)info);

		info->m_Window->SetParent(this);
		info->m_Window->ShowWindow(TRUE);

		info->m_Container.SetDockManager(NULL);	//so it doesn't try to call back and redock this window
		info->m_Container.DestroyWindow();

		CRect rect;
		GetWindowRect(rect);

		//stupid hack to get the window reitself properly
		rect.DeflateRect(0,0,0,1);
		MoveWindow(rect);
		rect.InflateRect(0,0,0,1);
		MoveWindow(rect);
	}

	UpdateTabControlIndices();
	FocusWindow(ID);

	if (info->m_DockCallback) {
		info->m_DockCallback(dock , info->m_ID , info->m_Window);
	}

	SaveWindowPlacement();
}
Example #3
0
void CDC::DrawDragRect(LPCRECT lpRect, SIZE size,
	LPCRECT lpRectLast, SIZE sizeLast, CBrush* pBrush, CBrush* pBrushLast)
{
	ASSERT(AfxIsValidAddress(lpRect, sizeof(RECT), FALSE));
	ASSERT(lpRectLast == NULL ||
		AfxIsValidAddress(lpRectLast, sizeof(RECT), FALSE));

	// first, determine the update region and select it
	CRgn rgnNew;
	CRgn rgnOutside, rgnInside;
	rgnOutside.CreateRectRgnIndirect(lpRect);
	CRect rect = *lpRect;
	rect.InflateRect(-size.cx, -size.cy);
	rect.IntersectRect(rect, lpRect);
	rgnInside.CreateRectRgnIndirect(rect);
	rgnNew.CreateRectRgn(0, 0, 0, 0);
	rgnNew.CombineRgn(&rgnOutside, &rgnInside, RGN_XOR);

	CBrush* pBrushOld = NULL;
	if (pBrush == NULL)
		pBrush = CDC::GetHalftoneBrush();
	if (pBrushLast == NULL)
		pBrushLast = pBrush;

	CRgn rgnLast, rgnUpdate;
	if (lpRectLast != NULL)
	{
		// find difference between new region and old region
		rgnLast.CreateRectRgn(0, 0, 0, 0);
		rgnOutside.SetRectRgn(lpRectLast);
		rect = *lpRectLast;
		rect.InflateRect(-sizeLast.cx, -sizeLast.cy);
		rect.IntersectRect(rect, lpRectLast);
		rgnInside.SetRectRgn(rect);
		rgnLast.CombineRgn(&rgnOutside, &rgnInside, RGN_XOR);

		// only diff them if brushes are the same
		if (pBrush->m_hObject == pBrushLast->m_hObject)
		{
			rgnUpdate.CreateRectRgn(0, 0, 0, 0);
			rgnUpdate.CombineRgn(&rgnLast, &rgnNew, RGN_XOR);
		}
	}
	if (pBrush->m_hObject != pBrushLast->m_hObject && lpRectLast != NULL)
	{
		// brushes are different -- erase old region first
		SelectClipRgn(&rgnLast);
		GetClipBox(&rect);
		pBrushOld = SelectObject(pBrushLast);
		PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), PATINVERT);
		SelectObject(pBrushOld);
		pBrushOld = NULL;
	}

	// draw into the update/new region
	SelectClipRgn(rgnUpdate.m_hObject != NULL ? &rgnUpdate : &rgnNew);
	GetClipBox(&rect);
	pBrushOld = SelectObject(pBrush);
	PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), PATINVERT);

	// cleanup DC
	if (pBrushOld != NULL)
		SelectObject(pBrushOld);
	SelectClipRgn(NULL);
}
void CCoolBar::NcPaintGripper(CDC* pDC, CRect rcClient)
{
    if (!HasGripper())
        return;
#ifndef _SCB_STYLE_FLAT
    CRect gripper = rcClient;
    CRect rcbtn = m_biHide.GetRect();
    BOOL bHorz = IsHorzDocked();

    gripper.DeflateRect(1, 1);
    if (bHorz)
    {   // gripper at left
        gripper.left -= m_cyGripper;
        gripper.right = gripper.left + 3;
        gripper.top = rcbtn.bottom + 3;
    }
    else
    {   // gripper at top
        gripper.top -= m_cyGripper;
        gripper.bottom = gripper.top + 3;
        gripper.right = rcbtn.left - 3;
    }

    pDC->Draw3dRect(gripper, ::GetSysColor(COLOR_BTNHIGHLIGHT),
        ::GetSysColor(COLOR_BTNSHADOW));

    gripper.OffsetRect(bHorz ? 3 : 0, bHorz ? 0 : 3);

    pDC->Draw3dRect(gripper, ::GetSysColor(COLOR_BTNHIGHLIGHT),
        ::GetSysColor(COLOR_BTNSHADOW));

    m_biHide.Paint(pDC);

#else

    // compute the caption rectangle
    BOOL bHorz = IsHorzDocked();
    CRect rcGrip = rcClient;
    CRect rcBtn = m_biHide.GetRect();
    if (bHorz)
    {   // right side gripper
        rcGrip.left -= m_cyGripper + 1;
        rcGrip.right = rcGrip.left + 11;
        rcGrip.top = rcBtn.bottom + 3;
    }
    else
    {   // gripper at top
        rcGrip.top -= m_cyGripper + 1;
        rcGrip.bottom = rcGrip.top + 11;
        rcGrip.right = rcBtn.left - 3;
    }
    rcGrip.InflateRect(bHorz ? 1 : 0, bHorz ? 0 : 1);

    // draw the caption background
    //CBrush br;
    COLORREF clrCptn = m_bActive ?
        ::GetSysColor(COLOR_ACTIVECAPTION) :
        ::GetSysColor(COLOR_INACTIVECAPTION);

    // query gradient info (usually TRUE for Win98/Win2k)
    BOOL bGradient = FALSE;
    ::SystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, &bGradient, 0);
    
    if (!bGradient)
        pDC->FillSolidRect(&rcGrip, clrCptn); // solid color
    else
    {
        // gradient from left to right or from bottom to top
        // get second gradient color (the right end)
        COLORREF clrCptnRight = m_bActive ?
            ::GetSysColor(COLOR_GRADIENTACTIVECAPTION) :
            ::GetSysColor(COLOR_GRADIENTINACTIVECAPTION);

        // this will make 2^6 = 64 fountain steps
        int nShift = 6;
        int nSteps = 1 << nShift;

        for (int i = 0; i < nSteps; i++)
        {
            // do a little alpha blending
            int nR = (GetRValue(clrCptn) * (nSteps - i) +
                      GetRValue(clrCptnRight) * i) >> nShift;
            int nG = (GetGValue(clrCptn) * (nSteps - i) +
                      GetGValue(clrCptnRight) * i) >> nShift;
            int nB = (GetBValue(clrCptn) * (nSteps - i) +
                      GetBValue(clrCptnRight) * i) >> nShift;

            COLORREF cr = RGB(nR, nG, nB);

            // then paint with the resulting color
            CRect r2 = rcGrip;
            if (bHorz)
            {
                r2.bottom = rcGrip.bottom - 
                    ((i * rcGrip.Height()) >> nShift);
                r2.top = rcGrip.bottom - 
                    (((i + 1) * rcGrip.Height()) >> nShift);
                if (r2.Height() > 0)
                    pDC->FillSolidRect(r2, cr);
            }
            else
            {
                r2.left = rcGrip.left + 
                    ((i * rcGrip.Width()) >> nShift);
                r2.right = rcGrip.left + 
                    (((i + 1) * rcGrip.Width()) >> nShift);
                if (r2.Width() > 0)
                    pDC->FillSolidRect(r2, cr);
            }
        }
    }
Example #5
0
bool CTrack::Down(int x, int y, bool bInsideMoveAllowed)
{
	if (m_bDisabled)
		return false;

	m_bMoved = false;
	m_iHandleGrabbed = 0;
	m_bPtInBorder = false;
	m_bPtInHandle = false;

	CPoint Point(x, y);
	for (int h = 0; h < NUM_HANDLES; h++)
	{
		if (!m_iHandleInUse[h])
			continue;

		if (PtInRect(&m_hHandleRects[h], Point))
		{
			m_iHandleGrabbed = h;
			m_bPtInHandle = true;
			break;
		}
	}

	if (m_iHandleGrabbed)
	{
		if (m_bShear)
		{
			if (!CONTROL
				&& m_iHandleGrabbed != H_MOVE
				&& m_iHandleGrabbed != H_CENTER
				&& m_iHandleGrabbed != H_ROTATE )
				ConstrainXY(&x, &y, true/*bButtonDown*/, true/*bInit*/, true/*bActive*/);
		}
	}
	else
	{
		if (PtInBorder(Point))
			m_bPtInBorder = true;

		CRect rect = m_Distort.Rect;
		m_Matrix.Transform(rect);
		m_ViewToDeviceMatrix.Transform(rect);
		// Make sure the rect is big enough to grab
		if (rect.Width() < 20)
			rect.InflateRect(10, 0);
		if (rect.Height() < 20)
			rect.InflateRect(0, 10);
		if (m_bPtInBorder || (bInsideMoveAllowed && PtInRect(&rect, Point)))
		{
			m_iHandleGrabbed = H_MOVE;
			m_bPtInHandle = false;
		}
	}

	if (m_iHandleGrabbed)
	{
		CPoint pt(x, y);
		m_iLastDownX = pt.x;
		m_iLastDownY = pt.y;
		m_ViewToDeviceMatrix.Inverse().Transform(pt);
		m_iLastX = pt.x;
		m_iLastY = pt.y;

		m_StartRect = m_Distort.Rect;
		m_Matrix.Transform(m_StartRect);
		m_StartMatrix = m_Matrix;
		m_iStartRotateX = m_ptRotate.x;
		m_iStartRotateY = m_ptRotate.y;

#ifdef READOUT
		m_fReadoutScale1X = m_fReadoutScaleX;
		m_fReadoutScale1Y = m_fReadoutScaleY;
		m_fReadoutAngle1X = m_fReadoutAngleX;
		m_fReadoutAngle1Y = m_fReadoutAngleY;
#endif READOUT
	}

	return !!m_iHandleGrabbed;
}
Example #6
0
LRESULT CImageColorDlg::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	CPaintDC dc(m_hWnd);

#if 0
	if (m_viewGroup)
	{
		if (!wcscmp(static_cast<CWebXMLViewGroup*>(m_viewGroup.p)->m_colorEditing, L"stroke") ||
			!wcscmp(static_cast<CWebXMLViewGroup*>(m_viewGroup.p)->m_colorEditing, L"fill"))
		{
			CComPtr<ILCSSStyleDeclaration> style;

			CComBSTR strokeStr;
			CComBSTR fillStr;

			if (m_viewGroup)
			{
				//style = ((CWebXMLDocument*)m_document.p)->m_defaultStyle;
				m_viewGroup->GetCurrentSelectionCSSStyle(&style);// = ((CWebXMLViewGroup*)m_viewGroup.p)->m_currentSelectionStyle;

				style->getPropertyValue(L"stroke", &strokeStr);
				//if (strokeStr.Length() == 0) strokeStr = L"";

				style->getPropertyValue(L"fill", &fillStr);
				//if (fillStr.Length() == 0) fillStr = L"";
			}

			{
				int state = dc.SaveDC();
				dc.ExcludeClipRect(&m_strokerc);
				dc.ExcludeClipRect(&m_fillrc);

				CRect rc2;

				rc2 = m_strokerc;
				rc2.InflateRect(1, 1);
				dc.Draw3dRect(&rc2, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));

				rc2 = m_fillrc;
				rc2.InflateRect(1, 1);
				dc.Draw3dRect(&rc2, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));

				dc.RestoreDC(state);
			}

			{
				if (gApp->m_strokeOrFill == 0)
				{
					int state = dc.SaveDC();
					dc.ExcludeClipRect(&m_strokerc);
					DrawFillPaint(dc, m_fillrc, fillStr);

					dc.RestoreDC(state);
					DrawStrokePaint(dc, m_strokerc, strokeStr);
				}
				else
				{
					int state = dc.SaveDC();
					dc.ExcludeClipRect(&m_fillrc);
					DrawStrokePaint(dc, m_strokerc, strokeStr);

					dc.RestoreDC(state);
					DrawFillPaint(dc, m_fillrc, fillStr);
				}
			}
		}
		else if (!wcscmp(static_cast<CWebXMLViewGroup*>(m_viewGroup.p)->m_colorEditing, L"stop-color") ||
					!wcscmp(static_cast<CWebXMLViewGroup*>(m_viewGroup.p)->m_colorEditing, L"solid-color"))
		{
			CComPtr<ILCSSStyleDeclaration> style;
			m_viewGroup->GetCurrentSelectionCSSStyle(&style);

			CComPtr<ILSVGColor> svgColor;
			style->getPropertyCSSValue(static_cast<CWebXMLViewGroup*>(m_viewGroup.p)->m_colorEditing, (ILCSSValue**)&svgColor);

			if (svgColor)
			{
				CLRGBColor rgbColor;
				svgColor->get_rgbColor(&rgbColor);

				double red = rgbColor.GetRed();
				double green = rgbColor.GetGreen();
				double blue = rgbColor.GetBlue();

				CRect rc = CRect(6, 6, 6+18+9, 6+18+9);

				dc.Draw3dRect(&rc, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
				rc.InflateRect(-1,-1);

				dc.FillSolidRect(&rc, RGB(red, green, blue));			

				if (!wcscmp(static_cast<CWebXMLViewGroup*>(m_viewGroup.p)->m_colorEditing, L"stop-color"))
				{
					// TODO: draw knob
				}
			}
		}
	}
#endif

	return 0;
}
Example #7
0
void CTableFormatControl::Init(void)
{
	// First, get the client rect.
	CRect crClient;
	GetClientRect(crClient);
	ASSERT(crClient.left == 0);
	ASSERT(crClient.top == 0);

	// Do whatever we want to the client rect.
	crClient.InflateRect(-4, -4);		 // Leave some room around the outside.

	// Set it for later use.
	m_crClient = crClient;

	// Set up a redisplay context to use for generating widths, etc.
	// Most of what we need is set default by the rc constructor.
	m_rc.scaled_source_x0 = 0;
	m_rc.scaled_source_y0 = 0;
	m_rc.destination_x0 = m_crClient.left;
	m_rc.destination_y0 = m_crClient.top;
	m_rc.destination_rect = m_crClient;
	m_rc.clip_rect = m_rc.destination_rect;

	m_rc.outline_gamma_curve =
		m_rc.bitmap_gamma_curve = screen_gamma_curve;

	CDC* pDC = GetDC();
	if (pDC != NULL)
	{
		m_rc.x_resolution = pDC->GetDeviceCaps(LOGPIXELSX);
		m_rc.y_resolution = pDC->GetDeviceCaps(LOGPIXELSY);
		ReleaseDC(pDC);
	}
	else
	{
		ASSERT(FALSE);
		m_rc.x_resolution = m_rc.y_resolution = 96;
	}

	// Compute the source that maps into this.
	PBOX Bound;
	m_rc.screen_to_pbox(&m_rc.destination_rect, &Bound);
	ASSERT(Bound.x0 == 0);
	ASSERT(Bound.y0 == 0);
	m_rc.source_pbox = Bound;

	// Create the document we need to show the object.
	m_pDoc = GET_PMWAPP()->NewHiddenDocument();
	if (m_pDoc == NULL)
	{
		ASSERT(FALSE);
		return;
	}

	// Create a table object to use for previewing.
	PMGDatabase* pDatabase = m_pDoc->get_database();
	TABLE_CREATE_STRUCT tcs;
	tcs.info.m_nRows = 5;
	tcs.info.m_nColumns = 5;
	tcs.bound = m_rc.source_pbox;
	m_pTable = (CTableObject*)pDatabase->new_object(OBJECT_TYPE_Table, &tcs);
	if (m_pTable == NULL)
	{
		return;
	}
	m_pDoc->append_object(m_pTable);
}
Example #8
0
void CChildFrame::FixUpSplitterBar (void)
  {
   int cyCurTop,
       cyCurBottom;

   // we want the input area to be at least high enough for our input font
   // (2 lines) (plus a couple of pixels)
   // nb FixedSys takes 15 pixels

   int iDefaultHeight = (15 * 2) + 9;

   if (m_pDoc)
     iDefaultHeight = (m_pDoc->m_InputFontHeight * 2) + 9;   // 2 lines plus 7 pixels for add, below

   int iMinimumHeight = 15 + 9;

   if (m_pDoc)
     iMinimumHeight = m_pDoc->m_InputFontHeight + 9;   // 2 lines plus 7 pixels for add, below

	CRect rectInside;
	m_wndSplitter.GetClientRect(rectInside);
	rectInside.InflateRect(-9, -9); // allow for borders and splitter bar

   cyCurTop = App.db_get_int("worlds", (LPCTSTR) CFormat ("%s:%s", (LPCTSTR) m_pDoc->m_mush_name, "Top Height"), 20);

   // if this world is existing, take command height from registry
   if (!(m_pDoc->m_mush_name.IsEmpty ()))
     cyCurBottom = App.db_get_int("worlds", (LPCTSTR) CFormat ("%s:%s", (LPCTSTR) m_pDoc->m_mush_name, "Bottom Height"), iDefaultHeight);
   else
     // otherwise, allow for a 2-line command area
    cyCurBottom = iDefaultHeight;

//  TRACE1 ("Bottom height (loaded) = %i\n", cyCurBottom);

   // if height from registry is smaller, make the input font height
   // REMOVED in version 3.83
//   if (cyCurBottom < iMinimumHeight)
//     cyCurBottom = iMinimumHeight;

   // we have to root around like this, because recalclayout lays out the top
   // view first, and allocates the rest (possibly nothing) to the bottom view.
   // I don't really want this, the important thing is that you can see where
   // you are going to type. Thus I work out how much the maxmimum top view
   // can be.

   int iRoom = rectInside.bottom - rectInside.top - cyCurBottom 
        + 7;    // 7 pixels for the splitter bar

   cyCurTop = iRoom;

   // however, don't make ridiculously tiny
   if (cyCurTop < 20)
     cyCurTop = 20;

   // set the info for the top view
   m_wndSplitter.SetRowInfo (OUTPUT_PANE, cyCurTop, 20);

   // set the info for the bottom view
   m_wndSplitter.SetRowInfo (COMMAND_PANE, cyCurBottom, 9);

   // recalculate it all
   m_wndSplitter.RecalcLayout ();

  }
Example #9
0
LRESULT CLayerOptionsDlg::OnDrawItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	UINT idCtl = (UINT) wParam;             // control identifier 
	LPDRAWITEMSTRUCT lpDrawItemStruct = (LPDRAWITEMSTRUCT) lParam; // item-drawing information 

	CDCHandle pDC = lpDrawItemStruct->hDC;
	CRect rc = lpDrawItemStruct->rcItem;

	if (idCtl == IDC_LAYER_COLOR)
	{
		pDC.DrawEdge(&rc, (lpDrawItemStruct->itemState & ODS_SELECTED)? EDGE_SUNKEN : EDGE_RAISED, BF_RECT | BF_ADJUST);

		rc.InflateRect(-1,-1);
		pDC.FillSolidRect(&rc, m_color);
	}
	else
	{
		int w = 12;
		int h = 12;

		int id = lpDrawItemStruct->itemID;

		if (id >= 0)
		{
			COLORREF	ref;

			if (lpDrawItemStruct->itemState & ODS_SELECTED)
				ref = ::GetSysColor(COLOR_HIGHLIGHT);
			else
				ref = ::GetSysColor(COLOR_WINDOW);

		//	pDC->FillSolidRect(rc.left+1, rc.top+1, rc.Width()-1, rc.Height()-1, ref);
			pDC.FillSolidRect(&rc, ref);

			if (lpDrawItemStruct->itemState & ODS_FOCUS)
				pDC.DrawFocusRect(&rc);

			if (id < gNumLayerColors)
			{
				HBRUSH hOldBrush = pDC.SelectBrush((HBRUSH)GetStockObject(NULL_BRUSH));
				pDC.Rectangle(rc.left+1, rc.top+1, rc.left+w+3, rc.top+h+3);
				pDC.SelectBrush(hOldBrush);

				CBrush brush;
				brush.CreateSolidBrush(gLayerColors[id].color);

				CRect	r(rc.left+2, rc.top+2, rc.left+2+w, rc.top+2+h);
				pDC.FillRect(&r, brush);
			}

			if (lpDrawItemStruct->itemState & ODS_SELECTED)
			{
				pDC.SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
				pDC.SetBkColor(::GetSysColor(COLOR_HIGHLIGHT));
			}
			else
			{
				pDC.SetTextColor(::GetSysColor(COLOR_WINDOWTEXT));
				pDC.SetBkColor(::GetSysColor(COLOR_WINDOW));
			}

			pDC.TextOut(rc.left+((id < gNumLayerColors)? (w+6): 4), rc.top+2, (LPCTSTR)lpDrawItemStruct->itemData);
		}
	}
	
	return 0;
}
	virtual DROPEFFECT OnDragOver(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
	{
		CXTPCoreTreeControl* pTree = DYNAMIC_DOWNCAST(CXTPCoreTreeControl, pWnd);
		if (!pTree)
			return DROPEFFECT_NONE;


		CRect rectClient;
		pWnd->GetClientRect(&rectClient);
		CRect rect = rectClient;

		// hit-test against inset region
		UINT nTimerID = MAKEWORD(-1, -1);
		rect.InflateRect(0, -nScrollInset);

		const int nTimerHover = 10;

		if (rectClient.PtInRect(point) && !rect.PtInRect(point))
		{
			// determine which way to scroll along both X & Y axis
			if (point.y < rect.top)
				nTimerID = SB_LINEUP;
			else if (point.y >= rect.bottom)
				nTimerID = SB_LINEDOWN;
		}
		else if (rectClient.PtInRect(point))
		{
			nTimerID = nTimerHover;
		}

		if (nTimerID == nTimerHover)
		{
			// save tick count when timer ID changes
			DWORD dwTick = GetTickCount();
			if (point != m_ptLastPoint)
			{
				m_ptLastPoint = point;
				m_dwLastTick = dwTick;
				m_nScrollDelay = m_nHoverTime;
			}

			// scroll if necessary
			if (dwTick - m_dwLastTick > m_nScrollDelay)
			{
				pTree->OnDragHover(pDataObject, dwKeyState, point);
				m_dwLastTick = dwTick;
			}

		}
		else if (nTimerID != MAKEWORD(-1, -1))
		{
			// save tick count when timer ID changes
			DWORD dwTick = GetTickCount();
			if (nTimerID != m_nTimerID)
			{
				m_dwLastTick = dwTick;
				m_nScrollDelay = nScrollDelay;
			}

			// scroll if necessary
			if (dwTick - m_dwLastTick > m_nScrollDelay)
			{
				pTree->OnVScroll(nTimerID, 0, NULL);
				m_dwLastTick = dwTick;
				m_nScrollDelay = nScrollInterval;
			}
		}

		m_nTimerID = nTimerID;

		return pTree->OnDragOver(pDataObject, dwKeyState, point);
	}
Example #11
0
BOOL CVisualManager::OnNcPaint (CWnd* pWnd, const CObList& lstSysButtons, CRect rectRedraw)
{
	if (!CanDrawImage ())
	{
		return CBCGPWinXPVisualManager::OnNcPaint (pWnd, lstSysButtons, rectRedraw);
	}

	ASSERT_VALID (pWnd);

	if (pWnd->GetSafeHwnd () == NULL)
	{
		return FALSE;
	}

	CWindowDC dc (pWnd);

	if (dc.GetSafeHdc () != NULL)
	{
		CRgn rgn;
		if (!rectRedraw.IsRectEmpty ())
		{
			rgn.CreateRectRgnIndirect (rectRedraw);
			dc.SelectClipRgn (&rgn);
		}

		CRect rtWindow;
		pWnd->GetWindowRect (rtWindow);
		pWnd->ScreenToClient (rtWindow);

		CRect rtClient;
		pWnd->GetClientRect (rtClient);

		rtClient.OffsetRect (-rtWindow.TopLeft ());
		dc.ExcludeClipRect (rtClient);

		rtWindow.OffsetRect (-rtWindow.TopLeft ());

        BOOL bActive = IsWindowActive (pWnd);

		CRect rectCaption (rtWindow);
		CSize szSysBorder (GetSystemBorders ());

		rectCaption.bottom = rectCaption.top + szSysBorder.cy;

		const DWORD dwStyle = pWnd->GetStyle ();
		BOOL bMaximized = (dwStyle & WS_MAXIMIZE) == WS_MAXIMIZE;

		const int nSysCaptionHeight = ::GetSystemMetrics (SM_CYCAPTION);
		rectCaption.bottom += nSysCaptionHeight;

		const DWORD dwStyleEx = pWnd->GetExStyle ();

		BOOL bDestroyIcon = FALSE;
		HICON hIcon = globalUtils.GetWndIcon (pWnd, &bDestroyIcon);

		CString strText;
		pWnd->GetWindowText (strText);

		CString strTitle (strText);
		CString strDocument;

		BOOL bPrefix = FALSE;
		if ((dwStyle & FWS_ADDTOTITLE) == FWS_ADDTOTITLE)
		{
			bPrefix = (dwStyle & FWS_PREFIXTITLE) == FWS_PREFIXTITLE;
			CFrameWnd* pFrameWnd = DYNAMIC_DOWNCAST(CFrameWnd, pWnd);

			if (pFrameWnd != NULL)
			{
				strTitle = pFrameWnd->GetTitle();

				if (!strTitle.IsEmpty ())
				{
					if (strText.GetLength () >= strTitle.GetLength ())
					{
						if (bPrefix)
						{
							int pos = strText.Find (strTitle, strText.GetLength () - strTitle.GetLength ());
							if (pos != -1)
							{
								strTitle = strText.Right (strTitle.GetLength () + 3);
								strDocument = strText.Left (strText.GetLength () - strTitle.GetLength ());
							}
						}
						else
						{
							int pos = strText.Find (strTitle);
							if (pos != -1)
							{
								strTitle = strText.Left (strTitle.GetLength () + 3);
								strDocument = strText.Right (strText.GetLength () - strTitle.GetLength ());
							}	
						}
					}
				}
				else
				{
					strDocument = strText;
				}
			}
		}

		if (bMaximized)
		{
			rectCaption.InflateRect (szSysBorder.cx, szSysBorder.cy, szSysBorder.cx, 0);
		}

		DrawNcCaption (&dc, rectCaption, dwStyle, dwStyleEx, 
						strTitle, strDocument, hIcon, bPrefix, bActive, FALSE,
						lstSysButtons);

		if (bDestroyIcon)
		{
			::DestroyIcon (hIcon);
		}

		if (bMaximized)
		{
			return TRUE;
		}

		rtWindow.top = rectCaption.bottom;

		dc.ExcludeClipRect (rectCaption);

		int indexBorder = 0;
		int indexNavi   = IsLargeNaviControl () ? 1 : 0;

		CRect rtPart (rtWindow);
		rtPart.right  = rtPart.left + szSysBorder.cx;
		rtPart.bottom = rtPart.top + 
			m_ctrlMainBorderExplorerL.GetParams ().m_rectImage.Height ();
		m_ctrlMainBorderExplorerL.Draw (&dc, rtPart, indexBorder);
		rtPart.top = rtPart.bottom;
		rtPart.bottom = rtWindow.bottom - 
			(m_ctrlMainBorderNaviL[indexNavi].GetParams ().m_rectImage.Height () + 
			 m_ctrlMainBorderNaviB[indexNavi].GetParams ().m_rectImage.Height ());
		m_ctrlMainBorderL.Draw (&dc, rtPart, indexBorder);
		rtPart.top = rtPart.bottom;
		rtPart.bottom = rtWindow.bottom - m_ctrlMainBorderNaviB[indexNavi].GetParams ().m_rectImage.Height ();
		m_ctrlMainBorderNaviL[indexNavi].Draw (&dc, rtPart, indexBorder);

		rtPart = rtWindow;
		rtPart.left   = rtPart.right - szSysBorder.cx;
		rtPart.bottom = rtPart.top + 
			m_ctrlMainBorderExplorerR.GetParams ().m_rectImage.Height ();
		m_ctrlMainBorderExplorerR.Draw (&dc, rtPart, indexBorder);
		rtPart.top = rtPart.bottom;
		rtPart.bottom = rtWindow.bottom - 
			(m_ctrlMainBorderNaviR[indexNavi].GetParams ().m_rectImage.Height () + 
			 m_ctrlMainBorderNaviB[indexNavi].GetParams ().m_rectImage.Height ());
		m_ctrlMainBorderR.Draw (&dc, rtPart, indexBorder);
		rtPart.top = rtPart.bottom;
		rtPart.bottom = rtWindow.bottom - m_ctrlMainBorderNaviB[indexNavi].GetParams ().m_rectImage.Height ();
		m_ctrlMainBorderNaviR[indexNavi].Draw (&dc, rtPart, indexBorder);

		rtPart = rtWindow;
		rtPart.top = rtPart.bottom - m_ctrlMainBorderNaviB[indexNavi].GetParams ().m_rectImage.Height ();
		m_ctrlMainBorderNaviB[indexNavi].Draw (&dc, rtPart, indexBorder);

		if (indexNavi == 1)
		{
			m_ctrlMainBorderNaviBCtrl.DrawEx (&dc, rtPart, 0, CBCGPToolBarImages::ImageAlignHorzCenter, CBCGPToolBarImages::ImageAlignVertBottom);
		}

		dc.SelectClipRgn (NULL);

		return TRUE;
	}

	return CBCGPWinXPVisualManager::OnNcPaint (pWnd, lstSysButtons, rectRedraw);
}
Example #12
0
void CProgressBar::DoPaint(CDC* pDC)
// Paints the bar, assuming that the background has already been cleared to grey.
// The bar has a percentage display on the left, followed by a progress bar
// which is sized to fit the available space up to a maximum of MAXBARWIDTH pixels
// If there is enough room, the current Job Description will also be displayed, to
// the right of the bar.
{
	ASSERT_VALID(this);
	ASSERT_VALID(pDC);

	CControlBar::DoPaint(pDC);      // draw border

	CRect rect;
	GetClientRect(rect);
	CalcInsideRect(rect);

	ASSERT(m_hFont != NULL);
	CFont *OurFont = CHECKFONT(CFont::FromHandle(m_hFont));		// Get a CFont* for this HFONT
	CFont *OldFont = CHECKFONT(pDC->SelectObject(OurFont));

	rect.InflateRect(-CX_BORDER, -CY_BORDER);

	CString PercentText("00%");							// Generate %age string
	if (CurrentPercent > 0 && CurrentPercent < 100)
	{
		if (CurrentPercent > 9)
			PercentText.SetAt(0, (CurrentPercent / 10) + '0');
		PercentText.SetAt(1, (CurrentPercent % 10) + '0');
	}

	pDC->SetTextColor(GetSysColor(COLOR_BTNTEXT));		// Draw %age string
	pDC->SetBkColor(GetSysColor(COLOR_BTNFACE));
	pDC->SetBkMode(OPAQUE);
	SetTextAlign(pDC->m_hDC, TA_LEFT | TA_BOTTOM);
	pDC->TextOut(rect.left, rect.bottom, PercentText);

	CSize TextSize = pDC->GetTextExtent(PercentText, 3);

	INT32 BarStart = rect.left + TextSize.cx + 4;			// Calc bar position, size
	INT32 WindowEnd = rect.right - 4;
	INT32 BarWidth = WindowEnd - BarStart;
	
	if (BarWidth < 10) return;		// Not enough room to do a bar!

	if (BarWidth > MAXBARWIDTH) BarWidth = MAXBARWIDTH;

	if (JobDescription != NULL && WindowEnd - BarStart > MAXBARWIDTH + 64)
	{	// If enough room for some text, add the job description
		CString OutText = TEXT(*JobDescription);

		rect.left = BarStart + BarWidth + 4;
		rect.right = WindowEnd;
		pDC->TextOut(rect.left, rect.bottom, OutText);
	}

	CHECKFONT(pDC->SelectObject(OldFont));	// Restore previous font 

	rect.left = BarStart;				// Finally, calc and paint the bar,,,
	rect.right = BarStart+BarWidth;
	rect.bottom -= m_FontDescent - 2;	// Line up bar bottom with text baseline
	Paint3dPlinth(pDC, &rect, FALSE);
	
	BarWidth -= 4;						// Bar is 2 pixels inside plinth rectangle
	rect.left = BarStart + 2;
	rect.top += 2;
	rect.bottom -= 2;
	rect.right = rect.left + (INT32) (((WORD)BarWidth * (WORD)CurrentPercent) / 100);

	CBrush BlueBrush(RGB(0,0,255));
	pDC->FillRect(rect, &BlueBrush);
}
Example #13
0
void CBalloonWnd::CalcAndMove( CRect rectParent )
{
	CRect rectBalloon, rectScreen;
	int nArrowSide;

	// Calc window pos
	GetClientRect( &rectBalloon );
	rectBalloon.InflateRect(0,0, B_MARGIN * 2, B_MARGIN * 2);
	
	// Resize parent window - margin
	rectParent.InflateRect( m_nAMargin, m_nAMargin );

	// Get screen size
	GetDesktopWindow()->GetWindowRect( &rectScreen );

	// Top
	if ( rectBalloon.Height() + B_ARROW <= rectParent.top )
	{
		// It's enough space
		nArrowSide = B_ARROWBOTTOM;

		rectBalloon.OffsetRect( 0, rectParent.top - rectBalloon.Height() - B_ARROW );
		rectBalloon.OffsetRect( rectParent.left - ( rectBalloon.Width() - rectParent.Width() ) * 0.5, 0) ;

		m_nHMargin = ( rectBalloon.Width() - m_nArrowSM ) * 0.5;

		goto CorrectPos;
	}

	// Right
	if ( rectBalloon.Width() + B_ARROW <= (rectScreen.right - rectParent.right) )
	{
		// OK
		nArrowSide = B_ARROWLEFT;
		
		rectBalloon.OffsetRect( 0, rectParent.top + ( (rectParent.Height() - rectBalloon.Height()) * 0.5 ) );
		rectBalloon.OffsetRect( rectParent.right, 0) ;
	
		m_nVMargin = ( rectBalloon.Height() - m_nArrowSM ) * 0.5;

		goto CorrectPos;
	}

	// Left
	if ( rectBalloon.Width() + B_ARROW <= rectParent.left )
	{
		// OK
		nArrowSide = B_ARROWRIGHT;

		rectBalloon.OffsetRect( 0, rectParent.top + ( ( rectParent.Height() - rectBalloon.Height()) * 0.5 ) );
		rectBalloon.OffsetRect( rectParent.left - rectBalloon.Width() - B_ARROW, 0) ;

		m_nVMargin = ( rectBalloon.Height() - m_nArrowSM ) * 0.5;

		goto CorrectPos;
	}
	
	// Bottom
	if ( rectBalloon.Height() + B_ARROW <= (rectScreen.bottom- rectParent.bottom) )
	{
		// OK
		nArrowSide = B_ARROWTOP;

		rectBalloon.OffsetRect( 0, rectParent.bottom + B_ARROW );
		rectBalloon.OffsetRect( rectParent.left - ( rectBalloon.Width() - rectParent.Width() ) * 0.5, 0) ;

		m_nHMargin = ( rectBalloon.Width() - m_nArrowSM ) * 0.5;

		goto CorrectPos;
	}

	// Nowhere is sufficient room
	nArrowSide = B_ARROWRIGHT;
	rectBalloon.OffsetRect( -rectBalloon.left, -rectBalloon.top );
	
	goto End;

CorrectPos:
	if ( rectBalloon.left < 0 )
	{
		m_nHMargin += -rectBalloon.left;
		rectBalloon.OffsetRect( -rectBalloon.left, 0 );
	}

	goto End;
	
End:
	m_nArrowSide = nArrowSide;
	SetSize();

	SetWindowPos(NULL, rectBalloon.left - B_ARROW, rectBalloon.top - B_ARROW, 0, 0,
		SWP_NOSIZE | SWP_NOZORDER );
}
Example #14
0
void CEditorAction::Render(CRect &Pos, CDC& dc,bool EventSelected, CChronoEventEditor& Ed, int renderType, bool bEnabled)
{
	COLORREF ActionBG	=m_select(&Ed)? ACTION_BG_SEL : (EventSelected? ACTION_BG_EVSEL : ACTION_BG);
	// Animating
	if(m_Anim.m_bDestroyed)
	{
		if(renderType == 3)
		{
			Pos.OffsetRect(0,m_Anim.Space);
		}
		if(renderType == 1)
		{
			Pos.OffsetRect(-30 + m_Anim.Space, 0);
		}
		//dc.FillSolidRect(Calc,BG);
		return;
	}

	

	switch(renderType)
	{
/*		case 0:
		{
			if(m_select(&Ed))
			{
				dc.FillSolidRect(Pos,ActionBG);
				dc.Draw3dRect(Pos,ACTION_BG_SEL2,ACTION_BG_SEL2);
			}

			HBITMAP load = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_DOT));
			HDC hdcScreenCompat = CreateCompatibleDC(dc.m_hDC);
			HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcScreenCompat, load);
			BitBlt(dc.m_hDC, Pos.left + 1, Pos.top + 1, 16, 16, hdcScreenCompat, 0, 0, SRCCOPY);
			SelectObject(hdcScreenCompat, hbmpOld);
			DeleteDC(hdcScreenCompat);
			DeleteObject(load);
		}
		break;*/

		case 1:
		{
			if(m_select(&Ed))
			{
				Pos.InflateRect(3,3);
				dc.FillSolidRect(Pos,ActionBG);
				dc.Draw3dRect(Pos,ACTION_BG_SEL2,ACTION_BG_SEL2);
				Pos.DeflateRect(3,3);
			}
			int icon = 0;
			if(m_Family)
				((EventSheetEditor*)(&Ed))->m_familyhbitmaps.Lookup(oid, icon);
			else
				((EventSheetEditor*)(&Ed))->m_objecthbitmaps.Lookup(oid, icon);

			static HDC dcMem = CreateCompatibleDC(dc.m_hDC);
						HBITMAP old = (HBITMAP)SelectObject(dcMem, Ed.GetIcon(icon));
						BitBlt(dc.m_hDC,Pos.left, Pos.top
							,16
							,16,dcMem,0,0,SRCCOPY);
			SelectObject(dcMem, old);
			//DeleteDC(dcMem); - its static so we cant delete it

			m_Anim.Space = 30;
		}
		break;

		case 2:
		{
			CHTMLFont f;
			f.SetBold(false);
			f.SetSize(8);
			f.SetName("Arial");
			f.SetImage(false);

			if (!bEnabled)
				f.SetStrike(true);

			CRect Calc = Pos;
			Calc.bottom  += m_rect(&Ed).Height();

			// Draw the action
			CString Out = m_Text;
			g_HTMLDraw.DrawText(&dc, Out, f, Calc, 0, &Ed, &m_imgs,&params);
			m_Readable = Out;

			Pos.bottom = Pos.top + Calc.Height();
			Calc = Pos;
			dc.FillSolidRect(Pos,ActionBG);

			// We may be hovering over something.
			CPoint mouse;
			GetCursorPos(&mouse);
			Ed.ScreenToClient(&mouse);

			if(Pos.PtInRect(mouse) && m_select(&Ed))
			{
				for(int p = 0; p < params.size(); p++)
					for(int d = 0; d < params[p]->displayrects.size(); d++)
						if(params[p]->displayrects[d].PtInRect(mouse))
						{
							for(int a = 0; a < params[p]->displayrects.size(); a++)
								dc.FillSolidRect(params[p]->displayrects[a], RGB(100,255,100));
							continue;
						}
			}

			// End hover
			Out = m_Text;
			g_HTMLDraw.DrawText(&dc, Out, f, Calc, 0, &Ed, &m_imgs,&params);
			m_Readable = Out;

			if(m_select(&Ed))
				dc.Draw3dRect(Calc,ACTION_BG_SEL2,ACTION_BG_SEL2);
		}
		break;

		case 3:
		{
			CHTMLFont f;
			f.SetBold(false);
			f.SetSize(8);
			f.SetName("Arial");
			f.SetImage(false);

			if (!bEnabled)
				f.SetStrike(true);

			CRect Calc = Pos;
			Calc.bottom  += m_rect(&Ed).Height();

			CString newtext;			
			CObjType* objectType =	((EventSheetEditor*)&Ed)->application->FindObjTypeFromNumber(oid);

			int icon = 0;

			if(m_Family)
				((EventSheetEditor*)(&Ed))->m_familyhbitmaps.Lookup(oid, icon);
			else
				((EventSheetEditor*)(&Ed))->m_objecthbitmaps.Lookup(oid, icon);

			bool show_name = true;
			bool show_icon = true;
			bool show_quotes = true;

			if (m_Text.Find("#noname") != -1) show_name = false;
			if (m_Text.Find("#noicon") != -1) show_icon = false;
			if (m_Text.Find("#noquotes") != -1) show_quotes = false;

			CString display_text = m_Text;

			display_text.Replace("#noname", "");
			display_text.Replace("#noicon", "");
			display_text.Replace("#noquotes", "");

			if (!show_quotes) display_text.Replace("\"", "");

			if (show_name && show_icon)
				newtext.Format("<img>%d</img> %s: %s",  icon, objectType->GetName(), display_text);
			else if (show_name && !show_icon)
				newtext.Format("%s: %s", objectType->GetName(), display_text);
			else if (!show_name && show_icon)
				newtext.Format("<img>%d</img> %s", icon, display_text);
			else
				newtext.Format("%s", display_text);

			CString Out = newtext;
			g_HTMLDraw.DrawText(&dc, Out, f, Calc, 0, &Ed, &m_imgs,&params);

			dc.FillSolidRect(Calc,ActionBG);

			//We may be hovering over something.
			CPoint mouse;
			GetCursorPos(&mouse);
			Ed.ScreenToClient(&mouse);

			if(Calc.PtInRect(mouse) && m_select(&Ed))
			{
				for(int p = 0; p < params.size(); p++)
					for(int d = 0; d < params[p]->displayrects.size(); d++)
						if(params[p]->displayrects[d].PtInRect(mouse))
						{
							for(int a = 0; a < params[p]->displayrects.size(); a++)
								dc.FillSolidRect(params[p]->displayrects[a], RGB(100,255,100));
							continue;
						}
			}


			// End hover
			Calc = Pos;
			Calc.bottom  += m_rect(&Ed).Height();

			// Get readable text
			g_HTMLDraw.DrawText(&dc, newtext, f, Calc, 0, &Ed, &m_imgs,&params);
			m_Readable = newtext.Right(newtext.GetLength() - newtext.ReverseFind(':'));

			Pos.bottom = Pos.top + Calc.Height();
		
			if(m_select(&Ed))
				dc.Draw3dRect(Calc,ACTION_BG_SEL2,ACTION_BG_SEL2);

			m_Anim.Space = Calc.Height();
		}

		break;
	}

	m_visible = true;

	m_rect(&Ed) = Pos;
	if(renderType == 1)
	{
		Pos.InflateRect(3,3);
		m_rect(&Ed) = Pos;
		Pos.DeflateRect(3,3);
	}

	

}
Example #15
0
LRESULT CToolbarsDlg::OnDrawItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	UINT idCtl = (UINT) wParam;             // control identifier 
	LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT) lParam; // item-drawing information 

	if (lpdis->itemID >= 0)
	{
		TCHAR text[256];
		::SendMessage(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, (LPARAM)text);
		IUIDlgSite* dlgbar = (IUIDlgSite*)::SendMessage(lpdis->hwndItem, LB_GETITEMDATA, lpdis->itemID, 0);

		CRect& rcItem = *(CRect*)&lpdis->rcItem;

		int oldBk = SetBkMode(lpdis->hDC, TRANSPARENT);

		FillSolidRect(lpdis->hDC, &rcItem, (lpdis->itemState & ODS_SELECTED)? GetSysColor(COLOR_HIGHLIGHT): GetSysColor(COLOR_WINDOW));

		CRect selectedRect = rcItem;

		BOOL bVisible = FALSE;
		dlgbar->IsVisible(&bVisible);

		CRect cbrect = rcItem;
		cbrect.right = cbrect.left+18;
		cbrect.InflateRect(-1, -1);
		DrawFrameControl(lpdis->hDC, &cbrect, DFC_BUTTON, DFCS_BUTTONCHECK | (bVisible? DFCS_CHECKED: 0));

		/*
		if (imageIndex >= 0)
		{
			selectedRect.left += 20;

			CRect iconrect = rcItem;
			iconrect.right = iconrect.left+20;

			int cx, cy;
			ImageList_GetIconSize(hImageList, &cx, &cy);

			ImageList_Draw(hImageList, imageIndex, lpdis->hDC, iconrect.left+(iconrect.Width()-cx)/2, iconrect.top+(iconrect.Height()-cy)/2, ILD_TRANSPARENT);

			if (lpdis->itemState & ODS_SELECTED)
			{
				Draw3DRect(lpdis->hDC, &iconrect, GetSysColor(COLOR_3DHILIGHT), GetSysColor(COLOR_3DSHADOW));
			}
		}
		*/

//		FillSolidRect(lpdis->hDC, &selectedRect, (lpdis->itemState & ODS_SELECTED)? GetSysColor(COLOR_HIGHLIGHT): GetSysColor(COLOR_BTNFACE));

		CRect trect = rcItem;
		trect.left += 22;
		SetTextColor(lpdis->hDC, (lpdis->itemState & ODS_SELECTED)? GetSysColor(COLOR_HIGHLIGHTTEXT): GetSysColor(COLOR_WINDOWTEXT));
		DrawText(lpdis->hDC, text, lstrlen(text), &trect, DT_SINGLELINE | DT_VCENTER);

		/*
		if (cmdType == 1)
		{
			CRect textbnd(0,0,0,0);
			DrawText(lpdis->hDC, text, lstrlen(text), &textbnd, DT_SINGLELINE | DT_CALCRECT);

			int height = 18;
			int top = rcItem.top + (rcItem.Height()-height)/2;

			Rectangle(lpdis->hDC, trect.left + textbnd.Width()+2, top, rcItem.right-2, top+height);

			CRect arrowrect(rcItem.right-2-18+1, top+1, rcItem.right-2-1, top+height-1);
			DrawFrameControl(lpdis->hDC, &arrowrect, DFC_SCROLL, DFCS_SCROLLCOMBOBOX | DFCS_FLAT);
		}
		*/

		SetBkMode(lpdis->hDC, oldBk);
	}

	return 0;
}
Example #16
0
LRESULT CDataGrid::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	CPaintDC dc(m_hWnd);

	CRect client;
	GetClientRect(&client);

	if (m_rs)
	{
		long scrollposY; m_vert->get_pos(&scrollposY);

		dc.SetBkMode(TRANSPARENT);

		HFONT hOldFont = (HFONT)dc.SelectFont((HFONT)GetStockObject(DEFAULT_GUI_FONT));

		long nfields = m_rs->Fields->Count;
		int rightX;

		// Draw column headers
		{
			dc.FillSolidRect(0, 0, client.right, 18, GetSysColor(COLOR_BTNFACE));

			int x = 18;

			{
				CRect rect(0, 0, x, 18);
				dc.Draw3dRect(&rect, GetSysColor(COLOR_3DHILIGHT), GetSysColor(COLOR_3DDKSHADOW));
			}

			for (int nfld = 0; nfld < nfields; nfld++)
			{
				ADODB::FieldPtr fld = m_rs->Fields->GetItem(&_variant_t((long)nfld));

				_bstr_t fldName = fld->Name;

				CRect rect(x, 0, x+160, 18);
				dc.Draw3dRect(&rect, GetSysColor(COLOR_3DHILIGHT), GetSysColor(COLOR_3DDKSHADOW));

				CRect trect = rect;
				trect.InflateRect(-1, -1);

				dc.DrawText(fldName, fldName.length(), &trect, DT_SINGLELINE | DT_VCENTER);

				x += 160;
			}

			rightX = x;
		}

		// Draw rows
		if (dc.IntersectClipRect(0, 18, client.right-16, client.bottom) > NULLREGION)
		{
			dc.SetViewportOrg(0, -scrollposY);

			int y = 18;
			int itemHeight = 60;

			m_rs->MoveFirst();

			while (!(m_rs->EndOfFile))
			{
				int x = 18;

				// Draw left margin of row
				{
					CRect rect(0, y, x, y+itemHeight);
					dc.FillSolidRect(&rect, GetSysColor(COLOR_BTNFACE));
					dc.Draw3dRect(&rect, GetSysColor(COLOR_3DHILIGHT), GetSysColor(COLOR_3DDKSHADOW));
				}

				for (int nfld = 0; nfld < nfields; nfld++)
				{
					ADODB::FieldPtr fld = m_rs->Fields->GetItem(&_variant_t((long)nfld));

					ADODB::DataTypeEnum type = fld->Type;

					CRect rect(x, y, x+160, y+itemHeight);

					CRect trect = rect;
					trect.InflateRect(-1, -1);

					_bstr_t vStr;

					if (type == ADODB::adLongVarBinary)
					{
						long size = fld->ActualSize;

						_variant_t varr = fld->GetChunk(size);

						WCHAR* p;
						if (SUCCEEDED(SafeArrayAccessData(varr.parray, (void**)&p)))
						{
							vStr = _bstr_t(p);

							SafeArrayUnaccessData(varr.parray);
						}
					}
					else
					{
						_variant_t v;

						try
						{
							v = fld->Value;


							if (v.vt == VT_NULL)
							{
								vStr = L"<NULL>";
							}
							else
							{
								vStr = v;
							}
						}
						catch (_com_error &e)
						{
							ATLASSERT(0);
						}
					}

					ATLTRACE("%S\n", (BSTR)vStr);
					dc.DrawText(vStr, vStr.length(), &trect, DT_WORDBREAK);

					x += 160;

				// Draw vertical separator between columns
					dc.FillSolidRect(x, y, 1, itemHeight, GetSysColor(COLOR_3DLIGHT));
				}

				m_rs->MoveNext();

				y += itemHeight;

			// Draw horizontal separator between rows
				dc.FillSolidRect(18, y, rightX-18, 1, GetSysColor(COLOR_3DLIGHT));
			}
		}

		dc.SelectFont(hOldFont);
	}

	return 0;
}
void CBCGPPlannerViewMonth::AdjustRects ()
{
	const int nDays = GetViewDuration ();

	const int nRows    = nDays / 7;
	const int dxColumn = CBCGPPlannerView::round (m_rectApps.Width () / (m_bCompressWeekend ? 6.0 : 7.0)) - 1;
	const int dxRow    = CBCGPPlannerView::round (m_rectApps.Height () / (double)nRows) - 1;

	const int nDayStart = (IsCompressWeekend () && CBCGPPlannerManagerCtrl::GetFirstDayOfWeek () == 0)
		? 1
		: CBCGPPlannerManagerCtrl::GetFirstDayOfWeek ();

	if (m_ViewRects.GetSize () != nDays)
	{
		m_ViewRects.SetSize (nDays);
	}

	int iRow = 0;
	for (iRow = 0; iRow < nRows; iRow++)
	{
		CRect rect (m_rectApps);
		rect.right   = rect.left + dxColumn;
		rect.top    += iRow * (dxRow + 1);
		rect.bottom  = iRow == (nRows - 1) ? rect.bottom : rect.top + dxRow;

		int nTop    = rect.top;
		int nBottom = rect.bottom;

		int nColumn = 0;

		for (int iDay = 0; iDay < 7; iDay++)
		{
			int nWeekDay = nDayStart + iDay - 7;

			if (m_bCompressWeekend)
			{
				if (nWeekDay == -1)
				{
					rect.bottom = rect.top + dxRow / 2;
				}
				else if (nWeekDay == 0)
				{
					rect.top = rect.bottom + 1;
					rect.bottom = nBottom;
				}
				else
				{
					rect.top = nTop;
				}
			}

			m_ViewRects[iRow * 7 + iDay] = rect;

			if ((m_bCompressWeekend && nWeekDay != -1) || !m_bCompressWeekend)
			{
				rect.OffsetRect (dxColumn + 1, 0);

				nColumn++;

				if ((m_bCompressWeekend && nColumn == 5) ||
					(!m_bCompressWeekend && nColumn == 6))
				{
					rect.right = m_rectApps.right;
				}
			}
		}
	}

	if (m_nWeekBarWidth > 0)
	{
		int nIndex = 0;
		if (IsCompressWeekend () && m_ViewRects[0].top != m_ViewRects[1].top)
		{
			nIndex = 2;
		}

		m_WeekRects.SetSize (nRows);

		for (iRow = 0; iRow < nRows; iRow++)
		{
			CRect rect (m_ViewRects[nIndex]);
			rect.right = m_rectApps.left;
			rect.left  = rect.right - m_nRowHeight;

			rect.top    += m_nRowHeight;
			rect.InflateRect (0, 1);

			m_WeekRects[iRow] = rect;

			nIndex += 7;
		}
	}
}
//************************************************************************************
void CBCGPDateTimeCtrl::OnLButtonDown(UINT /*nFlags*/, CPoint point) 
{
	m_iPrevDigit = -1;

	int iPrevPart = m_iPartNum;

	SetFocus ();

	if (m_rectDropButton.PtInRect (point) && IsWindowEnabled())
	{
		if (m_dropCalendar && m_bIsChecked && m_showDate)
		{
			m_bDropButtonIsPressed = TRUE;

			SetCapture ();
			RedrawWindow (m_rectDropButton);

			OnShowCalendarPopup ();
		}

		return;
	}

	int iPartNum = GetPartFromPoint (point);
	if (iPartNum == -1)
	{
		m_CurrPartType = NO;

		if (m_rectText.PtInRect (point))
		{
			do
			{
				point.x++;

				if (point.x > m_rectText.right)
				{
					return;
				}

				iPartNum = GetPartFromPoint (point);
			}
			while (iPartNum == -1);
		}
		else
		{
			return;
		}
	}

	if (!m_bIsChecked &&
		m_arPartsOrder [iPartNum] != CHECK_BOX)
	{
		return;
	}

	m_iPartNum = iPartNum;
	m_CurrPartType = m_arPartsOrder [m_iPartNum];

	if (m_CurrPartType == CHECK_BOX)
	{
		ToggleCheck ();
	}

	if (iPrevPart != m_iPartNum)
	{
		CRect rectPrevPart = m_arPartRects [iPrevPart];
		rectPrevPart.InflateRect (1, 1);
		RedrawWindow (rectPrevPart);

		CRect rectPart = m_arPartRects [m_iPartNum];
		rectPart.InflateRect (1, 1);
		RedrawWindow (rectPart);
	}
}
//***************************************************************************************
LRESULT CALLBACK CBCGPFileDialog::WindowProcNew(HWND hwnd,UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_NOTIFY:
		{
			CBCGPFileDialog* pFD = GetBCGFileDlg (hwnd);

			LPNMHDR pHdr = (LPNMHDR) lParam;
			ASSERT (pHdr != NULL);

			if (wParam == iTabCtrlId && pHdr->code == TCN_SELCHANGE)
			{
				pFD->OnTabSelchange();
			}
			else if ((wParam == iNewListCtrlId || wParam == iRecentListCtrlId) 
				&& pHdr->code == NM_DBLCLK)
			{
				pFD->OnItemDblClick();
			}
		}
		break;

	case WM_COMMAND:
		{
			if ((int) LOWORD(wParam) == IDOK)
			{
				CBCGPFileDialog* pFD = GetBCGFileDlg (hwnd);
				if (pFD->GetPage () != CBCGPFileDialog::BCGFileOpen)
				{
					pFD->OnItemDblClick();
					return 0;
				}
			}
		}
		break;

	case WM_PAINT:
		{
			CBCGPFileDialog* pFD = GetBCGFileDlg (hwnd);
			pFD->CollectControls ();
	
			if (pFD->m_pBmpLogo != NULL)
			{
				ASSERT_VALID (pFD->m_pBmpLogo);

				CFileDialog* pDlg = (CFileDialog*)CWnd::FromHandle (hwnd);
				ASSERT (pDlg != NULL);

				CPaintDC dc (pDlg); // device context for painting
				dc.DrawState (pFD->m_rectLogo.TopLeft (),
					pFD->m_rectLogo.Size (), pFD->m_pBmpLogo,
					DSS_NORMAL);

				CRect rectFrame = pFD->m_rectLogo;
				rectFrame.InflateRect (1, 1);

				dc.Draw3dRect (rectFrame, globalData.clrBtnShadow, globalData.clrBtnLight);
			}
		}
		break;

	case WM_SIZE:
		{
			LRESULT lRes = CallWindowProc(CBCGPFileDialog::m_wndProc, hwnd, message, wParam, lParam);

			CBCGPFileDialog* pFD = GetBCGFileDlg (hwnd);
			ASSERT_VALID (pFD);

			CWnd* pFDParent = pFD->GetParent();
			ASSERT (pFDParent != NULL);

			CRect rectTabs;
			pFDParent->GetClientRect (rectTabs);
			rectTabs.DeflateRect (4, 4);
			rectTabs.top += pFD->m_iLogoAreaHeight;

			pFD->m_wndTab.SetWindowPos (NULL, -1, -1,
				rectTabs.Width (), rectTabs.Height (),
				SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);

			pFD->m_lstFDControls.RemoveAll ();
			pFD->CollectControls ();

			return lRes;
		}
	}

	return CallWindowProc(CBCGPFileDialog::m_wndProc, hwnd, message, wParam, lParam);
}
Example #20
0
void COptionTreeImagePopUp::OnLButtonUp(UINT nFlags, CPoint point) 
{
	// Declare variables
	BOOL bFound = FALSE;
	CRect rcImage;
	CRect rcClient;

	// Get client rect
	GetClientRect(rcClient);

	// See if user clicked outside window
	if (rcClient.PtInRect(point) == FALSE)
	{
		// ALWAYS send message to parent
		if (IsWindow(m_pParent->GetSafeHwnd()))
		{
			m_pParent->SendMessage(OT_IMAGE_CLOSE, 0, m_nSelected);
		}

		ReleaseCapture();
		DestroyWindow();
		return;
	}

	// Go through all images
	for (int i = 0; i < m_pImageList->GetImageCount(); i++)
	{
		// -- Get rectangle
		rcImage = m_rcRectangles.GetAt(i);

		// -- See if selected
		if (m_nSelected == i)
		{
			rcImage.InflateRect(3, 3, 3, 3);
		}

		// -- Hit test
		if (rcImage.PtInRect(point) == TRUE)
		{
			// -- -- Select this image
			m_nSelected = i;

			// -- -- Found
			bFound = TRUE;

			break;
		}
	}

	// Close
	if (bFound == TRUE)
	{
		// ALWAYS send message to parent
		if (IsWindow(m_pParent->GetSafeHwnd()))
		{
			m_pParent->SendMessage(OT_IMAGE_CLOSE, 0, m_nSelected);
		}

		ReleaseCapture();
		DestroyWindow();
		return;
	}


	// Handle left click
	CWnd::OnLButtonUp(nFlags, point);
}
Example #21
0
void COptionTreeList::OnPaint() 
{
	// Make sure valid
	if (m_otOption == NULL)
	{
		return;
	}
	
	// Declare variables
	CPaintDC dc(this);
	CDC* pDCMem = new CDC;
	CBitmap bpMem;
	CBitmap *bmOld;
	COptionTreeItem* otiItem;
	CRect rcClient;
	HGDIOBJ hOldBrush;
	long lTotal, lHeight;
	HRGN hRgn;

	// Get client rectangle
	GetClientRect(rcClient);

	// Clear visible list
	m_otOption->ClearVisibleList();

	// Clear all label rectangle
	m_otOption->ClearAllLabelRect();

	// Create DC
	pDCMem->CreateCompatibleDC(&dc);

	// Create bitmap
	bpMem.CreateCompatibleBitmap(&dc, rcClient.Width(), rcClient.Height());

	// Select bitmap
	bmOld = pDCMem->SelectObject(&bpMem);

	// Draw control background
	hOldBrush = pDCMem->SelectObject(GetSysColorBrush(COLOR_BTNFACE));
	pDCMem->PatBlt(rcClient.left, rcClient.top, rcClient.Width(), rcClient.Height(), PATCOPY);

	// Draw control inside fill color
	rcClient.DeflateRect(2, 2);
	if (m_otOption->IsWindowEnabled() == TRUE)
	{
		pDCMem->SelectObject(GetSysColorBrush(COLOR_WINDOW));
	}
	else
	{
		pDCMem->SelectObject(GetSysColorBrush(COLOR_3DFACE));
	}
	pDCMem->PatBlt(rcClient.left, rcClient.top, rcClient.Width(), rcClient.Height(), PATCOPY);
	rcClient.InflateRect(2, 2);

	// Draw expand column	
	if (m_otOption->GetShadeExpandColumn() == TRUE || m_otOption->IsWindowEnabled() == FALSE)
	{
		pDCMem->SelectObject(GetSysColorBrush(COLOR_BTNFACE));
	}
	else
	{
		pDCMem->SelectObject(GetSysColorBrush(COLOR_WINDOW));
	}
	pDCMem->PatBlt(0, 0, OT_EXPANDCOLUMN, rcClient.Height(), PATCOPY);

	// Create clip region
	hRgn = CreateRectRgn(rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
	SelectClipRgn(pDCMem->m_hDC, hRgn);

	// Draw all items
	lTotal = 0;
	for (otiItem = m_otOption->GetRootItem()->GetChild(); otiItem != NULL; otiItem = otiItem->GetSibling())
	{
		lHeight = otiItem->DrawItem(pDCMem, rcClient, 0, lTotal);
		lTotal += lHeight;
	}

	// Remove clip region
	SelectClipRgn(pDCMem->GetSafeHdc(), NULL);
	DeleteObject(hRgn);

	// Draw vertical sep
	_DrawDarkVLine(pDCMem->GetSafeHdc(), OT_EXPANDCOLUMN, 0, rcClient.bottom);

	// Draw edge
	pDCMem->DrawEdge(&rcClient, BDR_SUNKENOUTER, BF_RECT);

	// Draw draw column
	if (m_bColDrag == TRUE)
	{
		_DrawXorBar(pDCMem->GetSafeHdc(), m_lColumn - OT_COLRNG / 2, 0, 4, rcClient.bottom);
	}

	// Copy back buffer to the display
	dc.BitBlt(0, 0, rcClient.Width(), rcClient.Height(), pDCMem, 0, 0, SRCCOPY);
	
	// Select old objects
	pDCMem->SelectObject(hOldBrush);
	pDCMem->SelectObject(bmOld);
	
	// Delete objects
	if (pDCMem->GetSafeHdc() != NULL)
	{
		pDCMem->DeleteDC();
	}
	delete pDCMem;
	if (bpMem.GetSafeHandle() != NULL)
	{
		bpMem.DeleteObject();
	}

}
Example #22
0
//****************************************************************************************
BOOL CBCGPropertySheet::OnInitDialog() 
{
	BOOL bResult = CPropertySheet::OnInitDialog();
	BOOL bReposButtons = FALSE;

	const int nVertMargin = 5;
	const int nHorzMargin = 5;

	CWnd* pWndNavigator = InitNavigationControl ();

	CRect rectClient;
	GetClientRect (rectClient);

	if (m_wndTab.GetSafeHwnd () != NULL)
	{
		CTabCtrl* pTab = GetTabControl ();
		ASSERT_VALID (pTab);

		CRect rectTab;
		pTab->GetWindowRect (rectTab);
		ScreenToClient (rectTab);

		rectTab.InflateRect (2, 0);

		if (pTab->GetItemCount () > 0)
		{
			CRect rectTabsNew;
			m_wndTab.GetTabsRect (rectTabsNew);

			CRect rectTabsOld;
			pTab->GetItemRect (0, rectTabsOld);

			const int nOldHeight = rectTabsOld.Height ();
			const int nNewHeight = rectTabsNew.Height ();

			if (nNewHeight > nOldHeight)
			{
				rectClient.bottom += nNewHeight - nOldHeight + nVertMargin;
				rectTab.bottom += nNewHeight - nOldHeight;

				SetWindowPos (NULL, -1, -1,
					rectClient.Width (), rectClient.Height (),
					SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
			}
		}

		m_wndTab.MoveWindow (rectTab);

		pTab->ModifyStyle (WS_TABSTOP, 0);
		pTab->ShowWindow (SW_HIDE);

		if (pTab->GetItemCount () > 0)
		{
			m_wndTab.SetActiveTab (0);
		}

		bReposButtons = TRUE;
	}
	else if (pWndNavigator != NULL)
	{
		CTabCtrl* pTab = GetTabControl ();
		ASSERT_VALID (pTab);

		pTab->ModifyStyle (WS_TABSTOP, 0);

		CRect rectTabItem;
		pTab->GetItemRect (0, rectTabItem);
		pTab->MapWindowPoints (this, &rectTabItem);

		const int nTabsHeight = rectTabItem.Height () + nVertMargin;

		SetWindowPos (NULL, -1, -1, rectClient.Width () + m_nBarWidth,
			rectClient.Height () - nTabsHeight + 4 * nVertMargin,
			SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
		
		GetClientRect (rectClient);
		pTab->MoveWindow (m_nBarWidth, -nTabsHeight, rectClient.right, rectClient.bottom - 2 * nVertMargin);

		CRect rectTab;
		pTab->GetWindowRect (rectTab);
		ScreenToClient (rectTab);

		CRect rectNavigator = rectClient;
		rectNavigator.right = rectNavigator.left + m_nBarWidth;
		rectNavigator.bottom = rectTab.bottom;
		rectNavigator.DeflateRect (1, 1);

		pWndNavigator->SetWindowPos (&wndTop, 
							rectNavigator.left, rectNavigator.top,
							rectNavigator.Width (), 
							rectNavigator.Height (),
							SWP_NOACTIVATE);

		SetActivePage (GetActivePage ());

		bReposButtons = TRUE;
	}

	if (bReposButtons)
	{
		int ids[] = { IDOK, IDCANCEL, ID_APPLY_NOW, IDHELP	};

		int nTotalButtonsWidth = 0;

		for (int iStep = 0; iStep < 2; iStep++)
		{
			for (int i = 0; i < sizeof (ids) / sizeof (ids [0]); i++)
			{
				CWnd* pButton = GetDlgItem (ids[i]);

				if (pButton != NULL)
				{
					if (ids [i] == IDHELP && (m_psh.dwFlags & PSH_HASHELP) == 0)
					{
						continue;
					}

					if (ids [i] == ID_APPLY_NOW && (m_psh.dwFlags & PSH_NOAPPLYNOW))
					{
						continue;
					}

					CRect rectButton;
					pButton->GetWindowRect (rectButton);
					ScreenToClient (rectButton);

					if (iStep == 0)
					{
						// Align buttons at the bottom
						pButton->SetWindowPos (&wndTop, rectButton.left, 
							rectClient.bottom - rectButton.Height () - nVertMargin, 
							-1, -1, SWP_NOSIZE | SWP_NOACTIVATE);

						nTotalButtonsWidth = rectButton.right;
					}
					else
					{
						// Right align the buttons
						pButton->SetWindowPos (&wndTop, 
							rectButton.left + rectClient.right - nTotalButtonsWidth - nHorzMargin,
							rectButton.top,
							-1, -1, SWP_NOSIZE | SWP_NOACTIVATE);
					}
				}
			}
		}
	}

	return bResult;
}
Example #23
0
void CTrack::Draw(bool bOn, HDC hDC)
{
	if (!m_pAGDC)
		return;

	m_bIsDrawn = bOn;

	if (!hDC)
		hDC = m_pAGDC->GetHDC();

	CPoint pt[4];
	pt[0] = m_Distort.p[0];
	pt[1] = m_Distort.p[1];
	pt[2] = m_Distort.p[2];
	pt[3] = m_Distort.p[3];

	CAGMatrix Matrix = m_Matrix * m_ViewToDeviceMatrix;

	// A trick to draw the selection rectangle outside of a transformed object
	if (!(m_iWhatCanDo & TR_DRAWASLINE))
	{
		CRect Offset(-1, -1, 0, 0);
		Matrix.Inverse().Transform((CPoint*)&Offset, 2, false);

		pt[0].x += Offset.left;
		pt[0].y += Offset.top;
		pt[1].x += Offset.right;
		pt[1].y += Offset.top;
		pt[2].x += Offset.right;
		pt[2].y += Offset.bottom;
		pt[3].x += Offset.left;
		pt[3].y += Offset.bottom;
	}

	Matrix.Transform(pt[0]);
	Matrix.Transform(pt[1]);
	Matrix.Transform(pt[2]);
	Matrix.Transform(pt[3]);

	// Before drawing the transform border, open up the clipping to include a border pixel
	HRGN hClipRegion = m_pAGDC->SaveClipRegion();
	CRect rClipRect = m_PageRect;	
	rClipRect.InflateRect(1, 1); // Add a border pixel
	rClipRect.InflateRect(H_SIZE, H_SIZE); // Add the tracking handle size
	m_pAGDC->SetClipRect(rClipRect);

	if (m_iWhatCanDo & TR_DRAWASLINE)
	{
		DrawLine(hDC, pt[0].x, pt[0].y, pt[2].x, pt[2].y, bOn);
	}
	else
	{
		Hline(hDC, pt[0].x, pt[0].y, pt[1].x, pt[1].y, bOn);
		Hline(hDC, pt[1].x, pt[1].y, pt[2].x, pt[2].y, bOn);
		Hline(hDC, pt[2].x, pt[2].y, pt[3].x, pt[3].y, bOn);
		Hline(hDC, pt[3].x, pt[3].y, pt[0].x, pt[0].y, bOn);
	}

	DrawHandles(hDC, bOn, pt);

	m_pAGDC->RestoreClipRegion(hClipRegion);
}
void CRemoteFileDialog::PostCreate()
{
	if (m_toolbar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE))
	{
		UINT nStyle = m_toolbar.GetBarStyle();
		nStyle &= ~(CCS_NORESIZE | CCS_NOPARENTALIGN | CBRS_BORDER_ANY);
		nStyle |= (CBRS_SIZE_FIXED | CBRS_TOOLTIPS | CBRS_FLYBY);
		m_toolbar.SetBarStyle(nStyle);

		m_toolbar.GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);

		int iImage = m_toolbar.GetToolBarCtrl().SendMessage(TB_LOADIMAGES, IDB_VIEW_SMALL_COLOR, (LPARAM)HINST_COMMCTRL);

		// add 'up folder' item
		TBBUTTON tbbUp = { iImage + VIEW_PARENTFOLDER, ID_UPONELEVEL, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 };
		m_toolbar.GetToolBarCtrl().InsertButton(0, &tbbUp);

		// add 'view' item with drop menu
		TBBUTTON tbbView = { iImage + VIEW_LIST, ID_VIEWMENU, TBSTATE_ENABLED, TBSTYLE_BUTTON | TBSTYLE_DROPDOWN, 0, 0 };
		m_toolbar.GetToolBarCtrl().InsertButton(1, &tbbView);

		// move to topright corner
		CDlgUnits dlu(*this);
		CRect rToolbar, rButton;

		GetClientRect(rToolbar);
		m_toolbar.GetItemRect(1, rButton);

		rToolbar.top += dlu.ToPixelsY(4);
		rToolbar.right -= dlu.ToPixelsX(7);
		rToolbar.left = rToolbar.right - rButton.right;
		rToolbar.bottom = rToolbar.top + rButton.Height();

		m_toolbar.MoveWindow(rToolbar);

		CRect rCtrl = OffsetCtrl(IDC_CURRENTFOLDER);
		ResizeCtrl(IDC_CURRENTFOLDER, rToolbar.left - rCtrl.right - 4, 0);
	}

	// restore size
	DWORD dwSize = AfxGetApp()->GetProfileInt(_T("RemoteSettings"), _T("LastSize"), -1);

	if (dwSize != -1)
	{
		int nWidth = LOWORD(dwSize);
		int nHeight = HIWORD(dwSize);

		// centre on current position
		CRect rWindow;
		GetWindowRect(rWindow);

		rWindow.InflateRect((nWidth - rWindow.Width()) / 2, (nHeight - rWindow.Height()) / 2);
		MoveWindow(rWindow);
	}

	// restore last view
	int nView = AfxGetApp()->GetProfileInt(_T("RemoteSettings"), _T("LastView"), LVS_LIST);
	OnChangeView(VIEWIDS[nView]);

	// init resize icon
	GetDlgItem(IDC_GRIPPER)->ModifyStyle(0, SBS_SIZEGRIP | SBS_SIZEBOXTOPLEFTALIGN);

	// and fill the file list
	SetCurrentFolder(m_sCurFolder);
}
Example #25
0
bool CTrack::SetCursor(int x, int y, bool bInsideMoveAllowed, bool& bPtInBorder, bool& bPtInHandle)
{
	if (m_bDisabled)
		return false;

	CPoint Point(x, y);
	HINSTANCE hInst = NULL;
	LPCSTR lpCursor = NULL;
	bPtInBorder = false;
	bPtInHandle = false;
	for (int h = 0; h < NUM_HANDLES; h++)
	{
		if (!m_iHandleInUse[h])
			continue;

		if (!PtInRect(&m_hHandleRects[h], Point))
			continue;

		bPtInHandle = true;
		switch (h)
		{
			case H_ROTATE:
				lpCursor = IDC_CROSS; //j MAKEINTRESOURCE(ID_ROTATE);
				hInst = _AtlBaseModule.GetResourceInstance();
				break;
			case H_CENTER:
				lpCursor = IDC_ARROW;
				break;
			case H_CORNER_UL:
			case H_CORNER_UR:
			case H_CORNER_LR:
			case H_CORNER_LL:
				lpCursor = IDC_ARROW;
				break;
			case H_UL:
			case H_LR:
				lpCursor = IDC_SIZENWSE;
				break;
			case H_UR:
			case H_LL:
				lpCursor = IDC_SIZENESW;
				break;
			case H_TOP:
			case H_BOTTOM:
				lpCursor = IDC_SIZENS;
				break;
			case H_LEFT:
			case H_RIGHT:
				lpCursor = IDC_SIZEWE;
				break;
			default:
				break;
		}
		break;
	}

	if (!lpCursor)
	{
		if (PtInBorder(Point))
			bPtInBorder = true;

		CRect rect = m_Distort.Rect;
		m_Matrix.Transform(rect);
		m_ViewToDeviceMatrix.Transform(rect);
		// Make sure the rect is big enough to grab
		if (rect.Width() < 20)
			rect.InflateRect(10, 0);
		if (rect.Height() < 20)
			rect.InflateRect(0, 10);

		if (bPtInBorder || (bInsideMoveAllowed && PtInRect(&rect, Point)))
			lpCursor = IDC_SIZEALL;
	}

	if (lpCursor)
	{
		::SetCursor(::LoadCursor(hInst, lpCursor));
		return true;
	}

	return false;
}
Example #26
0
void CMyButton::DrawButton(HDC hDestDC)
{
	CRect rc;
	GetClientRect(rc);
	int nWindth=rc.Width();
	int nHeight=rc.Height();
	HDC hDC=CreateCompatibleDC(hDestDC);//创建兼容DC,采用双缓冲画出
	HDC hMaskDC=CreateCompatibleDC(hDestDC);
	HBITMAP hBitmap=CreateCompatibleBitmap(hDestDC,nWindth,nHeight);
	HBITMAP hMaskBitmap=CreateCompatibleBitmap(hDestDC,nWindth,nHeight);
	HBITMAP hOldBitmap=(HBITMAP)SelectObject(hDC,hBitmap);
	HBITMAP hOldMaskBitmap=(HBITMAP)SelectObject(hMaskDC,hMaskBitmap);
	SetBkMode(hDC,TRANSPARENT);

	//把父窗口的背景图复制到按钮的DC上,实现视觉透明----------------
	CShellDlg* pParent=(CShellDlg*)GetParent();
	CPoint pt(0,0);
	MapWindowPoints(pParent,&pt,1);
	pParent->m_bkImage.BitBlt(hDC,rc,pt,SRCCOPY);


	//-------------------------------------------------------------
	int nAlpha=100;//0--255
	int nOffset=0;

	HBRUSH hbr=CreateSolidBrush(m_bkColor);
	FillRect(hMaskDC,&rc,hbr);
	DeleteObject(hbr);

	if(m_bDisable){
		nAlpha=0;//100
	}else if(m_bDown){
		nAlpha=0;//180
		nOffset=1;
	}else if(m_bOver){
		nAlpha=0;//150
	}else{
		nAlpha=0;//100
	}
	BLENDFUNCTION blend;
	memset( &blend, 0, sizeof( blend) );
	blend.BlendOp= AC_SRC_OVER;
	blend.SourceConstantAlpha= nAlpha; // 透明度 最大255

	HRGN hRgn=CreateRoundRectRgn(0,0,nWindth,nHeight,3,3);
	SelectClipRgn (hDC,hRgn);
	AlphaBlend (hDC,0,0,nWindth,nHeight,hMaskDC, 0,0,nWindth,nHeight,blend);

	CString strText;
	GetWindowText(strText);
	if(strText!=_T("")){
		rc.InflateRect(-2,-2);
		rc.OffsetRect(nOffset,nOffset);
		HFONT hFont=(HFONT)SendMessage(WM_GETFONT);
		if(!hFont)hFont=(HFONT)GetStockObject(DEFAULT_GUI_FONT);
		HFONT hOldFont=(HFONT)SelectObject(hDC,hFont);
		::SetTextColor(hDC,m_textColor);
		::DrawText(hDC,strText,-1,&rc,DT_SINGLELINE|DT_CENTER|DT_VCENTER|DT_WORD_ELLIPSIS);
		::SelectObject(hDC,hOldFont);
	}
	SelectClipRgn (hDC,NULL);
	DeleteObject(hRgn);
	//复制到控件的DC上------------------------
	BitBlt(hDestDC,0,0,nWindth,nHeight,hDC,0,0,SRCCOPY);
	//删除资源,释放内存-----------------------
	SelectObject(hDC,hOldBitmap);
	DeleteObject(hBitmap);
	DeleteDC(hDC);
	SelectObject(hMaskDC,hOldMaskBitmap);
	DeleteObject(hMaskBitmap);
	DeleteDC(hMaskDC);

}
Example #27
0
void CEditSpinSlider::OnNcPaint() 
{

	
	if (!before) { //If first time, the OnNcCalcSize function will be called
			SetWindowPos(NULL,0,0,64,32,SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE); 
			before=true;
	}	
	
	
	
	// TODO: Add your message handler code here
//	CPaintDC dc(this); // device context for painting
	CDC* p_Dc = GetDC();
	bool selected = false;
	if(HIWORD(CEdit::GetMargins())!= 24)
		CEdit::SetMargins(0,0);

	CRect Client;
	GetClientRect(&Client);

	Client.InflateRect(1,1,23,4);
	p_Dc->Draw3dRect(Client,g_PaintManager->GetColor(COLOR_3DSHADOW),g_PaintManager->GetColor(COLOR_3DSHADOW));

	Client.DeflateRect(1,1,23,4);

	CRect BG(Client.right,Client.top,Client.right+22,Client.bottom);

	selected = (m_downOn==30);
	p_Dc->FillSolidRect(BG,0xffffff);
	CRect Up(Client.right,Client.top+1,Client.right+10,Client.top+(Client.Height()/2)-1);
	p_Dc->FillSolidRect(Up,selected?g_PaintManager->GetColor(COLOR_3DSHADOW):g_PaintManager->GetColor(COLOR_3DFACE));

	DRAWARROWUP(((Up.left+Up.right)/2-3),((Up.top+Up.bottom)/2-1))
//DRAWARROWUP(0,0)

	selected = (m_downOn==31);
	CRect Down = Up;
	Down.top = Up.bottom+1;
	Down.bottom = Client.bottom-1;
	
	p_Dc->FillSolidRect(Down,selected?g_PaintManager->GetColor(COLOR_3DSHADOW):g_PaintManager->GetColor(COLOR_3DFACE));
	DRAWARROWDOWN(((Down.left+Down.right)/2-3),((Down.top+Down.bottom)/2-1))

	CRect Right = Up;
	Right.bottom = Down.bottom;
	Right.left = Up.right+1;
	Right.right = Client.right+21;
	selected = (m_downOn==32);
	p_Dc->FillSolidRect(Right,selected?g_PaintManager->GetColor(COLOR_3DSHADOW):g_PaintManager->GetColor(COLOR_3DFACE));
	DRAWARROWDOWN(((Right.left+Right.right)/2-3),((Right.top+Right.bottom)/2-1))

	CRect Bottom = CRect(Client.left,Client.bottom,Client.right+22,Client.bottom + 3);
	p_Dc->FillSolidRect(Bottom,g_PaintManager->GetColor(COLOR_3DFACE));

	CRect Show = Bottom;
	CString Content;
	GetWindowText(Content);
	
	Show.right = Show.left + (Show.Width() * (atoi(Content)-m_Min)/(m_Max-m_Min+0.0));
	p_Dc->FillSolidRect(Show,m_Color);
	// Do not call CEdit::OnNcPaint() for painting messages
}
DROPEFFECT CBCGPPlannerDropTarget::OnDragScroll(CWnd* pWnd, DWORD dwKeyState, CPoint point)
{
	if (m_pPlanner == NULL)
	{
		return DROPEFFECT_NONE;
	}

	ASSERT_VALID (m_pPlanner);

	DROPEFFECT dropEffect = m_pPlanner->OnDragScroll(dwKeyState, point);

	// DROPEFFECT_SCROLL means do the default
	if (dropEffect != DROPEFFECT_SCROLL)
		return dropEffect;

	// get client rectangle of destination window
	CRect rectClient;
	m_pPlanner->GetDragScrollRect(rectClient);
	CRect rect = rectClient;

	// hit-test against inset region
	UINT nTimerID = MAKEWORD(-1, -1);
	rect.InflateRect(-nScrollInset, -nScrollInset);

	if (rectClient.PtInRect(point) && !rect.PtInRect(point))
	{
		// determine which way to scroll along both X & Y axis
		if (point.x < rect.left)
		{
			nTimerID = MAKEWORD(SB_LINEUP, HIBYTE(nTimerID));
		}
		else if (point.x >= rect.right)
		{
			nTimerID = MAKEWORD(SB_LINEDOWN, HIBYTE(nTimerID));
		}

		if (point.y < rect.top)
		{
			nTimerID = MAKEWORD(LOBYTE(nTimerID), SB_LINEUP);
		}
		else if (point.y >= rect.bottom)
		{
			nTimerID = MAKEWORD(LOBYTE(nTimerID), SB_LINEDOWN);
		}

		ASSERT(nTimerID != MAKEWORD(-1, -1));

		BOOL bEnableScroll = m_pPlanner->OnScroll(nTimerID, 0, FALSE);

		if (!bEnableScroll)
		{
			nTimerID = MAKEWORD(-1, -1);
		}
	}

	if (m_nTimerID == MAKEWORD(-1, -1) && nTimerID != MAKEWORD(-1, -1))
	{
		// send fake OnDragEnter when transition from scroll->normal
		COleDataObject dataObject;
		dataObject.Attach(m_lpDataObject, FALSE);
		OnDragEnter(pWnd, &dataObject, dwKeyState, point);
	}

	if (nTimerID == MAKEWORD(-1, -1))
	{
		if (m_nTimerID != MAKEWORD(-1, -1))
		{
			// send fake OnDragEnter when transition from scroll->normal
			//COleDataObject dataObject;
			//dataObject.Attach(m_lpDataObject, FALSE);
			//OnDragEnter(pWnd, &dataObject, dwKeyState, point);
			m_nTimerID = MAKEWORD(-1, -1);
		}
		
		return DROPEFFECT_NONE;
	}

	// save tick count when timer ID changes
	DWORD dwTick = GetTickCount();
	if (nTimerID != m_nTimerID)
	{
		m_dwLastTick = dwTick;
		m_nScrollDelay = nScrollDelay;
	}

	// scroll if necessary
	if (dwTick - m_dwLastTick > m_nScrollDelay)
	{
		m_pPlanner->OnScroll(nTimerID, 0, TRUE);

		m_dwLastTick = dwTick;
		m_nScrollDelay = nScrollInterval;
	}
	
	if (m_nTimerID == MAKEWORD(-1, -1))
	{
		// send fake OnDragLeave when transitioning from normal->scroll
		//OnDragLeave(pWnd);
	}

	m_nTimerID = nTimerID;
/*
	// check for force link
	if ((dwKeyState & (MK_CONTROL | MK_SHIFT)) == (MK_CONTROL | MK_SHIFT))
		dropEffect = DROPEFFECT_SCROLL|DROPEFFECT_LINK;
	// check for force copy
	else */if ((dwKeyState & MK_CONTROL) == MK_CONTROL)
		dropEffect = DROPEFFECT_SCROLL | DROPEFFECT_COPY;
	// check for force move
	else if ((dwKeyState & MK_ALT) == MK_ALT ||
		(dwKeyState & MK_SHIFT) == MK_SHIFT)
		dropEffect = DROPEFFECT_SCROLL | DROPEFFECT_MOVE;
	// default -- recommended action is move
	else
		dropEffect = DROPEFFECT_SCROLL | DROPEFFECT_MOVE;
	
	return dropEffect;
}
Example #29
0
void CSHListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// This function is called by the control in different 
	// stages during the control drawing process.
	if (!m_bKeyEvent)
		return;

	NMLVCUSTOMDRAW *pCD = (NMLVCUSTOMDRAW*)pNMHDR;
	// By default set the return value to do the default behavior.
	*pResult = 0;
	
	switch( pCD->nmcd.dwDrawStage )
	{
	case  CDDS_PREPAINT:  // First stage (for the whole control)
		// Tell the control we want to receive drawing messages  
		// for drawing items.
		*pResult = CDRF_NOTIFYITEMDRAW;
		// The next stage is handled in the default:
		break;
	case CDDS_ITEMPREPAINT | CDDS_SUBITEM: // Stage three (called for each subitem of the focused item)
		{
			// We don't want to draw anything here, but we need to respond 
			// of DODEFAULT will be the next stage.
			// Tell the control we want to handle drawing after the subitem 
			// is drawn.
			*pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NOTIFYPOSTPAINT;
		}
		break;
	case CDDS_ITEMPOSTPAINT | CDDS_SUBITEM: // Stage four (called for each subitem of the focused item)
		{
			// We do the drawing here (well maybe).
			// This is actually after the control has done its drawing
			// on the subitem.  Since drawing a cell is near instantaneous
			// the user won't notice.
			int subitem = pCD->iSubItem;
			// Only do our own drawing if this subitem has focus at the item level.
			if( (pCD->nmcd.uItemState & CDIS_FOCUS) )
			{
				// If this subitem is the subitem with the current focus,
				// draw it.  Otherwise let the control draw it.  
				CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
				// We have to take into account the possibility that the 
				// columns may be reordered.
				if( subitem == Header_OrderToIndex( pHeader->m_hWnd,  m_CurSubItem ) )
				{
					// POSTERASE
					CDC* pDC = CDC::FromHandle(pCD->nmcd.hdc);
					// Calculate the offset of the text from the right and left of the cell.
					int offset = pDC->GetTextExtent(_T(" "), 1 ).cx*2;
					// The rect for the cell gives correct left and right values.
					CRect rect = pCD->nmcd.rc;
					CRect bounds;
					GetItemRect( pCD->nmcd.dwItemSpec, &bounds, LVIR_BOUNDS );
					// Get the top and bottom from the item itself.
					rect.top = bounds.top;
					rect.bottom = bounds.bottom;
					// Adjust rectangle for horizontal scroll and first column label
					{
						if( subitem == 0 )
						{
							CRect lrect;
							GetItemRect( pCD->nmcd.dwItemSpec, &lrect, LVIR_LABEL );
							rect.left = lrect.left;
							rect.right = lrect.right;
						}
						else
						{
							rect.right += bounds.left;
							rect.left  += bounds.left;
						}
					}
					// Clear the background with button face color
					pDC->FillRect(rect, &CBrush(::GetSysColor(COLOR_3DFACE)));
					// PREPAINT
					CString str;
					str = GetItemText( pCD->nmcd.dwItemSpec, pCD->iSubItem );
					// Deflate the rect by the horizontal offset.
					rect.DeflateRect( offset, 0 );
					// You could also make this column alignment sensitive here.
					pDC->DrawText( str, rect, 
						DT_SINGLELINE|DT_NOPREFIX|DT_LEFT|DT_VCENTER|DT_END_ELLIPSIS);
					// POSTPAINT
					// Draw rounded edge
					rect.InflateRect( offset, 0 );
					pDC->Draw3dRect( &rect, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DFACE) );
					rect.DeflateRect( 1, 1 );
					pDC->Draw3dRect( &rect, ::GetSysColor(COLOR_3DDKSHADOW), ::GetSysColor(COLOR_3DHILIGHT) );
					// Tell the control that we handled the drawing for this subitem.
					*pResult = CDRF_SKIPDEFAULT;
				}
			}
		}
		break;
	default: // Stage two handled here. (called for each item)
		if( !(pCD->nmcd.uItemState & CDIS_FOCUS) )
		{
			// If this item does not have focus, let the 
			// control draw the whole item.
			*pResult = CDRF_DODEFAULT;
		}
		else
		{
			// If this item has focus, tell the control we want
			// to handle subitem drawing.
			*pResult = CDRF_NOTIFYSUBITEMDRAW;
		}
		break;
	}
}
Example #30
0
bool CIVStatusBar::IsOverURL(CPoint pt, CString & rstr )
{

	if ( ! IsWindowEnabled()  || !GetTopLevelParent()->IsWindowEnabled()   )
		return false;

	CStatusBarCtrl & sb = GetStatusBarCtrl();
	int iPart = -1;
	CRect rc;
	for (int i=0; i < sb.GetParts(0, NULL); i++ )
	{
		sb.GetRect (i, rc);
		if (rc.PtInRect(pt) && ( GetPaneStyle(i) & SBT_OWNERDRAW )  )
		{
			iPart = i;
			break;
		}
	}

	if (iPart == -1)
		return false;

	if ( ! (GetPaneStyle(iPart)  & SBPS_NOBORDERS) )
		rc.InflateRect(-GetSystemMetrics(SM_CYBORDER), -GetSystemMetrics(SM_CXBORDER));

	if (!rc.PtInRect(pt))
		return false;

	CString strText = GetPaneText(iPart);
	CDC * pDC = GetDC();

	CFont * pFont = GetFont();
	CFont fntURL;
	GetLinkFont(fntURL);
	
	CFont * pOldFont =  pDC->SelectObject (pFont);

	int x = CalcX (pDC, rc, strText);

	bool bFound = false;
	for (int i = 0; i < strText.GetLength();)
	{
		CSize szPos = FindURL (strText, i );
		if (szPos.cx != -1)
		{
			CString strStart = strText.Mid (i, szPos.cx-i);
			CRect rcURL;
			x += pDC->GetTextExtent (strStart).cx;
			rcURL.left = x;
	
			pFont = pDC->SelectObject (&fntURL);
		
			CString strURL = strText.Mid(szPos.cx, szPos.cy);
			
			CSize szURL =  pDC->GetTextExtent (strURL);
			x += szURL.cx;
			
			rcURL.right = x;
			rcURL.top = rc.top;
			rcURL.bottom = rc.top + szURL.cy;

			pDC->SelectObject (pFont);
			
			if (rcURL.PtInRect(pt))
			{
				rstr = strURL;
				bFound = true;
				break;
			}

			i = szPos.cx + szPos.cy;
		}
		else
			break;

	}

	pDC->SelectObject (pOldFont);


	return bFound;
}