Click here to Skip to main content
15,886,798 members
Articles / Web Development / HTML

A Comprehensive CE Class Library to Replace ATL and MFC

Rate me:
Please Sign up or sign in to vote.
4.48/5 (14 votes)
4 Oct 2000CPOL 279.1K   998   70  
A collection of classes for CE that do not use ATL or MFC, plus an FTP client, database viewer, and sample application that solves beam deflection equations.

// CeSize
inline CeSize::CeSize()
	{ /* random filled */ }
inline CeSize::CeSize(int initCX, int initCY)
	{ cx = initCX; cy = initCY; }
inline CeSize::CeSize(SIZE initSize)
	{ *(SIZE*)this = initSize; }
inline CeSize::CeSize(POINT initPt)
	{ *(POINT*)this = initPt; }
inline CeSize::CeSize(DWORD dwSize)
	{
		cx = (short)LOWORD(dwSize);
		cy = (short)HIWORD(dwSize);
	}
inline BOOL CeSize::operator==(SIZE size) const
	{ return (cx == size.cx && cy == size.cy); }
inline BOOL CeSize::operator!=(SIZE size) const
	{ return (cx != size.cx || cy != size.cy); }
inline void CeSize::operator+=(SIZE size)
	{ cx += size.cx; cy += size.cy; }
inline void CeSize::operator-=(SIZE size)
	{ cx -= size.cx; cy -= size.cy; }
inline CeSize CeSize::operator+(SIZE size) const
	{ return CeSize(cx + size.cx, cy + size.cy); }
inline CeSize CeSize::operator-(SIZE size) const
	{ return CeSize(cx - size.cx, cy - size.cy); }
inline CeSize CeSize::operator-() const
	{ return CeSize(-cx, -cy); }
inline CePoint CeSize::operator+(POINT point) const
	{ return CePoint(cx + point.x, cy + point.y); }
inline CePoint CeSize::operator-(POINT point) const
	{ return CePoint(cx - point.x, cy - point.y); }
inline CeRect CeSize::operator+(const RECT* lpRect) const
	{ return CeRect(lpRect) + *this; }
inline CeRect CeSize::operator-(const RECT* lpRect) const
	{ return CeRect(lpRect) - *this; }

// CePoint
inline CePoint::CePoint()
	{ /* random filled */ }
inline CePoint::CePoint(int initX, int initY)
	{ x = initX; y = initY; }
#if !defined(_AFX_CORE_IMPL) || !defined(_AFXDLL) || defined(_DEBUG)
inline CePoint::CePoint(POINT initPt)
	{ *(POINT*)this = initPt; }
#endif
inline CePoint::CePoint(SIZE initSize)
	{ *(SIZE*)this = initSize; }
inline CePoint::CePoint(DWORD dwPoint)
	{
		x = (short)LOWORD(dwPoint);
		y = (short)HIWORD(dwPoint);
	}
inline void CePoint::Offset(int xOffset, int yOffset)
	{ x += xOffset; y += yOffset; }
inline void CePoint::Offset(POINT point)
	{ x += point.x; y += point.y; }
inline void CePoint::Offset(SIZE size)
	{ x += size.cx; y += size.cy; }
inline BOOL CePoint::operator==(POINT point) const
	{ return (x == point.x && y == point.y); }
inline BOOL CePoint::operator!=(POINT point) const
	{ return (x != point.x || y != point.y); }
inline void CePoint::operator+=(SIZE size)
	{ x += size.cx; y += size.cy; }
inline void CePoint::operator-=(SIZE size)
	{ x -= size.cx; y -= size.cy; }
inline void CePoint::operator+=(POINT point)
	{ x += point.x; y += point.y; }
inline void CePoint::operator-=(POINT point)
	{ x -= point.x; y -= point.y; }
inline CePoint CePoint::operator+(SIZE size) const
	{ return CePoint(x + size.cx, y + size.cy); }
inline CePoint CePoint::operator-(SIZE size) const
	{ return CePoint(x - size.cx, y - size.cy); }
inline CePoint CePoint::operator-() const
	{ return CePoint(-x, -y); }
inline CePoint CePoint::operator+(POINT point) const
	{ return CePoint(x + point.x, y + point.y); }
inline CeSize CePoint::operator-(POINT point) const
	{ return CeSize(x - point.x, y - point.y); }
inline CeRect CePoint::operator+(const RECT* lpRect) const
	{ return CeRect(lpRect) + *this; }
inline CeRect CePoint::operator-(const RECT* lpRect) const
	{ return CeRect(lpRect) - *this; }

// CeRect
inline CeRect::CeRect()
	{ /* random filled */ }
inline CeRect::CeRect(int l, int t, int r, int b)
	{ left = l; top = t; right = r; bottom = b; }
inline CeRect::CeRect(const RECT& srCeRect)
	{ ::CopyRect(this, &srCeRect); }
inline CeRect::CeRect(LPCRECT lpSrCeRect)
	{ ::CopyRect(this, lpSrCeRect); }
inline CeRect::CeRect(POINT point, SIZE size)
	{ right = (left = point.x) + size.cx; bottom = (top = point.y) + size.cy; }
inline CeRect::CeRect(POINT topLeft, POINT bottomRight)
	{ left = topLeft.x; top = topLeft.y;
		right = bottomRight.x; bottom = bottomRight.y; }
inline int CeRect::Width() const
	{ return right - left; }
inline int CeRect::Height() const
	{ return bottom - top; }
inline CeSize CeRect::Size() const
	{ return CeSize(right - left, bottom - top); }
inline CePoint& CeRect::TopLeft()
	{ return *((CePoint*)this); }
inline CePoint& CeRect::BottomRight()
	{ return *((CePoint*)this+1); }
