Click here to Skip to main content
15,883,773 members
Articles / Mobile Apps / Windows Mobile

A Picture Viewer for the Pocket PC 2002

Rate me:
Please Sign up or sign in to vote.
4.79/5 (21 votes)
2 Nov 2003CPOL4 min read 496.4K   685   43  
Putting imgdecmp.lib to work with a few extras.
// CeTitleBar.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "CeTitleBar.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


//---------------------------------------------------------------------------
//
//	CCeTitleBar
//
//---------------------------------------------------------------------------


CCeTitleBar::CCeTitleBar()
:	m_nHeight	(17)
{
	LOGFONT	lf;
	long	nHeight;

	//
	// Create the option font
	//
	// Points  8 : -11
	//         9 : -12
	//		  10 : -13
	nHeight = -11;//(LONG)(-8 * pDC.GetDeviceCaps(LOGPIXELSY) / 72);

	lf.lfHeight			= nHeight;
	lf.lfWidth			= 0;
	lf.lfEscapement		= 0;
	lf.lfOrientation	= 0;
	lf.lfWeight			= FW_BOLD;
	lf.lfItalic			= FALSE;
	lf.lfUnderline		= FALSE;
	lf.lfStrikeOut		= 0;
	lf.lfCharSet		= ANSI_CHARSET;
	lf.lfOutPrecision	= OUT_DEFAULT_PRECIS;
	lf.lfClipPrecision	= CLIP_DEFAULT_PRECIS;
	lf.lfQuality		= DEFAULT_QUALITY;
	lf.lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
	lstrcpy(lf.lfFaceName, TEXT("Tahoma"));
	m_fntDefault.CreateFontIndirect(&lf);
}


CCeTitleBar::~CCeTitleBar()
{
}


BEGIN_MESSAGE_MAP(CCeTitleBar, CControlBar)
	//{{AFX_MSG_MAP(CCeTitleBar)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


//---------------------------------------------------------------------------
//
//	CCeTitleBar interface to CControlBar
//
//---------------------------------------------------------------------------


// CCeTitleBar::OnUpdateCmdUI
//
//		Pure virtual from CControlBar.
//		Dummy implementation: not needed
//
void CCeTitleBar::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler)
{
}


// CCeTitleBar::CalcFixedLayout
//
//		Make sure the bar height is 17 pixels.
//
CSize CCeTitleBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
{
	CSize		size(0,0);
	CFrameWnd*	pWnd = GetDockingFrame();

	if(pWnd)
	{
		CRect	rc;

		pWnd->GetClientRect(&rc);

		if(bHorz)
		{
			size.cx = rc.Width();
			size.cy = m_nHeight;
		}
	}
	return size;
}


// CCeTitleBar::CalcDynamicLayout
//
//		Make sure the bar height is 17 pixels.
//
CSize CCeTitleBar::CalcDynamicLayout(int nLength, DWORD nMode)
{
	CSize		size(0,0);
	CFrameWnd*	pWnd = GetDockingFrame();

	if(pWnd)
	{
		CRect	rc;

		pWnd->GetClientRect(&rc);

		size.cx = rc.Width();
		size.cy = m_nHeight;
	}
	return size;
}


//---------------------------------------------------------------------------
//
//	CCeTitleBar operations
//
//---------------------------------------------------------------------------


// CCeTitleBar::Create
//
//		Creates the letter bar
//
BOOL CCeTitleBar::Create(CWnd *pParentWnd, UINT nID)
{
	CRect	rc;

	m_dwStyle	= CBRS_BORDER_BOTTOM | CBRS_ALIGN_TOP;

	pParentWnd->GetClientRect(&rc);

	return CControlBar::Create(NULL, _T(""), WS_CHILD | WS_VISIBLE, 
				rc, pParentWnd, nID);
}


void CCeTitleBar::SetTitle(LPCTSTR pszTitle, BOOL bRepaint)
{
	m_strTitle = pszTitle;
	if(bRepaint)
		InvalidateRect(NULL);
}


void CCeTitleBar::SetTitle(UINT nStrID, BOOL bRepaint)
{
	m_strTitle.LoadString(nStrID);
	if(bRepaint)
		InvalidateRect(NULL);
}


//---------------------------------------------------------------------------
//
//	CCeTitleBar message handlers
//
//---------------------------------------------------------------------------


// CCeTitleBar::OnPaint
//
//		Paints the title
//
void CCeTitleBar::OnPaint() 
{
	CPaintDC	dc(this);
	CRect		rc;
	CFont*		pFont;
	CBrush		brshBack(RGB(255, 255, 255)),
			*	pBrsh;
	CPen		penNull(PS_NULL, 0, 0),
			*	pPen;
	int			nBkMode;
	COLORREF	crText(RGB(0, 0, 156)),
				crOld;

	GetClientRect(&rc);
	
	pBrsh = dc.SelectObject(&brshBack);
	pPen  = dc.SelectObject(&penNull);
	dc.Rectangle(&rc);

	dc.SelectObject(pBrsh);
	dc.SelectObject(pPen);

	dc.MoveTo(rc.left, rc.bottom - 1);
	dc.LineTo(rc.right, rc.bottom - 1);

	rc.left += 4;
	rc.top += 1;

	pFont	= dc.SelectObject(&m_fntDefault);
	nBkMode	= dc.SetBkMode(TRANSPARENT);
	crOld	= dc.SetTextColor(crText);

	dc.DrawText(m_strTitle, -1, &rc, DT_LEFT | DT_SINGLELINE);

	dc.SetTextColor(crOld);
	dc.SetBkMode(nBkMode);
	dc.SelectObject(pFont);
}

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
Software Developer (Senior) Frotcom International
Portugal Portugal
I work on R&D for Frotcom International, a company that develops web-based fleet management solutions.

Comments and Discussions