Click here to Skip to main content
15,884,739 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 278.4K   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.
#include "StdAfx.h"

#include "CeWnd.h"
#include "CeSplit.h"

void CeSplitFrame::GetWindowPlacements(CeRect& rc, CeRect& rcTop, CeRect& rcBottom)
{
	if (GetSystemMetrics(SM_CXSCREEN) >= GetSystemMetrics(SM_CYSCREEN))
	{
		// HPC
		rcTop = CeRect(rc.left, rc.top, rc.left +  2 * rc.Width() / 5, rc.bottom);
		rcBottom = CeRect(rcTop.right, rc.top, rc.right, rc.bottom);
		m_bVertical = false;
		rcTop.right -= 3;
		rcBottom.left += 3;
	}
	else
	{
		// PPC
		rcTop = CeRect(rc.left, rc.top, rc.right, rc.top + rc.Height() / 2);
		rcBottom = CeRect(rc.left, rcTop.bottom, rc.right, rc.bottom);
		m_bVertical = true;
		rcTop.bottom -= 3;
		rcBottom.top += 3;
	}
}


void CeSplitFrame::OnLButtonDown( UINT nFlags, POINT point, bool& bHandled )
{
	bHandled = true;

	SetCapture();
	Invalidate();

	m_bMoving = true;
}

void CeSplitFrame::OnLButtonUp( UINT nFlags, POINT point, bool& bHandled )
{
	bHandled = true;

	ReleaseCapture();
	Invalidate();

	m_bMoving = false;
}


void CeSplitFrame::OnMouseMove( UINT nFlags, POINT point, bool& bHandled )
{
	bHandled = true;

	if (m_bMoving)
	{
		CeRect rc, rcTop, rcBottom;

		GetClientRect(rc);
#ifdef _WIN32_WCE
		rc.top += m_cmdband.Height();
#endif
		if (! m_bVertical)
		{
			// HPC
			rcTop = CeRect(rc.left, rc.top, point.x - 3, rc.bottom);
			rcBottom = CeRect(rcTop.right + 3, rc.top, rc.right, rc.bottom);
			rcTop.right--;
			rcBottom.left++;
		}
		else
		{
			// PPC
			rcTop = CeRect(rc.left, rc.top, rc.right, point.y - 3);
			rcBottom = CeRect(rc.left, rcTop.bottom + 3, rc.right, rc.bottom);
			rcTop.bottom--;
			rcBottom.top++;
		}

		if (rcTop.Height() >= 0 && rcBottom.Height() >= 0)
		{
			::MoveWindow(m_hwndTop, rcTop.left, rcTop.top, rcTop.Width(), rcTop.Height(), TRUE);
			::MoveWindow(m_hwndBottom, rcBottom.left, rcBottom.top, rcBottom.Width(), rcBottom.Height(), TRUE);
		}
	}
}

//
// Paint the divider between the two panes
//
void CeSplitFrame::OnPaint( bool& bHandled )
{
	bHandled = true;
	PAINTSTRUCT ps;
	HDC hDC = ::BeginPaint(*this, &ps);

	CeRect rc;
	::GetWindowRect(m_hwndTop, rc);
	ScreenToClient(rc);

	if (m_bVertical)
	{
		// PPC
		rc.top = rc.bottom;
		rc.bottom += 6;

		rc.left -= 2;
		rc.right += 2;
	}
	else
	{
		// HPC
		rc.left = rc.right;
		rc.right += 6;

		rc.top -= 2;
		rc.bottom += 2;
	}

	if (m_bMoving)
	{
		::SetBkColor(hDC, RGB(0,0,0));
		::ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);
	}
	else
	{
		::DrawFrameControl(hDC, &rc, DFC_BUTTON, DFCS_BUTTONPUSH);
	}

	::EndPaint(*this, &ps);
}


//
// Incase we're sized, set to defaults
//
void CeSplitFrame::OnSize( UINT nType, int cx, int cy, bool& bHandled )
{
	bHandled = false;	// allow default

	CeRect rc;
	GetClientRect(&rc);
#ifdef _WIN32_WCE
	rc.top += m_cmdband.Height();
#endif

	CeRect rcTop, rcBottom;
	GetWindowPlacements(rc, rcTop, rcBottom);

	::MoveWindow(m_hwndBottom, rcBottom.left, rcBottom.top, 
		rcBottom.Width(), rcBottom.Height(), TRUE);

	::MoveWindow(m_hwndTop, rcTop.left, rcTop.top, 
		rcTop.Width(), rcTop.Height(), TRUE);

	TRACE0("Size Change\n");
}

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