Click here to Skip to main content
15,881,281 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 277.9K   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.
#ifndef __CeStaticGroup_h__
#define __CeStaticGroup_h__

#include "CeWnd.h"
#include "CeMisc.h"
#include "CeString.h"

class CeStaticGroup: public CeWnd
{
public:
	void OnPaint(bool& bHandled)
	{
		bHandled = true;
		PAINTSTRUCT ps;
		HDC hDC = ::BeginPaint(*this, &ps);

		// Set the proper font
		HFONT hFontCreated = NULL;
		HFONT hFont = (HFONT) ::SendMessage(m_hWnd, WM_GETFONT, 0, 0);

		LOGFONT lf;
		if (GetObject(hFont, sizeof LOGFONT, &lf))
		{
			lf.lfWeight = 900;
			hFontCreated = CreateFontIndirect(&lf); 
			hFont = hFontCreated;
		}

		HFONT hFontOld = (HFONT) ::SelectObject(hDC, hFont);

		//TEXTMETRIC tm;
		//::GetTextMetrics(hDC, &tm);
		//tm.tmHeight;

		COLORREF clrStatic = GetSysColor(COLOR_STATIC);
#if defined(_WIN32_WCE_EMULATION)
		COLORREF clrStaticText = GetSysColor(COLOR_BTNTEXT);
#else
		COLORREF clrStaticText = GetSysColor(COLOR_STATICTEXT);
#endif

		// Paint the text
		CeRect rc;
		CeString strWnd(m_hWnd);
		GetClientRect(rc);

		::SetTextColor(hDC, clrStaticText);
		COLORREF cr = ::SetBkColor(hDC, clrStatic);

		DrawText( hDC, strWnd, strWnd.GetLength(), rc,
			DT_LEFT | DT_VCENTER | DT_SINGLELINE);

		// Paint the line
		CeSize sz;
		::GetTextExtentPoint32(hDC, strWnd, strWnd.GetLength(), &sz);
		rc.left += sz.cx;

		::SetBkColor(hDC, clrStatic);
		::ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);

		::SetBkColor(hDC, clrStaticText);
		rc.top += rc.Height()/2 - 1;
		rc.bottom = rc.top + 2;
		rc.left += 4;
		::ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL);

		::SelectObject(hDC, hFontOld);
		::SetBkColor(hDC, cr);

		if (hFontCreated)
			::DeleteObject(hFontCreated);

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

#endif // __CeStaticGroup_h__

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