inline const CePoint& CeRect::TopLeft() const
	{ return *((CePoint*)this); }
inline const CePoint& CeRect::BottomRight() const
	{ return *((CePoint*)this+1); }
inline CePoint CeRect::CenterPoint() const
	{ return CePoint((left+right)/2, (top+bottom)/2); }
inline CeRect::operator LPRECT()
	{ return this; }
inline CeRect::operator LPCRECT() const
	{ return this; }
inline BOOL CeRect::IsRectEmpty() const
	{ return ::IsRectEmpty(this); }
inline BOOL CeRect::IsRectNull() const
	{ return (left == 0 && right == 0 && top == 0 && bottom == 0); }
inline BOOL CeRect::PtInRect(POINT point) const
	{ return ::PtInRect(this, point); }
inline void CeRect::SetRect(int x1, int y1, int x2, int y2)
	{ ::SetRect(this, x1, y1, x2, y2); }
inline void CeRect::SetRect(POINT topLeft, POINT bottomRight)
	{ ::SetRect(this, topLeft.x, topLeft.y, bottomRight.x, bottomRight.y); }
inline void CeRect::SetRectEmpty()
	{ ::SetRectEmpty(this); }
inline void CeRect::CopyRect(LPCRECT lpSrCeRect)
	{ ::CopyRect(this, lpSrCeRect); }
inline BOOL CeRect::EqualRect(LPCRECT lpRect) const
	{ return ::EqualRect(this, lpRect); }
inline void CeRect::InflateRect(int x, int y)
	{ ::InflateRect(this, x, y); }
inline void CeRect::InflateRect(SIZE size)
	{ ::InflateRect(this, size.cx, size.cy); }
inline void CeRect::DeflateRect(int x, int y)
	{ ::InflateRect(this, -x, -y); }
inline void CeRect::DeflateRect(SIZE size)
	{ ::InflateRect(this, -size.cx, -size.cy); }
inline void CeRect::OffsetRect(int x, int y)
	{ ::OffsetRect(this, x, y); }
inline void CeRect::OffsetRect(POINT point)
	{ ::OffsetRect(this, point.x, point.y); }
inline void CeRect::OffsetRect(SIZE size)
	{ ::OffsetRect(this, size.cx, size.cy); }
inline BOOL CeRect::IntersectRect(LPCRECT lpRect1, LPCRECT lpRect2)
	{ return ::IntersectRect(this, lpRect1, lpRect2);}
inline BOOL CeRect::UnionRect(LPCRECT lpRect1, LPCRECT lpRect2)
	{ return ::UnionRect(this, lpRect1, lpRect2); }
inline void CeRect::operator=(const RECT& srCeRect)
	{ ::CopyRect(this, &srCeRect); }
inline BOOL CeRect::operator==(const RECT& rect) const
	{ return ::EqualRect(this, &rect); }
inline BOOL CeRect::operator!=(const RECT& rect) const
	{ return !::EqualRect(this, &rect); }
inline void CeRect::operator+=(POINT point)
	{ ::OffsetRect(this, point.x, point.y); }
inline void CeRect::operator+=(SIZE size)
	{ ::OffsetRect(this, size.cx, size.cy); }
inline void CeRect::operator+=(LPCRECT lpRect)
	{ InflateRect(lpRect); }
inline void CeRect::operator-=(POINT point)
	{ ::OffsetRect(this, -point.x, -point.y); }
inline void CeRect::operator-=(SIZE size)
	{ ::OffsetRect(this, -size.cx, -size.cy); }
inline void CeRect::operator-=(LPCRECT lpRect)
	{ DeflateRect(lpRect); }
inline void CeRect::operator&=(const RECT& rect)
	{ ::IntersectRect(this, this, &rect); }
inline void CeRect::operator|=(const RECT& rect)
	{ ::UnionRect(this, this, &rect); }
inline CeRect CeRect::operator+(POINT pt) const
	{ CeRect rect(*this); ::OffsetRect(&rect, pt.x, pt.y); return rect; }
inline CeRect CeRect::operator-(POINT pt) const
	{ CeRect rect(*this); ::OffsetRect(&rect, -pt.x, -pt.y); return rect; }
inline CeRect CeRect::operator+(SIZE size) const
	{ CeRect rect(*this); ::OffsetRect(&rect, size.cx, size.cy); return rect; }
inline CeRect CeRect::operator-(SIZE size) const
	{ CeRect rect(*this); ::OffsetRect(&rect, -size.cx, -size.cy); return rect; }
inline CeRect CeRect::operator+(LPCRECT lpRect) const
	{ CeRect rect(this); rect.InflateRect(lpRect); return rect; }
inline CeRect CeRect::operator-(LPCRECT lpRect) const
	{ CeRect rect(this); rect.DeflateRect(lpRect); return rect; }
inline CeRect CeRect::operator&(const RECT& rect2) const
	{ CeRect rect; ::IntersectRect(&rect, this, &rect2);
		return rect; }
inline CeRect CeRect::operator|(const RECT& rect2) const
	{ CeRect rect; ::UnionRect(&rect, this, &rect2);
		return rect; }
inline BOOL CeRect::SubtractRect(LPCRECT lpRectSrc1, LPCRECT lpRectSrc2)
	{ return ::SubtractRect(this, lpRectSrc1, lpRectSrc2); }

inline void CeRect::ScreenToClient(HWND hWnd)
	{ ::ScreenToClient(hWnd, (LPPOINT)this); ::ScreenToClient(hWnd, ((LPPOINT)this)+1); }
inline void CeRect::ClientToScreen(HWND hWnd)
	{ ::ClientToScreen(hWnd, (LPPOINT)this); ::ClientToScreen(hWnd, ((LPPOINT)this)+1); }

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions