// 自绘, 灯亮LightOn=true(按钮显示第二幅图),否则LightOn=false(按钮显示第一幅图),
// 控件失效,即未使能,显示第三幅图片
void CLightBitmapButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	// TODO:  添加您的代码以绘制指定项
	ASSERT(lpDrawItemStruct != NULL); 
	// must have at least the first bitmap loaded before calling DrawItem 
	ASSERT(m_bitmap.m_hObject != NULL);     // 至少有一个正常显示的CBitmap对象 

	CBitmap* pBitmap = &m_bitmap; // 第一个图片正常显示(Light off)
	UINT state = lpDrawItemStruct->itemState; 

	if ((state & ODS_DISABLED) && m_bitmapFocus.m_hObject != NULL) 
		pBitmap = &m_bitmapFocus;   // 第三个图片用于未使能按钮(disable)
	else if(m_LightOn && m_bitmapSel.m_hObject != NULL)
		pBitmap = &m_bitmapSel; // 第二个图片,左键按下后显示(Light on)

	// draw the whole button 
	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); 
	CDC memDC; 
	memDC.CreateCompatibleDC(pDC); 
	CBitmap* pOld = memDC.SelectObject(pBitmap); 
	if (pOld == NULL) 
		return;     // destructors will clean up 

	CRect rect; 
	rect.CopyRect(&lpDrawItemStruct->rcItem); 
	pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), 
		&memDC, 0, 0, SRCCOPY); 
	memDC.SelectObject(pOld); 
}
Esempio n. 2
0
LRESULT COleIPFrameWnd::OnResizeChild(WPARAM, LPARAM lParam)
{
	// notify the container that the rectangle has changed!
	COleServerDoc* pDoc = (COleServerDoc*)GetActiveDocument();
	if (pDoc == NULL)
		return 0;

	ASSERT_KINDOF(COleServerDoc, pDoc);

	// get new rect and parent
	CRect rectNew;
	rectNew.CopyRect((LPCRECT)lParam);
	CWnd* pParentWnd = GetParent();
	ASSERT_VALID(pParentWnd);

	// convert rectNew relative to pParentWnd
	ClientToScreen(&rectNew);
	pParentWnd->ScreenToClient(&rectNew);

	// adjust the new rectangle for the current control bars
	CWnd* pLeftOver = GetDlgItem(AFX_IDW_PANE_FIRST);
	ASSERT(pLeftOver != NULL);
	CRect rectCur = m_rectPos;
	pLeftOver->CalcWindowRect(&rectCur, CWnd::adjustOutside);
	rectNew.left += m_rectPos.left - rectCur.left;
	rectNew.top += m_rectPos.top - rectCur.top;
	rectNew.right -= rectCur.right - m_rectPos.right;
	rectNew.bottom -= rectCur.bottom - m_rectPos.bottom;
	OnRequestPositionChange(rectNew);

	return 0;
}
Esempio n. 3
0
// Draw the appropriate bitmap
void CBitmapButton::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
	ASSERT(lpDIS != NULL);
	// must have at least the first bitmap loaded before calling DrawItem
	ASSERT(m_bitmap.m_hObject != NULL);     // required

	// use the main bitmap for up, the selected bitmap for down
	CBitmap* pBitmap = &m_bitmap;
	UINT state = lpDIS->itemState;
	if ((state & ODS_SELECTED) && m_bitmapSel.m_hObject != NULL)
		pBitmap = &m_bitmapSel;
	else if ((state & ODS_FOCUS) && m_bitmapFocus.m_hObject != NULL)
		pBitmap = &m_bitmapFocus;   // third image for focused
	else if ((state & ODS_DISABLED) && m_bitmapDisabled.m_hObject != NULL)
		pBitmap = &m_bitmapDisabled;   // last image for disabled

	// draw the whole button
	CDC* pDC = CDC::FromHandle(lpDIS->hDC);
	CDC memDC;
	memDC.CreateCompatibleDC(pDC);
	CBitmap* pOld = memDC.SelectObject(pBitmap);
	if (pOld == NULL)
		return;     // destructors will clean up

	CRect rect;
	rect.CopyRect(&lpDIS->rcItem);
	pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(),
		&memDC, 0, 0, SRCCOPY);
	memDC.SelectObject(pOld);
}
Esempio n. 4
0
//-------------------------------------------------------------------//
// DrawItem()																			//
//-------------------------------------------------------------------//
// This function was copied from CBitmapButton's source (in 			//
// WinBtn.cpp). It was modified according to knowledge base article:	//
// "How to Use CBitmapButton to Resize a Bitmap to Fit a Button".		//
//-------------------------------------------------------------------//
void ColorBitmapButton::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
	ASSERT(lpDIS != NULL);
	
	// Have to have loaded the bitmap.
	ASSERT( pBitmap->m_hObject != NULL );

	UINT state = lpDIS->itemState;

	// Update the style manually for checkbox-style buttons.
	if ( m_bCheckBoxStyle )
		if ( m_bCheckState )
			state |= ODS_SELECTED;
		else 
			state &= ~ODS_SELECTED;

	CRect rect;
	rect.CopyRect(&lpDIS->rcItem);

	// If we are Sizing to bitmap, then
	// the rectangle needs to be juuuuuust a little bit
	// bigger than the bitmap to leave room for the border.
	if ( uSizeToResourceID == 0 ) {

		// determine bitmaps size
		BITMAP bits;
		pBitmap->GetObject(sizeof(BITMAP),&bits);

		if ( bGrayedOut )
			rect.right = rect.left + (bits.bmWidth>>1) + 4;
		else
Esempio n. 5
0
/*------------------------------------------------------------*
 * Purpose	: Get Control Rectangle;
 * Return Value	: return CRect class;
 *------------------------------------------------------------*/
CRect CLineInfo::GetControlRect() const
{
	CRect rectangle;
	rectangle.CopyRect(m_rect);

	return rectangle;
}
Esempio n. 6
0
//-----------------------------------------------------------------------------
BOOL CMRCSizeToolBar::Create(CWnd * pParent, DWORD dwStyle, UINT nID, LPRECT pRect)
//-----------------------------------------------------------------------------
{
	m_ToolCtrlButtonSize.cx = 16;
	m_ToolCtrlButtonSize.cy = 15;
	
	// if no rectangle supplied, then what is hopefully as sensible default.
	// ie a single row of buttons
	CRect rect;
	if (pRect != NULL)
		rect.CopyRect(pRect);
	else
	{
		pParent->GetClientRect(&rect);
		rect.left = 0;
		rect.top = 0;
		rect.bottom = m_ToolCtrlButtonSize.cy + 18;
		rect.right -= 8;
	}
		
	BOOL status = CMRCSizeControlBar::Create(pParent, NULL, nID, dwStyle, rect); 
	if (status == TRUE)
	{
	}
	return status;
}
Esempio n. 7
0
void CMyBitmapButton::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{

	ASSERT(lpDIS != NULL); 
	// must have at least the first bitmap loaded before calling DrawItem 
	ASSERT(m_bitmap.m_hObject != NULL);     // 至少有一个正常显示的CBitmap对象 

	// use the main bitmap for up, the selected bitmap for down 
	CBitmap* pBitmap = &m_bitmap; // 第一个图片正常显示
	UINT state = lpDIS->itemState; 

	if ((state & ODS_DISABLED) && m_bitmapFocus.m_hObject != NULL) 
		pBitmap = &m_bitmapFocus;   // 第三个图片用于未使能按钮
	else if(m_LButtonDown && m_bitmapSel.m_hObject != NULL)
		pBitmap = &m_bitmapSel; // 第二个图片,左键按下后显示

	// draw the whole button 
	CDC* pDC = CDC::FromHandle(lpDIS->hDC); 
	CDC memDC; 
	memDC.CreateCompatibleDC(pDC); 
	CBitmap* pOld = memDC.SelectObject(pBitmap); 
	if (pOld == NULL) 
		return;     // destructors will clean up 

	CRect rect; 
	rect.CopyRect(&lpDIS->rcItem); 
	pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), 
		&memDC, 0, 0, SRCCOPY); 
	memDC.SelectObject(pOld); 
}
Esempio n. 8
0
void CMappedBitmapButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	ASSERT(lpDrawItemStruct != NULL);
	ASSERT(m_image.GetImageCount() == 4);

	// images are:
	// 0 = up
	// 1 = down
	// 2 = focused
	// 3 = disabled
	int image = 0;
	UINT state = lpDrawItemStruct->itemState;
	if (state & ODS_SELECTED)
		image = 1;
	else if (state & ODS_FOCUS)
		image = 2;   // third image for focused
	else if (state & ODS_DISABLED)
		image = 3;   // last image for disabled

	// draw the whole button
	CRect rect;
	rect.CopyRect(&lpDrawItemStruct->rcItem);

	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	VERIFY( m_image.Draw( pDC, image, rect.TopLeft(), ILD_NORMAL ) );
}
Esempio n. 9
0
void CGraphPanel::DoRedraw(CDC* dc, LPCRECT r)
{
    if (!offscreen)
    {
	return;
    };

    CRect rect;
    if (r == NULL)
    {
	GetClientRect(&rect);
    } else
    {
	rect.CopyRect(r);
    };
    if(rect.IsRectEmpty()) return;

    if( !offscreen->IsDIBReady() )
    {
	UpdateGraphWindow(NULL);
    };

    offscreen->DrawDib(dc->m_hDC, &rect);
    //draw zoom rect
    if (bZoomActive || bCreateZoomRect) zoomrect->Draw(dc);
}
Esempio n. 10
0
//
// Draw the appropriate image
void CuImageButton::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
	int iImage = 0;
	ASSERT(lpDIS != NULL);
	int nCount = m_imageList.GetImageCount();
	//
	// Must have at least the first bitmap loaded before calling DrawItem
	ASSERT(m_imageList.m_hImageList != NULL);     // required
	//
	// Use the zero-based index index 0 bitmap for up, the selected bitmap for down
	UINT state = lpDIS->itemState;
	if ((state & ODS_SELECTED) && m_imageList.m_hImageList != NULL)
		iImage = (nCount > 1)? 1: 0;
	else 
	if ((state & ODS_FOCUS) &&  m_imageList.m_hImageList != NULL /*&& (GetParent()->GetStyle() & DS_WINDOWSUI)*/)
		iImage = (nCount > 2)? 2: 0;
	else 
	if ((state & ODS_DISABLED) && m_imageList.m_hImageList != NULL)
		iImage = (nCount > 3)? 3: 0;

	//
	// Draw the whole button
	CRect rect;
	rect.CopyRect(&lpDIS->rcItem);
	CDC* pDC = CDC::FromHandle(lpDIS->hDC);
	m_imageList.Draw (pDC, iImage, CPoint (rect.left, rect.top), ILD_TRANSPARENT);
}
Esempio n. 11
0
void CSearchBarCtrl::OnPaint()
{
	CPaintDC dc(this);

	CRect rtTriangle;
	CRect rtBack;
	

	CClientRect	rtClient(this);
	CBufferDC	bufDC(dc.GetSafeHdc(), rtClient);
	rtTriangle.CopyRect(rtClient);

	SendMessage(WM_ERASEBKGND, (WPARAM) bufDC.GetSafeHdc(), 1);

	CSize	sizeIcon;
	CRect	rtIcon;
	CFaceManager::GetInstance()->GetImageSize(m_nCurrentIcon, sizeIcon);
	CenterRect(&rtIcon, rtClient, sizeIcon);

	rtIcon.left = rtClient.left + MARGIN_WIDTH;
	rtIcon.top = rtClient.top + MARGIN_WIDTH;
	rtIcon.right = rtIcon.left + sizeIcon.cx;

	rtBack.left = rtClient.left + 2;
	rtBack.top = rtClient.top + 2;
	rtBack.bottom = rtClient.bottom;
	rtBack.right = sizeIcon.cx - 8;


	if (m_bHover)
	{
		bufDC.FillSolidRect(rtBack, RGB(226,226,226));//RGB(238,236,221)
	}
	else
	{
		bufDC.FillSolidRect(rtBack, RGB(240,240,240));//RGB(238,236,221)
	}

	{
		CPenDC pen(bufDC.GetSafeHdc(), RGB(200,200,200));


		bufDC.MoveTo(rtBack.bottom + 6, rtBack.top - 1);
		bufDC.LineTo(rtBack.bottom + 6, rtBack.right - 5);

	}

	m_ImageList.Draw(&bufDC, m_nCurrentIcon, CPoint(rtIcon.left, rtIcon.top), ILD_NORMAL);

	rtTriangle.left = rtClient.left + MARGIN_WIDTH + 1;
	rtTriangle.bottom = rtClient.bottom - rtClient.Height()/2 + MARGIN_WIDTH;
	rtTriangle.right = rtTriangle.left + sizeIcon.cx;


	DrawTriangle(&bufDC, rtTriangle);

}
Esempio n. 12
0
void CODMenu::DrawItem (LPDRAWITEMSTRUCT lpDIS)
{
	ASSERT(lpDIS != NULL);
	CDC* pDC = CDC::FromHandle(lpDIS->hDC);
	CRect rect;
	UINT state = (((CODMenuData*)(lpDIS->itemData))->nFlags);
	if(state & MF_SEPARATOR){
		rect.CopyRect(&lpDIS->rcItem);
		rect.top+=rect.Height()>>1;
		pDC->DrawEdge(&rect,EDGE_ETCHED,BF_TOP);
	}
Esempio n. 13
0
void CGraph::PrepareDraw()
{
	m_hOldBitmap = (HBITMAP)::SelectObject(m_hMemDC, m_hBitmap);
	m_hOldBlackBrush = (HBRUSH)::SelectObject(m_hMemDC, m_hBlackBrush);

	::FillRect(m_hMemDC,  CRect(0, 0, m_cxStaticWidth, m_cyStaticHeight), m_hBlackBrush);

	CRect rtRectangleFrame;
	rtRectangleFrame.CopyRect(&CRect(0 + FRAME_EDAGE_OFFSET, 0 + FRAME_EDAGE_OFFSET, m_cxExcludeFrameStaticWidth + FRAME_EDAGE_OFFSET, m_cyExcludeFrameStaticHeight + FRAME_EDAGE_OFFSET));
	DrawRectangleFrame(rtRectangleFrame);
}
Esempio n. 14
0
void InfoBarOp::OnSizeParent(WPARAM, LPARAM lParam)
{
	AFX_SIZEPARENTPARAMS FAR* lpLayout = (AFX_SIZEPARENTPARAMS FAR*)lParam;

	if (Visible)
	{
		// Make the window zero size to avoid redraws
		//MoveWindow(WindowID, 0, 0, 0, 0, FALSE);

		// Info Bar is visible - reposition it wrt parent window.
		CRect rect;
		rect.CopyRect(&lpLayout->rect);

		CSize sizeAvail = rect.Size();  // maximum size available
		CSize size;     // maximum requested size
		size.cx = min(32767, sizeAvail.cx);
		size.cy = min(28, sizeAvail.cy);


		// top align (stretch width)
		size.cx = sizeAvail.cx;
		lpLayout->rect.top += size.cy;

		rect.right = rect.left + size.cx;
		rect.bottom = rect.top + size.cy;

		#if _MFC_VER < 0x300
		_AfxRepositionWindow(lpLayout, WindowID, &rect);

		// If the window hasn't actually been opened yet, then open it.
		// This deferral is necessary otherwise the window is opened before being
		// correctly positioned, and a portion of the document view is invalidated
		// and redrawn, which we definitely don't want.
		#if 1
		if (!IsWindowVisible(WindowID))
		{
			lpLayout->hDWP =
				::DeferWindowPos(lpLayout->hDWP, WindowID, NULL, 0, 0, 0, 0,
								 SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|
								 SWP_SHOWWINDOW);
		}
		#endif
		#else
		lpLayout->hDWP = ::DeferWindowPos(lpLayout->hDWP, WindowID, NULL,
										  rect.left, rect.top,
										  rect.right - rect.left, rect.bottom - rect.top,
										  SWP_NOACTIVATE|SWP_NOZORDER|SWP_SHOWWINDOW);
		#endif
	}
}
Esempio n. 15
0
//艺术字体
void CGameClientView::DrawTextString(CDC * pDC, LPCTSTR pszString, COLORREF crText, COLORREF crFrame, LPRECT lpRect)
{
	//变量定义
	int nStringLength=lstrlen(pszString);
	int nXExcursion[8]={1,1,1,0,-1,-1,-1,0};
	int nYExcursion[8]={-1,0,1,1,1,0,-1,-1};

	//绘画边框
	pDC->SetTextColor(crFrame);
	CRect rcDraw;
	for (int i=0;i<CountArray(nXExcursion);i++)
	{
		rcDraw.CopyRect(lpRect);
		rcDraw.OffsetRect(nXExcursion[i],nYExcursion[i]);
		pDC->DrawText(pszString,nStringLength,&rcDraw,DT_VCENTER|DT_CENTER|DT_SINGLELINE|DT_END_ELLIPSIS);
	}

	//绘画字体
	rcDraw.CopyRect(lpRect);
	pDC->SetTextColor(crText);
	pDC->DrawText(pszString,nStringLength,&rcDraw,DT_VCENTER|DT_CENTER|DT_SINGLELINE|DT_END_ELLIPSIS);

	return;
}
Esempio n. 16
0
BOOL CInPlaceFrame::CanGetBorderSpace(
    LPCRECT lpRectBorder, LPOLEINPLACEUIWINDOW lpUIWindow, BOOL bFrame)
{
    ASSERT_VALID(this);
    ASSERT(lpRectBorder == NULL ||
        AfxIsValidAddress(lpRectBorder, sizeof(RECT), FALSE));
    ASSERT(lpUIWindow != NULL);

    // use IOleInPlaceUIWindow::GetBorder if no border given
    CRect rectBorder;
    if (lpRectBorder != NULL)
        rectBorder.CopyRect(lpRectBorder);
    else
        lpUIWindow->GetBorder(&rectBorder);

    // get CWnd* for the OLE window
    HWND hwnd;
    VERIFY(lpUIWindow->GetWindow(&hwnd) == NOERROR);
    CWnd* pWnd = CWnd::FromHandle(hwnd);
    ASSERT(pWnd != NULL);
  
    // see how much space we need by calling reposition bars
    CRect rectNeeded = rectBorder;
    pWnd->RepositionBars(0, 0xFFFF, 0, CWnd::reposQuery, &rectNeeded, &rectBorder);
    CRect rectRequest;

    // request the border space from the container
    rectRequest.SetRect(
        rectNeeded.left - rectBorder.left,
        rectNeeded.top - rectBorder.top,
        rectBorder.right - rectNeeded.right,
        rectBorder.bottom - rectNeeded.bottom);
    CRect rectTemp;
    rectTemp = rectRequest;

    // if no border space, just call SetBorderSpace
    if (rectRequest.IsRectNull())
        goto RequestFailed;

    if (lpUIWindow->RequestBorderSpace(&rectTemp) != NOERROR)
        goto RequestFailed;

    return TRUE;

RequestFailed:

	return FALSE;
}
//=============================================================================	
void CXButtonXP::PrepareImageRect(BOOL bHasText,
								  CRect& rectItem,
								  CRect& rectText,
								  BOOL bIsPressed,
								  BOOL bIsThemed,
								  DWORD dwWidth,
								  DWORD dwHeight,
								  CRect& rectImage)
//=============================================================================	
{
	rectImage.CopyRect(&rectItem);

	if (bHasText)
	{
		// image must be placed just inside the focus rect
		int nTextWidth = rectText.right - rectText.left;
		if (m_eIconAlignment == RIGHT)
		{
			rectText.right = nTextWidth - dwWidth - dwWidth/2;
			rectText.left  = dwWidth/2;
			rectImage.left = rectItem.right - dwWidth - dwWidth/2;
		}
		else	// icon is on the left
		{
			rectText.right = nTextWidth - dwWidth/2;
			rectText.left  = 2 * dwWidth;
			rectImage.left = dwWidth/2;
		}
	}
	else	// no text
	{
		// center image horizontally
		int nImageWidth = rectImage.right - rectImage.left;
		rectImage.left += ((nImageWidth - dwWidth)/2);
	}

	// center image vertically
	int nImageHeight = rectImage.bottom - rectImage.top;
	rectImage.top += ((nImageHeight - dwHeight)/2);

	// if button is pressed then press image also
	if (bIsPressed && !bIsThemed)
		rectImage.OffsetRect(1, 1);
}
Esempio n. 18
0
HBITMAP CMainDlg::GetScreenshot(HWND hWnd, CRect* pRect/*=NULL*/)
{
	// Get DC
	HDC hDC = ::GetWindowDC(hWnd);
	HDC hCaptureDC = ::CreateCompatibleDC(hDC);
	int nBPP = ::GetDeviceCaps(hDC, BITSPIXEL);

	// If no rect was supplied grab entire window
	CRect rCapture;
	if(pRect)
		rCapture.CopyRect(pRect);
	else
		::GetWindowRect(hWnd, rCapture);

	// Create device independent bitmap
	BITMAPINFO bmiCapture = {
		sizeof(BITMAPINFOHEADER), 
		rCapture.Width(), -rCapture.Height(), 
		1, nBPP, BI_RGB, 0, 0, 0, 0, 0,
	};
	LPBYTE lpCapture;
	HBITMAP hbmCapture = CreateDIBSection(hDC, &bmiCapture,
		DIB_PAL_COLORS, (LPVOID*)&lpCapture, NULL, 0);
	if(!hbmCapture)
	{
		::DeleteDC(hCaptureDC);
		::DeleteDC(hDC);
		return NULL;
	}
	
	// Grab the image
	int nCapture = ::SaveDC(hCaptureDC);
	::SelectObject(hCaptureDC, hbmCapture);
	if(pRect)
		::BitBlt(hCaptureDC, 0, 0, rCapture.Width(), rCapture.Height(), hDC, rCapture.left, rCapture.top, SRCCOPY);
	else
		::BitBlt(hCaptureDC, 0, 0, rCapture.Width(), rCapture.Height(), hDC, 0, 0, SRCCOPY);
	::RestoreDC(hCaptureDC, nCapture);
	::DeleteDC(hCaptureDC);
	::DeleteDC(hDC);

	// Return the bitmap handle
	return hbmCapture;
}
Esempio n. 19
0
// </snippet1>
LRESULT CInPlaceFrame::OnResizeChild(WPARAM /*wParam*/, LPARAM lParam)
{
	// notify the container that the rectangle has changed!
	CWordPadDoc* pDoc = (CWordPadDoc*)GetActiveDocument();
	if (pDoc == NULL)
		return 0;

	ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(CWordPadDoc)));

	// get new rect and parent
	CRect rectNew;
	rectNew.CopyRect((LPCRECT)lParam);
	CWnd* pParentWnd = GetParent();
	ASSERT_VALID(pParentWnd);

	// convert rectNew relative to pParentWnd
	ClientToScreen(&rectNew);
	pParentWnd->ScreenToClient(&rectNew);

	if (m_wndRulerBar.GetStyle()&WS_VISIBLE)
	{
		CRect rect;
		m_wndRulerBar.GetWindowRect(&rect);
		rectNew.top += rect.Height();
	}
	rectNew.left += HORZ_TEXTOFFSET;
	rectNew.top += VERT_TEXTOFFSET;

	// adjust the new rectangle for the current control bars
	CWnd* pLeftOver = GetDlgItem(AFX_IDW_PANE_FIRST);
	ASSERT(pLeftOver != NULL);
	CRect rectCur = m_rectPos;
	pLeftOver->CalcWindowRect(&rectCur, CWnd::adjustOutside);
	rectNew.left += m_rectPos.left - rectCur.left;
	rectNew.top += m_rectPos.top - rectCur.top;
	rectNew.right -= rectCur.right - m_rectPos.right;
	rectNew.bottom -= rectCur.bottom - m_rectPos.bottom;
	OnRequestPositionChange(rectNew);

	return 0;
}
Esempio n. 20
0
void CGraphPanel::UpdateGraphWindow(LPCRECT rect)
{
    if(!offscreen)
    {
		return;
    };
    CRect r;
    if (rect==NULL) GetClientRect(&r);
	else r.CopyRect(rect);

    //do paint here
    CDC* dc = offscreen->GetDibCDC();
    if (dc != NULL)
    {
	CRect rect_to_draw;
	GetClientRect(rect_to_draw);
	DrawToDC(dc, rect_to_draw);
	offscreen->SetReady(TRUE);
    };

    CDC* cdc = GetDC();
    DoRedraw(cdc, &r);
    ReleaseDC(cdc);
}
Esempio n. 21
0
static void test_CRect()
{
    CRect empty;
    ok(empty.left == 0, "Expected left to be 0, was %ld\n", empty.left);
    ok(empty.top == 0, "Expected top to be 0, was %ld\n", empty.top);
    ok(empty.Width() == 0, "Expected Width to be 0, was %i\n", empty.Width());
    ok(empty.Height() == 0, "Expected Height to be 0, was %i\n", empty.Height());

    CRect rect(0, 0, 100, 50);
    ok(rect.Width() == 100, "Expected Width to be 100, was %i\n", rect.Width());
    ok(rect.Height() == 50, "Expected Height to be 50, was %i\n", rect.Height());

    RECT sdkRect;
    sdkRect.left = 0;
    sdkRect.top = 0;
    sdkRect.right = 100;
    sdkRect.bottom = 50;

    CRect rect2(sdkRect);
    CRect rect3(&sdkRect);
    ok_rect(rect2, rect);
    ok_rect(rect3, rect);

    CPoint pt(0, 0);
    CSize sz(100, 50);
    CRect rect4(pt, sz);
    ok_rect(rect4, rect2);

    CPoint ptBottomRight(100, 50);
    CRect rect5(pt, ptBottomRight);
    ok_rect(rect5, rect4);

    rect = CRect(210, 150, 350, 900);
    CPoint ptDown;

    ptDown = rect.BottomRight();

    pt = CPoint(350, 900);
    ok_point(ptDown, pt);

    rect2 = CRect(10, 10, 350, 350);
    CPoint ptLow(180, 180);

    rect2.BottomRight() = ptLow;

    rect = CRect(10, 10, 180, 180);
    ok_rect(rect2, rect);

    pt = CPoint(95, 95);
    CPoint pt2 = rect2.CenterPoint();
    ok_point(pt2, pt);

    pt2 = rect2.BottomRight();
    pt = CPoint(180, 180);
    ok_point(pt2, pt);

    pt2 = rect2.TopLeft();
    pt = CPoint(10, 10);
    ok_point(pt2, pt);

    rect2.TopLeft().Offset(3, 3);
    rect3 = CRect(13, 13, 180, 180);
    ok_rect(rect3, rect2);

    CRect rectSource(35, 10, 125, 10);
    CRect rectDest;

    rectDest.CopyRect(&rectSource);

    RECT rectSource2;
    rectSource2.left = 0;
    rectSource2.top = 0;
    rectSource2.bottom = 480;
    rectSource2.right = 640;

    rectDest.CopyRect(&rectSource2);

    rect = CRect(10, 10, 50, 50);

    rect.DeflateRect(1, 2);

    rect2 = CRect(11, 12, 49, 48);
    ok_rect(rect2, rect);

    rect2 = CRect(10, 10, 50, 50);
    CRect rectDeflate(1, 2, 3, 4);

    rect2.DeflateRect(&rectDeflate);
    rect = CRect(11, 12, 47, 46);
    ok_rect(rect2, rect);

    rect2.DeflateRect(sz);
    rect = CRect(111, 62, -53, -4);
    ok_rect(rect2, rect);

    rect2.OffsetRect(sz);
    rect = CRect(211, 112, 47, 46);
    ok_rect(rect2, rect);

    CRect rect1(35, 150, 10, 25);
    rect2 = CRect(35, 150, 10, 25);
    rect3 = CRect(98, 999, 6, 3);

    ok(rect1.EqualRect(rect2), "Expected EqualRect to return TRUE for %s, %s\n", wine_dbgstr_rect(&rect1), wine_dbgstr_rect(&rect2));
    ok(!rect1.EqualRect(rect3), "Expected EqualRect to return FALSE for %s, %s\n", wine_dbgstr_rect(&rect1), wine_dbgstr_rect(&rect3));

    RECT test;
    test.left = 35;
    test.top = 150;
    test.right = 10;
    test.bottom = 25;

    ok(rect1.EqualRect(&test), "Expected EqualRect to return TRUE for %s, %s\n", wine_dbgstr_rect(&rect1), wine_dbgstr_rect(&test));

    rect = test;
    rect2 = CRect(35, 150, 10, 25);
    ok_rect(rect, rect2);

    rect = CRect(0, 0, 300, 300);
    rect.InflateRect(50, 200);

    rect2 = CRect(-50, -200, 350, 500);
    ok_rect(rect, rect2);

    rect.InflateRect(sz);
    rect2 = CRect(-150, -250, 450, 550);
    ok_rect(rect, rect2);

    rect = CRect(20, 30, 80, 70);

    int nHt = rect.Height();

    ok(nHt == 40, "Expected nHt to be 40, was %i\n", nHt);

    CRect rectOne(125, 0, 150, 200);
    CRect rectTwo(0, 75, 350, 95);
    CRect rectInter;

    rectInter.IntersectRect(rectOne, rectTwo);

    rect = CRect(125, 75, 150, 95);
    ok_rect(rectInter, rect);

    CRect rectInter2 = rectOne;
    rectInter2 &= rectTwo;
    rect = CRect(125, 75, 150, 95);
    ok_rect(rectInter2, rect);

    CRect rectNone(0, 0, 0, 0);
    CRect rectSome(35, 50, 135, 150);

    ok(rectNone.IsRectEmpty(), "Expected IsRectEmpty to return TRUE for %s\n", wine_dbgstr_rect(&rectNone));
    ok(!rectSome.IsRectEmpty(), "Expected IsRectEmpty to return FALSE for %s\n", wine_dbgstr_rect(&rectSome));

    CRect rectEmpty(35, 35, 35, 35);
    ok(rectEmpty.IsRectEmpty(), "Expected IsRectEmpty to return TRUE for %s\n", wine_dbgstr_rect(&rectEmpty));

    ok(rectNone.IsRectNull(), "Expected IsRectNull to return TRUE for %s\n", wine_dbgstr_rect(&rectNone));
    ok(!rectSome.IsRectNull(), "Expected IsRectNull to return FALSE for %s\n", wine_dbgstr_rect(&rectSome));

    CRect rectNotNull(0, 0, 35, 50);
    ok(!rectNotNull.IsRectNull(), "Expected IsRectNull to return FALSE for %s\n", wine_dbgstr_rect(&rectNotNull));

    rect1 = CRect(35, 150, 10, 25);
    rect2 = CRect(35, 150, 10, 25);
    rect3 = CRect(98, 999, 6, 3);

    ok_rect(rect1, rect2);

    test.left = 35;
    test.top = 150;
    test.right = 10;
    test.bottom = 25;

    ok_rect(rect1, test);

    nok_rect(rect1, rect3);
    nok_rect(rect3, test);

    rect1 = CRect(100, 235, 200, 335);
    pt = CPoint(35, 65);
    rect2 = CRect(135, 300, 235, 400);

    rect1 += pt;

    ok_rect(rect1, rect2);

    rect1 = CRect(100, 235, 200, 335);
    rect2 = rect1 + pt;
    CRect rectResult(135, 300, 235, 400);
    ok_rect(rectResult, rect2);

    rect2 = rect1 + &test;
    rectResult = CRect(65, 85, 210, 360);
    ok_rect(rectResult, rect2);

    rect2 = rect1 - (LPCRECT)&test;
    rectResult = CRect(135, 385, 190, 310);
    ok_rect(rectResult, rect2);

    rect2 = rect1 - pt;
    rectResult = CRect(65, 170, 165, 270);

    ok_rect(rect2, rectResult);

    rect1 -= pt;
    ok_rect(rect1, rectResult);

    rect1 = CRect(100, 0, 200, 300);
    rect2 = CRect(0, 100, 300, 200);

    rect3 = rect1 & rect2;

    rectResult = CRect(100, 100, 200, 200);
    ok_rect(rectResult, rect3);

    rect3 = rect1 | rect2;
    rectResult = CRect(0, 0, 300, 300);
    ok_rect(rectResult, rect3);

    rect1 |= rect2;
    ok_rect(rectResult, rect1);

    rect1 += sz;
    rectResult = CRect(100, 50, 400, 350);
    ok_rect(rectResult, rect1);

    rect1 += &test;
    rectResult = CRect(65, -100, 410, 375);
    ok_rect(rectResult, rect1);

    rect1 -= sz;
    rectResult = CRect(-35, -150, 310, 325);
    ok_rect(rectResult, rect1);

    rect1 -= &test;
    rectResult = CRect(0, 0, 300, 300);
    ok_rect(rectResult, rect1);

    rect2 = rect1 + sz;
    rectResult = CRect(100, 50, 400, 350);
    ok_rect(rectResult, rect2);

    rect2 = rect1 - sz;
    rectResult = CRect(-100, -50, 200, 250);
    ok_rect(rectResult, rect2);
}
Esempio n. 22
0
LRESULT CControlBar::OnSizeParent(WPARAM, LPARAM lParam)
{
	AFX_SIZEPARENTPARAMS* lpLayout = (AFX_SIZEPARENTPARAMS*)lParam;
	DWORD dwStyle = RecalcDelayShow(lpLayout);

	if ((dwStyle & WS_VISIBLE) && (dwStyle & CBRS_ALIGN_ANY) != 0)
	{
		// align the control bar
		CRect rect;
		rect.CopyRect(&lpLayout->rect);

		CSize sizeAvail = rect.Size();  // maximum size available

		// get maximum requested size
		DWORD dwMode = lpLayout->bStretch ? LM_STRETCH : 0;
		if ((m_dwStyle & CBRS_SIZE_DYNAMIC) && m_dwStyle & CBRS_FLOATING)
			dwMode |= LM_HORZ | LM_MRUWIDTH;
		else if (dwStyle & CBRS_ORIENT_HORZ)
			dwMode |= LM_HORZ | LM_HORZDOCK;
		else
			dwMode |=  LM_VERTDOCK;

		CSize size = CalcDynamicLayout(-1, dwMode);

		size.cx = min(size.cx, sizeAvail.cx);
		size.cy = min(size.cy, sizeAvail.cy);

		if (dwStyle & CBRS_ORIENT_HORZ)
		{
			lpLayout->sizeTotal.cy += size.cy;
			lpLayout->sizeTotal.cx = max(lpLayout->sizeTotal.cx, size.cx);
			if (dwStyle & CBRS_ALIGN_TOP)
				lpLayout->rect.top += size.cy;
			else if (dwStyle & CBRS_ALIGN_BOTTOM)
			{
				rect.top = rect.bottom - size.cy;
				lpLayout->rect.bottom -= size.cy;
			}
		}
		else if (dwStyle & CBRS_ORIENT_VERT)
		{
			lpLayout->sizeTotal.cx += size.cx;
			lpLayout->sizeTotal.cy = max(lpLayout->sizeTotal.cy, size.cy);
			if (dwStyle & CBRS_ALIGN_LEFT)
				lpLayout->rect.left += size.cx;
			else if (dwStyle & CBRS_ALIGN_RIGHT)
			{
				rect.left = rect.right - size.cx;
				lpLayout->rect.right -= size.cx;
			}
		}
		else
		{
			ASSERT(FALSE);      // can never happen
		}

		rect.right = rect.left + size.cx;
		rect.bottom = rect.top + size.cy;

		// only resize the window if doing layout and not just rect query
		if (lpLayout->hDWP != NULL)
			AfxRepositionWindow(lpLayout, m_hWnd, &rect);
	}
	return 0;
}
Esempio n. 23
0
void CColorButton::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct ) 
{
	ASSERT( 0 != lpDrawItemStruct );

	CDC* pDC( CDC::FromHandle( lpDrawItemStruct->hDC ) );
	ASSERT( 0 != pDC );

	DWORD style = GetStyle();

	UINT uiDrawState( DFCS_ADJUSTRECT );	
	UINT state( lpDrawItemStruct->itemState );

	CRect rc; 
	rc.CopyRect( &lpDrawItemStruct->rcItem );

	if(((state & ODS_DEFAULT) || (state & ODS_FOCUS)) )
	{
		pDC->Draw3dRect(rc, GetSysColor(COLOR_WINDOWFRAME), GetSysColor(COLOR_WINDOWFRAME));
		rc.DeflateRect(1, 1);
	}

	if(style & BS_FLAT)
	{
		pDC->Draw3dRect(rc, GetSysColor(COLOR_WINDOWFRAME), GetSysColor(COLOR_WINDOWFRAME));
		rc.DeflateRect(1, 1);
		pDC->Draw3dRect(rc, GetSysColor(COLOR_WINDOW), GetSysColor(COLOR_WINDOW));
		rc.DeflateRect(1, 1);
	}
	else
	{
		if(state & ODS_SELECTED)
		{
			pDC->Draw3dRect(rc, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DSHADOW));
			rc.DeflateRect(1, 1);
		}
		else
		{
			pDC->Draw3dRect(rc, GetSysColor(COLOR_3DHILIGHT), GetSysColor(COLOR_3DDKSHADOW));
			rc.DeflateRect(1, 1);
		}
	}

	if(state & ODS_SELECTED)
	{
		pDC->SetBkMode(TRANSPARENT);
		pDC->FillSolidRect( &rc, m_color );
	}
	else
	{
		pDC->SetBkMode(TRANSPARENT);
		pDC->FillSolidRect( &rc, m_color );
	}
	
	if( false != m_showText )
	{
		CString wndText;
		GetWindowText( wndText );

		if (!wndText.IsEmpty())
		{
			pDC->SetTextColor( m_textColor );
			pDC->DrawText( wndText, &rc, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
		}
	}
}
void CSliderCtrlEx::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult) 
{
	int loopMax = colorList.GetSize();	// number of color ranges to process
	LPNMCUSTOMDRAW lpCustDraw = (LPNMCUSTOMDRAW)pNMHDR;

	////////////////////////////////////////////////////////////////////////////////
	// OnCustomDraw() is called at many different stages during the painting process
	// of the control. We only care about the PREPAINT state or the ITEMPREPAINT
	// state and not always then.
	//
	// If we want to be notified about subcontrol painting, we have to say so when
	// we get the initial PREPAINT message.
	////////////////////////////////////////////////////////////////////////////////
	if(lpCustDraw->dwDrawStage == CDDS_PREPAINT)
	{
		// should we report slider's position?
		int curVal = GetPos();
		if((m_Callback != NULL)	&& (curVal != m_oldPosition))
		{
			m_oldPosition = curVal;
			m_Callback(m_p2Object, m_data1, curVal, m_IsDragging);
		}

		// If we don't have any special coloring to do, skip all the silliness...
		if(loopMax <= 0)
		{
			*pResult = CDRF_DODEFAULT;
		}
		else
		{
			// We want to be informed when each part of the control is being
			// processed so we can intercept the channel drawing.
			*pResult = CDRF_NOTIFYITEMDRAW;	// send messages for each piece-part
		}
		return;
	}


	///////////////////////////////////////////////////////////////////////////////
	// A slider (track control) is drawn in several steps:
	//	1. Erase
	//	2. Tics
	//	3. Channel
	//	4. Thumb
	//
	// It would be nice to capture when the background has been painted and
	// before the other sub-pieces have been painted. Then we could just
	// substitute our own painting routine. But this doesn't seem to be
	// available.
	//
	// So this routine captures the tics by inserting operations before
	// painting the thumb.
	//
	// Look at the help on NMCUSTOMDRAW for complete details, but the pNMHDR
	// pointer looks at a structure like:
	//
	// typedef struct tagNMCUSTOMDRAWINFO {
    //	 NMHDR  hdr;
    //	 DWORD  dwDrawStage;	// This indicates what stage of the drawing process is involved
    //	 HDC    hdc;			// graphics context of the control (or sub-component)
    //	 RECT   rc;
    //	 DWORD  dwItemSpec;	// This is the particular piece-part of the slider involved
    //	 UINT   uItemState;
    //	 LPARAM lItemlParam;
	// } NMCUSTOMDRAW
	//
	// The stages include CDDS_PREPAINT, which is just before painting of the entire
	// control. However, unless the *pResult parameter is set to CDRF_NOTIFYITEMDRAW,
	// we will get notification for the control as a whole, not for each piece-part.
	// So the first thing to do is set *pResult. Thereafter, we must intercept
	// the sub-parts.
	//
	// We don't care about painting the background (we will re-paint later on). We
	// don't care about PREPAINT on the CHANNEL or the TICS since we will overwrite
	// everything when we get to the THUMB.
	/////////////////////////////////////////////////////////////////////////////////

	if((lpCustDraw->dwDrawStage == CDDS_ITEMPREPAINT) && (lpCustDraw->dwItemSpec != TBCD_THUMB))
	{
		*pResult = CDRF_DODEFAULT;
		return;
	}

	// get channel orientation
	BOOL IsVertical = (TBS_VERT & GetStyle()) ? TRUE : FALSE;

	// Get the coordinates of the control's window
	CRect crect;
	GetClientRect(crect);	// client coordinates (top = left = 0, bottom = height, right = width)

	// Much of this is "paraphrased" from Nic Wilson's work -- see the header file
	//////////////////////////////////////////////////////////////////////////////////
	// This bit does the tics marks transparently.
	// Create a memory dc to hold a copy of the oldbitmap data that includes the tics,
	// because when we add the background in we will lose the tic marks.
	///////////////////////////////////////////////////////////////////////////////////
	CDC *pDC = CDC::FromHandle(lpCustDraw->hdc);
	CDC SaveCDC;
	CBitmap SaveCBmp;

	//set the colours for the monochrome mask bitmap
	COLORREF crOldBack = pDC->SetBkColor(RGB(0,0,0));			// set to Black
	COLORREF crOldText = pDC->SetTextColor(RGB(255,255,255));	// set to White

	int iWidth  = crect.Width();	// channel width
	int iHeight = crect.Height();	// channel height

	////////////////////////////////////////////////////////////////////////////
	// Create an in-memory copy of displayed bitmap, including the tics.
	// This is a monochrome bitmap since it was created from a memory DC.
	// If it had been created from pDC (an actual device DC, not a memory
	// DC) then this would be something with 8, 16, 24, or 32 bits per pixel.
	//
	// This will have a black background, with the tic marks in white.
	//
	// For reasons I don't yet understand, this saves only the tic marks and
	// the channel's centerline (both originally in black), and not the other
	// colors (such as drawn AROUND the channel's centerline). I am not sure
	// what would have happened if the tic marks were not black...
	////////////////////////////////////////////////////////////////////////////
	SaveCDC.CreateCompatibleDC(pDC);
	SaveCBmp.CreateCompatibleBitmap(&SaveCDC, iWidth, iHeight);
	CBitmap* SaveCBmpOld = (CBitmap *)SaveCDC.SelectObject(SaveCBmp);
	SaveCDC.BitBlt(0, 0, iWidth, iHeight, pDC, crect.left, crect.top, SRCCOPY);

	if(m_dumpBitmaps)	// debugging stuff
	{
		SaveBitmap("MonoTicsMask.bmp",SaveCBmp);
	}

	// Do as much of this stuff in memory as possible, then blit it to the screen
	CDC memDC;
	memDC.CreateCompatibleDC(pDC);
	CBitmap memBM;
	memBM.CreateCompatibleBitmap(pDC,iWidth,iHeight);	// create from pDC, not memDC
	CBitmap *oldbm = memDC.SelectObject(&memBM);

	////////////////////////////////////////////////////////////////////////////////
	// copy screen bitmap to memory bitmap for manipulation. If this is the very
	// first time the control has been updated, the screen bitmap will show only
	// the tic marks (in black) and the default background color (RGB(214,207,189)).
	// If the control has been updated before, remnants of the previously drawn
	// background color ranges will also show up.
	////////////////////////////////////////////////////////////////////////////////
	memDC.BitBlt(0,0,iWidth,iHeight,pDC,0,0,SRCCOPY);

	if(m_dumpBitmaps)	// debugging
	{
		SaveBitmap("ScrnStart.bmp",memBM);
	}

	/////////////////////////////////////////////////////////////////////////////
	// Color parts of the channel if necessary. It SHOULD be necessary since we
	// don't get notifications unless there are colors to print, but we may have
	// a race condition and it is best to check.
	/////////////////////////////////////////////////////////////////////////////
	if(loopMax)
	{
		/////////////////////////////////////////////////////////////////////////////////
		// We need to draw colors over the subrange of the channel that the center of the
		// thumb traverses, rather than the entire client window. Later on, extend these
		// colors outwards to the ends of the client window (for nicer appearance). This
		// allows for more precise correlation with color and thumb position.
		/////////////////////////////////////////////////////////////////////////////////
		CRect chanRect;
		GetChannelRect(&chanRect);
		CRect thmbRect;
		GetThumbRect(&thmbRect);

		// For unknown reasons, GetChannelRect() returns a rectangle
		// as though it were a horizonally oriented slider, even if it isn't!
		if(IsVertical)
		{
			CRect n;	// could probably just change chanRect directly
			n.left = chanRect.top;
			n.right = chanRect.bottom;
			n.top = chanRect.left;
			n.bottom = chanRect.right;
			n.NormalizeRect();
			chanRect.CopyRect(&n);
		}

		// Offset into client rectangle for beginning of coloring range
		int Offset = chanRect.left + thmbRect.Width()/2;
		if(IsVertical)
		{
			Offset = chanRect.top + thmbRect.Height()/2;
		}

		// Range for center of thumb on the channel
		int ht = chanRect.Height() - thmbRect.Height();
		int wd = chanRect.Width()  - thmbRect.Width();

		// scaling between control range and bitmap
		int min,max;
		GetRange(min,max);	// range of values for the slider
		double scale = (double(max) - double(min))/double(IsVertical ? ht : wd);

		BOOL gotStartColor = FALSE;
		BOOL gotEndColor = FALSE;
		COLORREF startColor = 0, endColor = 0;

		int loop;	// Loop through the array of color ranges
		for(loop = 0; loop < loopMax; loop++)
		{
			clrRange clr;
			clr = colorList[loop];
			
			// Get the good values. If not set, then entire range is good
			int lval = clr.lval;
			int hval = clr.hval;
			if((lval < min) || (lval > max)) lval = min;
			if((hval > max) || (hval < min)) hval = max;

			if(lval == min)
			{
				gotStartColor = TRUE;
				startColor = clr.strColor;
			}
			if(hval == max)
			{
				gotEndColor = TRUE;
				endColor = clr.endColor;
			}

			int minVal = lval - min;	// offset into bitmap for this color
			minVal = int(double(minVal)/scale);

			// width (or height for vertical slider) inside bitmap for this color
			int widthVal = hval - lval;
			widthVal = int((double(widthVal)/scale) + 1.0);			
			
			// For drawing a gradient, we need to know the individual RGB values
			int sR,eR,sG,eG,sB,eB;	// start and end R, G, and B values
			sR = GetRValue(clr.strColor);
			eR = GetRValue(clr.endColor);
			sG = GetGValue(clr.strColor);
			eG = GetGValue(clr.endColor);
			sB = GetBValue(clr.strColor);
			eB = GetBValue(clr.endColor);

			if(GradientFill != NULL)
			{
				TRIVERTEX vert[2];	// for specifying range to gradient fill
				GRADIENT_RECT gRect;

// Warning C4244: conversion from 'int' to 'unsigned short', possible loss of data
#pragma warning (push)
#pragma warning (disable : 4244)
				vert[0].Red   = sR<<8;	// expects 16-bit color values!
				vert[0].Green = sG<<8;
				vert[0].Blue  = sB<<8;
				vert[0].Alpha = 0;		// no fading/transparency
				
				vert[1].Red   = eR<<8;
				vert[1].Green = eG<<8;
				vert[1].Blue  = eB<<8;
				vert[1].Alpha = 0;
#pragma warning (pop)

				gRect.UpperLeft = 0;
				gRect.LowerRight = 1;
				
				BOOL retval;
				if(IsVertical)	// vertically oriented?
				{
					vert[0].x = 0;
					vert[0].y = Offset + minVal;
					vert[1].x = iWidth;
					vert[1].y = Offset + minVal + widthVal;
					retval = GradientFill(memDC,vert,2,&gRect,1,GRADIENT_FILL_RECT_V);
				}
				else
				{
					vert[0].x = Offset + minVal;
					vert[0].y = 0;
					vert[1].x = Offset + minVal + widthVal;
					vert[1].y = iHeight;
					retval = GradientFill(memDC,vert,2,&gRect,1,GRADIENT_FILL_RECT_H);
				}
			}
			else
			{
				// Homebrew version of GradientFill for rectangles -- works pretty well, sort of.
				int i;
				for(i = 0; i < widthVal; i++)	// for each pixel column in bitmap color range
				{
					int R = sR;
					int G = sG;
					int B = sB;
					if(widthVal)
					{
						R += ::MulDiv(eR - sR, i, widthVal);
						G += ::MulDiv(eG - sG, i, widthVal);
						B += ::MulDiv(eB - sB, i, widthVal);
					}

					if(IsVertical)
					{
						// widthVal really refers to height
						//memDC.FillSolidRect(0,minVal+i,iWidth,widthVal-i,GetNearestColor(memDC,RGB(R,G,B)));
						memDC.FillSolidRect(
							0,						// starting X value
							Offset + minVal + i,	// starting Y value
							iWidth,					// full width
							1,						// one pixel height
							GetNearestColor(memDC,RGB(R,G,B)));
					}
					else
					{
						//memDC.FillSolidRect(minVal+i,0,widthVal-i,iHeight,GetNearestColor(memDC,RGB(R,G,B)));
						memDC.FillSolidRect(
							Offset + minVal + i,	// Starting X value
							0,						// Starting Y value
							1,						// 1 pixel wide
							iHeight,				// full height
							GetNearestColor(memDC,RGB(R,G,B)));
					}
				}
			}
		}

		if(m_extendColors)
		{
			// If we have put in colors at the slider ends, then extend those same
			// colors to the rest of the background. We could try to determine the
			// colors by examining the bitmap, but this is awkward and it is just
			// as easy to grab them on-the-fly in the coloring loop above.
			//
			// If you want to see why this is done, just set m_extendColors to FALSE
			// and take a look at the control. Ugly. But there might be a legitimate
			// reason for it so leave the option to suppress.
			if(IsVertical)
			{
				if(gotStartColor)
				{
					memDC.FillSolidRect(0, 0, iWidth, Offset, startColor);
				}
				if(gotEndColor)
				{
					memDC.FillSolidRect(0, iHeight - Offset - 1, iWidth, Offset, endColor);
				}
			}
			else
			{
				if(gotStartColor)
				{
					memDC.FillSolidRect(0, 0, Offset, iHeight, startColor);
				}
				if(gotEndColor)
				{
					memDC.FillSolidRect(iWidth - Offset - 1, 0, Offset, iHeight, endColor);
				}
			}
		}
	}

	// The screen bitmap should now have only the color ranges filled in, no tic
	// marks should be visible.
	if(m_dumpBitmaps)	// debugging
	{
		SaveBitmap("ScrnColors.bmp",memBM);
	}
	
	//////////////////////////////////////////////////////////////
	// More "paraphrasing" from Nic Wilson's work...
	//////////////////////////////////////////////////////////////

	////////////////////////////////////////////////////////////////////////////
	// At this point, memDC's bitmap contains just the color ranges drawn above.
	// No tic marks are visible. Doing SRCINVERT with the mask will draw in the
	// tic marks, but all the colors will be backwards. Also, the tics will be
	// whatever color was drawn in the color range stuff, rather than solid,
	// normal tic marks. SRCINVERT means the RGB values are changed by subtracting
	// from 255:
	//
	//		RGB(255,0,0)    --> RGB(0,255,255)
	//		RGB(247,8,0)    --> RGB(8,247,255)
	//		RGB(214,40,255) --> RGB(41,215,0)
	//
	/////////////////////////////////////////////////////////////////////////////
	memDC.SetBkColor(pDC->GetBkColor());
	memDC.SetTextColor(pDC->GetTextColor());
	memDC.BitBlt(0, 0, iWidth, iHeight, &SaveCDC, 0, 0, SRCINVERT);

	if(m_dumpBitmaps)	// debugging
	{
		SaveBitmap("ScrnInvert.bmp",memBM);
	}

	// Change the tic marks from the color range to the background color. This
	// changes only the tic marks (and the channel centerline) and leaves the
	// rest alone. The tic marks wind up black.
	memDC.BitBlt(0, 0, iWidth, iHeight, &SaveCDC, 0, 0, SRCAND);

	if(m_dumpBitmaps)	// debugging
	{
		SaveBitmap("ScrnAnd.bmp",memBM);
	}

	// Finally, invert the color ranges to their normal values. Since the tic
	// marks in the SaveCDC bitmap are white, they get inverted to black.
	memDC.BitBlt(0, 0, iWidth, iHeight, &SaveCDC, 0, 0, SRCINVERT);

	if(m_dumpBitmaps)	// debugging
	{
		SaveBitmap("ScrnFinal.bmp",memBM);
	}
	
	// Now copy out to screen
	pDC->BitBlt(0,0,iWidth,iHeight,&memDC,0,0,SRCCOPY);

	// restore and clean up
	pDC->SetBkColor(crOldBack);
	pDC->SetTextColor(crOldText);
	DeleteObject(SelectObject(SaveCDC, SaveCBmpOld));
	DeleteDC(SaveCDC);
	DeleteObject(SelectObject(memDC,oldbm));
	DeleteDC(memDC);

	*pResult = CDRF_DODEFAULT;

	m_dumpBitmaps = FALSE;	// only do this once!
}
Esempio n. 25
0
void CCJSizeDockBar::DrawBorders(CDC *pDC, CRect &rect)
{
	int cxBorderLeft	= 0;
	int cxBorderRight	= 0;
	int cyBorderTop		= 0;
	int cyBorderBottom	= 0;
	
	CRect rc;
	rc.CopyRect(&rect);
	
	if (m_dwStyle & CBRS_BORDER_TOP) {
		pDC->FillSolidRect(rc.left,rc.top,rc.Width(),1,m_clrBtnShadow);
		pDC->FillSolidRect(rc.left,rc.top+1,rc.Width(),1,m_clrBtnHilite);
		cyBorderTop+=2;
	}
	
	if (m_dwStyle & CBRS_BORDER_BOTTOM) {
		pDC->FillSolidRect(rc.left,rc.bottom-1,rc.Width(),1,m_clrBtnHilite);
		pDC->FillSolidRect(rc.left,rc.bottom-2,rc.Width(),1,m_clrBtnShadow);
		cyBorderBottom+=2;
	}
	
	if (m_dwStyle & CBRS_BORDER_LEFT) {
		pDC->FillSolidRect(rc.left,rc.top,1,rc.Height(),m_clrBtnShadow);
		pDC->FillSolidRect(rc.left+1,rc.top,1,rc.Height(),m_clrBtnHilite);
		cxBorderLeft+=2;
	}
	
	if (m_dwStyle & CBRS_BORDER_RIGHT) {
		pDC->FillSolidRect(rc.right-2,rc.top,1,rc.Height(),m_clrBtnShadow);
		pDC->FillSolidRect(rc.right-1,rc.top,1,rc.Height(),m_clrBtnHilite);
		cxBorderRight+=2;
	}
	
	UINT nID = ((UINT)(WORD)::GetDlgCtrlID(m_hWnd));
	
	CRect rcTrack;
	rcTrack.CopyRect(&rc);
	
	if (nID == AFX_IDW_SIZEBAR_LEFT) {
		rcTrack.left    = rc.right-m_iTrackBorderSize;
		rcTrack.right  += 1;
		rcTrack.top    += 1;
		rcTrack.bottom -= 1;
		pDC->FillSolidRect(rcTrack,m_clrBtnFace);
		pDC->Draw3dRect(rcTrack,m_clrBtnHilite,m_clrBtnShadow);
		cxBorderRight = m_iTrackBorderSize;
	}
	
	else if (nID == AFX_IDW_SIZEBAR_TOP) {
		rcTrack.top = rc.bottom-m_iTrackBorderSize;
		rcTrack.bottom+=1;
		pDC->FillSolidRect(rcTrack,m_clrBtnFace);
		pDC->Draw3dRect(rcTrack,m_clrBtnHilite,m_clrBtnShadow);
		cyBorderBottom = m_iTrackBorderSize;	
	}
	
	else if (nID == AFX_IDW_SIZEBAR_RIGHT) {
		rcTrack.right   = rc.left+m_iTrackBorderSize;
		rcTrack.left   -= 1;
		rcTrack.top    += 1;
		rcTrack.bottom -= 1;
		pDC->FillSolidRect(rcTrack,m_clrBtnFace);
		pDC->Draw3dRect(rcTrack,m_clrBtnHilite,m_clrBtnShadow);
		cxBorderLeft = m_iTrackBorderSize;		
	}
	
	else if (nID == AFX_IDW_SIZEBAR_BOTTOM) {
		rcTrack.bottom = rc.top+m_iTrackBorderSize;
		rcTrack.top-=1;
		pDC->FillSolidRect(rcTrack,m_clrBtnFace);
		pDC->Draw3dRect(rcTrack,m_clrBtnHilite,m_clrBtnShadow);
		cyBorderTop = m_iTrackBorderSize;	
	}
	
	rect.left	+= cxBorderLeft;
	rect.right	-= cxBorderRight;
	rect.top	+= cyBorderTop;
	rect.bottom	-= cyBorderBottom;
}
Esempio n. 26
0
LRESULT CProgressBar::OnSizeParent(WPARAM, LPARAM lParam)
// This overrides the normal OnSizeParent method (CControlBar)
// Normal control bars can never overlap - each is opened using the parent's
// client rectangle, and then their area is subtracted from the available client
// area, so that they never overlap. 
// However, the progress bar wants to sit over the top of the status bar if
// possible, so before allowing the normal action to proceed...
// If the status window's client rectangle butts onto the layout rect passed in,
// then we extend the layout rectangle to include the status bar, and hence we
// will be placed over the top of the SB.
// NOTE - currently only does this if attached to the BOTTOM of the window.
// If this fails (sttaus bar not open, or at top of window, etc), the progress
// bar will appear normally (above/below all other control bars)
{
	AFX_SIZEPARENTPARAMS FAR* lpLayout = (AFX_SIZEPARENTPARAMS FAR*)lParam;
	CRect StatusRect;

	((CMainFrame *) AfxGetApp()->m_pMainWnd)->GetStatusBarWindowRect(&StatusRect);

	if (!StatusRect.IsRectEmpty())					// Cover status bar (if open)
	{
		// JustinF says: this is a quick bodge so that the progress-bar respects any
		// overriding prefix displayed in the status line by StatusLine::SetPrefix.
		StatusRect.left = StatusLine::GetPrefixWidth();

		// We just move our window so it is covering the status bar, using the
		// HWDP supplied in the AFX_SIZEPARENTPARAMS structure.
		lpLayout->hDWP = ::DeferWindowPos(lpLayout->hDWP, m_hWnd, HWND_TOP,
									 	  StatusRect.left, StatusRect.top,  
										  StatusRect.right - StatusRect.left,
										  StatusRect.bottom - StatusRect.top,
										  SWP_NOACTIVATE);
	}
	else
	{

	#if _MFC_VER < 0x300
		// No status bar - just plonk the progress bar where we can...
		return (CControlBar::OnSizeParent((WPARAM)0, lParam));
	#else
		// resize and reposition this control bar based on styles
		DWORD dwStyle = (m_dwStyle & (CBRS_ALIGN_ANY|CBRS_BORDER_ANY)) |
			(GetStyle() & WS_VISIBLE);

		if ((dwStyle & WS_VISIBLE) && (dwStyle & CBRS_ALIGN_ANY) != 0)
		{
			// align the control bar
			CRect rect;

			if (StatusRect.IsRectEmpty())
			{
				// Status bar is not open - just fit in where we can.
				// (This code copied from barcore.cpp in MFC 3)
				rect.CopyRect(&lpLayout->rect);

				CSize sizeAvail = rect.Size();	// maximum size available

				// get maximum requested size
				CSize size = CalcFixedLayout(lpLayout->bStretch, 
					(dwStyle & CBRS_ORIENT_HORZ) ? TRUE : FALSE);

				size.cx = min(size.cx, sizeAvail.cx);
				size.cy = BarHeight;

				lpLayout->sizeTotal.cy += size.cy;
				lpLayout->sizeTotal.cx = max(lpLayout->sizeTotal.cx, size.cx);
				rect.top = rect.bottom - size.cy;
				lpLayout->rect.bottom -= size.cy;

				rect.right = rect.left + size.cx;
				rect.bottom = rect.top + size.cy;

				// only resize the window if doing layout and not just rect query
				if (lpLayout->hDWP != NULL)
				{
					AfxRepositionWindow(lpLayout, m_hWnd, &rect);
				}
			}
		}
	#endif
	}

	return 0;

}
Esempio n. 27
0
void CCJOutlookBar::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
    CDC*            pDC = CDC::FromHandle( lpDrawItemStruct->hDC );
    CRect           rcItem(lpDrawItemStruct->rcItem);
    CRect           rClient(rcItem);
    CRect           rText;
    CPoint          Pt(((rcItem.Width() - 32) /2 ), rcItem.top + 15);
    CContentItems   pContents = m_pContents[ lpDrawItemStruct->itemID ];
    HICON           hIcon = m_ImageListNormal.ExtractIcon( pContents.GetImageID());

	// deflate the client rect, and set up item and
	// text rect's.
	rClient.DeflateRect( 8, 5 );
	rcItem.CopyRect( rClient );
    rText.CopyRect( rClient );
    rText.top += 45;
	rText.bottom += 10;

    // set the text color to white, and background mode
	// to transparent.
	pDC->SetTextColor( ::GetSysColor( COLOR_WINDOW ) );
	pDC->SetBkMode( TRANSPARENT );

	// draw the button icon and text.
	if( lpDrawItemStruct->itemAction& ODA_DRAWENTIRE ) {
        pDC->DrawIcon( Pt, hIcon );
        pDC->DrawText( pContents.GetText(), rText,
			DT_CENTER | DT_WORDBREAK );
    }

    // if the left mouse button is pressed, offset
	// the button icon.
	if( m_bLBDown ) {
        Pt.x += 2;
        Pt.y += 2;
        rcItem.OffsetRect( 2, 2 );
    }

	// deflate the button rect, and move up.
	rcItem.DeflateRect( 4, 16 );
	rcItem.top -= 8;

	// Draw the button icon and text, if the mouse is over the
	// button, draw the 3d rect, either pressed,
	// or not pressed depending on left mouse button.
	if(( lpDrawItemStruct->itemState& ODS_SELECTED ) &&
		( lpDrawItemStruct->itemAction& ( ODA_SELECT | ODA_DRAWENTIRE ))) {
        
		rcItem.left = ( rcItem.Width()/2 )-5;
		rcItem.right = rcItem.left+37;

		if( m_bHilight ) {
            if( m_bLBDown ) {
              pDC->Draw3dRect( rcItem, ::GetSysColor( COLOR_3DDKSHADOW ),
				  ::GetSysColor( COLOR_BTNFACE ) );
			}
            else {
              pDC->Draw3dRect( rcItem, ::GetSysColor( COLOR_BTNFACE ),
				  ::GetSysColor( COLOR_3DDKSHADOW ) );
			}
        }

        pDC->DrawIcon( Pt, hIcon );
        pDC->DrawText( pContents.GetText(), rText,
			DT_CENTER | DT_WORDBREAK );
	}

	if( !( lpDrawItemStruct->itemState& ODS_SELECTED ) &&
		( lpDrawItemStruct->itemAction& ODA_SELECT )) {
        pDC->FillSolidRect( rClient, ::GetSysColor( COLOR_3DSHADOW ) );
        pDC->DrawIcon(Pt, hIcon);
        pDC->DrawText(pContents.GetText(), rText, DT_CENTER|DT_WORDBREAK);
    }
}
Esempio n. 28
0
void CImageView::ShowImage(QString &strPathName)
{
	const CString &Path = strPathName;
	Jpeg jpeg;
	ZeroMemory(&jpeg, sizeof(jpeg));

	if (!m_JpegCodec.GetJpegInformation((LPCTSTR) Path, &jpeg)) return;
	if (m_dwBufferLength < jpeg.dwLength) {
		if (m_pBuffer) _aligned_free(m_pBuffer);
		m_pBuffer = (BYTE *) _aligned_malloc(jpeg.dwLength, 16);
		m_dwBufferLength = jpeg.dwLength;
	}

	jpeg.pBuffer = (BYTE *) m_pBuffer;
	if (!m_JpegCodec.Decode((LPCTSTR) Path, &jpeg)) {
		return;
	}

	int width = (jpeg.bm.biWidth<= 360)?(2*jpeg.bm.biWidth):(jpeg.bm.biWidth);
	int height = (jpeg.bm.biHeight<= 288)?(2*jpeg.bm.biHeight):(jpeg.bm.biHeight);

	DWORD dwEngId = _ttoi(m_strEngId.GetBuffer());

	CRect	rcVCAROI;
	VCA5_RECT	rcROIEng = CAPPConfigure::Instance()->GetAPPEngineInfo( dwEngId )->tSourceData.rcROI;

	rcVCAROI.left	= rcROIEng.x;
	rcVCAROI.top	= rcROIEng.y;
	rcVCAROI.right	= rcROIEng.x + rcROIEng.w;
	rcVCAROI.bottom	= rcROIEng.y + rcROIEng.h;

	if( rcVCAROI.Size() == CSize(0, 0) ) {
		rcVCAROI.CopyRect(&m_ClientRect);
	} else {
		rcVCAROI.right = min(rcVCAROI.right-1, width);
		rcVCAROI.bottom = min(rcVCAROI.bottom-1, height);
		PIXELTOPERCENT(rcVCAROI.left, rcVCAROI.left, width);
		PIXELTOPERCENT(rcVCAROI.top, rcVCAROI.top, height);
		PIXELTOPERCENT(rcVCAROI.right, rcVCAROI.right, width);
		PIXELTOPERCENT(rcVCAROI.bottom, rcVCAROI.bottom, height);

		PERCENTTOPIXEL(rcVCAROI.left, rcVCAROI.left, m_ClientRect.right);
		PERCENTTOPIXEL(rcVCAROI.top, rcVCAROI.top, m_ClientRect.bottom);
		PERCENTTOPIXEL(rcVCAROI.right, rcVCAROI.right, m_ClientRect.right);
		PERCENTTOPIXEL(rcVCAROI.bottom, rcVCAROI.bottom, m_ClientRect.bottom);
	}

	m_ClientRect.left = 0;
	m_ClientRect.top = 0;
	m_ClientRect.right = width;
	m_ClientRect.bottom = height;

	AdjustDlgRect(width, height);
	RelocateControls(width, height);
	
	
	DrawImage(jpeg.bm.biWidth, jpeg.bm.biHeight, jpeg.pImage, jpeg.bm);
	DrawSingleZone(rcVCAROI, jpeg.pZone);
	DrawObject(rcVCAROI, jpeg.bm.biWidth, jpeg.bm.biHeight, jpeg.pObject);
	if(jpeg.pRule) DrawTimeStampAndRuleType(jpeg.bm.biWidth, jpeg.bm.biHeight, jpeg.i64TimeStamp, jpeg.pRule->usRuleType);

	
	RECT	ScreenRect;
	ScreenRect = m_ClientRect;

	ClientToScreen((POINT*)&ScreenRect.left );
	ClientToScreen((POINT*)&ScreenRect.right );

	m_pD3d->PrimaryPresentation(&ScreenRect, &m_ClientRect);
}
Esempio n. 29
0
void CCoolBarCtrl::DoPaint(CDC* pDC, CRect& rcClient, BOOL bTransparent)
{
	CRect rcItem( rcClient.left + MARGIN_WIDTH, rcClient.top + 1, rcClient.right - MARGIN_WIDTH, rcClient.bottom - 1 );
	CRect rcCopy;
	
	if ( m_bGripper )
	{
		if ( bTransparent )
		{
			for ( int nY = rcClient.top + 4 ; nY < rcClient.bottom - 4 ; nY += 2 )
			{
				pDC->Draw3dRect( rcClient.left + 3, nY, GRIPPER_WIDTH, 1,
					CoolInterface.m_crDisabled, CoolInterface.m_crDisabled );
			}
		}
		else
		{
			for ( int nY = rcClient.top + 4 ; nY < rcClient.bottom - 4 ; nY += 2 )
			{
				pDC->Draw3dRect( rcClient.left + 3, nY, GRIPPER_WIDTH, 2,
					CoolInterface.m_crDisabled, CoolInterface.m_crMidtone );
			}
			
			pDC->ExcludeClipRect( rcClient.left + 3, rcClient.top + 4, rcClient.left + GRIPPER_WIDTH + 2, rcClient.bottom - 4 );
		}
		
		rcItem.left += GRIPPER_WIDTH;
	}
	
	if ( m_pItems.GetCount() == 0 ) return;
	
	CFont* pOldFont = (CFont*)pDC->SelectObject( m_bBold ? &CoolInterface.m_fntBold : &CoolInterface.m_fntNormal );
	BOOL bRight = FALSE;
	
	for ( POSITION pos = m_pItems.GetHeadPosition() ; pos ; )
	{
		CCoolBarItem* pItem = (CCoolBarItem*)m_pItems.GetNext( pos );
		
		if ( pItem->m_nID == ID_RIGHTALIGN && ! bRight )
		{
			int nRight = 0;
			bRight = TRUE;
			
			for ( POSITION pos2 = pos ; pos2 ; )
			{
				CCoolBarItem* pRight = (CCoolBarItem*)m_pItems.GetNext( pos2 );
				if ( pRight->m_bVisible ) nRight += pRight->m_nWidth;
			}
			
			if ( rcClient.right - rcItem.left >= nRight + MARGIN_WIDTH )
			{
				rcItem.left = rcClient.right - nRight - MARGIN_WIDTH;
			}
		}
		else if ( pItem->m_bVisible )
		{
			
			rcItem.right = rcItem.left + pItem->m_nWidth;
			rcCopy.CopyRect( &rcItem );
			
			CWnd* pCtrl = ( pItem->m_nCtrlID ) ? GetDlgItem( pItem->m_nCtrlID ) : NULL;
			
			pItem->Paint( pDC, rcCopy, m_pDown == pItem,
				m_pHot == pItem || ( pCtrl && pCtrl == GetFocus() ),
				m_bMenuGray, bTransparent );
			
			if ( ! bTransparent ) pDC->ExcludeClipRect( &rcItem );
			if ( pCtrl ) SmartMove( pCtrl, &rcCopy );
			
			rcItem.OffsetRect( rcItem.Width(), 0 );
		}
		else if ( pItem->m_nCtrlID )
		{
			CWnd* pCtrl = GetDlgItem( pItem->m_nCtrlID );
			if ( pCtrl && pCtrl->IsWindowVisible() ) pCtrl->ShowWindow( SW_HIDE );
		}
	}
	
	pDC->SelectObject( pOldFont );
}
Esempio n. 30
0
LRESULT CControlBar::OnSizeParent(WPARAM, LPARAM lParam)
{
	AFX_SIZEPARENTPARAMS* lpLayout = (AFX_SIZEPARENTPARAMS*)lParam;
	DWORD dwStyle = RecalcDelayShow(lpLayout);

	if ((dwStyle & WS_VISIBLE) && (dwStyle & CBRS_ALIGN_ANY) != 0)
	{
		// align the control bar
		CRect rect;
		rect.CopyRect(&lpLayout->rect);

		CSize sizeAvail = rect.Size();  // maximum size available

		// get maximum requested size
		CSize size = CalcFixedLayout(lpLayout->bStretch,
			dwStyle & CBRS_ORIENT_HORZ);

		size.cx = min(size.cx, sizeAvail.cx);
		size.cy = min(size.cy, sizeAvail.cy);

		if (dwStyle & CBRS_ORIENT_HORZ)
		{
			lpLayout->sizeTotal.cy += size.cy;
			lpLayout->sizeTotal.cx = max(lpLayout->sizeTotal.cx, size.cx);
			if (dwStyle & CBRS_ALIGN_TOP)
				lpLayout->rect.top += size.cy;
			else if (dwStyle & CBRS_ALIGN_BOTTOM)
			{
				rect.top = rect.bottom - size.cy;
				lpLayout->rect.bottom -= size.cy;
			}
		}
		else if (dwStyle & CBRS_ORIENT_VERT)
		{
			lpLayout->sizeTotal.cx += size.cx;
			lpLayout->sizeTotal.cy = max(lpLayout->sizeTotal.cy, size.cy);
			if (dwStyle & CBRS_ALIGN_LEFT)
				lpLayout->rect.left += size.cx;
			else if (dwStyle & CBRS_ALIGN_RIGHT)
			{
				rect.left = rect.right - size.cx;
				lpLayout->rect.right -= size.cx;
			}
		}
		else
		{
			ASSERT(FALSE);      // can never happen
		}

		rect.right = rect.left + size.cx;
		rect.bottom = rect.top + size.cy;

#ifdef _MAC
		// account for the Macintosh grow box, if there is one
		CWnd* pWnd = GetParentFrame();
		if (pWnd != NULL)
		{
			DWORD dwWndStyle = pWnd->GetStyle();
			DWORD dwExStyle = pWnd->GetExStyle();

			if (!(dwExStyle & WS_EX_MDIFRAME) &&
				(dwExStyle & WS_EX_FORCESIZEBOX) &&
				!(dwWndStyle & (WS_VSCROLL|WS_HSCROLL)))
			{
				CRect rectParent;
				pWnd->GetClientRect(rectParent);

				if (dwStyle & CBRS_ALIGN_BOTTOM)
				{
					if (rect.bottom > rectParent.bottom - afxData.cxVScroll + 1)
						rect.right -= (afxData.cxVScroll - 1);
				}
				else if (dwStyle & CBRS_ALIGN_RIGHT)
				{
					if (rect.bottom > rectParent.bottom - afxData.cyHScroll + 1)
						rect.bottom -= (afxData.cxVScroll - 1);
				}
			}
		}
#endif

		// only resize the window if doing layout and not just rect query
		if (lpLayout->hDWP != NULL)
			AfxRepositionWindow(lpLayout, m_hWnd, &rect);
	}
	return 0;
}