|
// Helpers.cpp
//
// Author : David Shepherd
// Copyright (c) 2002, DaeDoe-Software
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Helpers.h"
CRect ForceRectIntoRect(const CRect &Destination,const CRect &Source)
{
CRect NewRect=Source;
// check the width is not too large
if(NewRect.Width() > Destination.Width())
{
NewRect.right=NewRect.left+Destination.Width();
}
// check the height is not too large
if(NewRect.Height() > Destination.Height())
{
NewRect.bottom=NewRect.top+Destination.Height();
}
// check the horizontal positioning
if(NewRect.left < 0)
{
NewRect.OffsetRect(-NewRect.left,0);
}
if(NewRect.right > Destination.right)
{
NewRect.OffsetRect(Destination.right-NewRect.right,0);
}
// check the vertical positioning
if(NewRect.top < 0)
{
NewRect.OffsetRect(0,-NewRect.top);
}
if(NewRect.bottom > Destination.bottom)
{
NewRect.OffsetRect(0,Destination.bottom-NewRect.bottom);
}
return NewRect;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.