|
// ExtLabel.cpp : implementation file
//
#include "stdafx.h"
#include "StatusPanes.h"
#include "ExtLabel.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CExtLabel
CExtLabel::CExtLabel()
{
}
CExtLabel::~CExtLabel()
{
}
BEGIN_MESSAGE_MAP(CExtLabel, CStatic)
//{{AFX_MSG_MAP(CExtLabel)
ON_WM_ERASEBKGND()
ON_WM_PAINT()
ON_WM_SETCURSOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExtLabel message handlers
BOOL CExtLabel::OnEraseBkgnd(CDC* pDC)
{
pDC;
return TRUE;
}
//////////////////////////////////////////////////////////////////////////
void CExtLabel::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rcClient;
GetClientRect( &rcClient );
CRgn rgn;
rgn.CreateRectRgnIndirect(&rcClient);
dc.SelectClipRgn(&rgn);
if( g_PaintManager->GetCb2DbTransparentMode(this) )
{
CExtPaintManager::stat_ExcludeChildAreas(
dc,
GetSafeHwnd(),
CExtPaintManager::stat_DefExcludeChildAreaCallback
);
g_PaintManager->PaintDockerBkgnd( dc, this );
} // if( g_PaintManager->GetCb2DbTransparentMode(this) )
else
dc.FillSolidRect( &rcClient, g_PaintManager->GetColor(CExtPaintManager::CLR_3DFACE_OUT) );
//////////////////////////////////////////////////////////////////////////
// paint text
//////////////////////////////////////////////////////////////////////////
CString strText;
GetWindowText(strText);
DWORD style = GetStyle();
DWORD dwFlags = 0;
switch (style & SS_TYPEMASK)
{
case SS_RIGHT:
dwFlags = DT_RIGHT | DT_WORDBREAK;
break;
case SS_CENTER:
dwFlags = SS_CENTER | DT_WORDBREAK;
break;
case SS_LEFTNOWORDWRAP:
dwFlags = DT_LEFT;
break;
default: // treat other types as left
case SS_LEFT:
dwFlags = DT_LEFT | DT_WORDBREAK;
break;
}
// Added to expand tabs...
if(strText.Find(_T('\t')) != -1)
dwFlags |= DT_EXPANDTABS;
// If the text centered make an assumtion that
// the will want to center verticly as well
if (style & SS_CENTERIMAGE){
dwFlags = DT_CENTER;
// Apply
if (strText.Find(_T("\r\n")) == -1){
dwFlags |= DT_VCENTER;
// And because DT_VCENTER only works with single lines
dwFlags |= DT_SINGLELINE;
}
}
dwFlags |= (DT_VCENTER|DT_END_ELLIPSIS);
COLORREF clrOldText;
INT nOldBkMode = dc.SetBkMode( TRANSPARENT );
LOGFONT lf;
memset(&lf,0,sizeof(LOGFONT));
lf.lfQuality = PROOF_QUALITY;
lf.lfHeight = 16;
lf.lfWeight = 600;
lstrcpy(lf.lfFaceName, _T("Arial"));
CFont f;
f.CreateFontIndirect(&lf);
CFont * pOldFont = dc.SelectObject(&f);
CRect rc;
rc = rcClient;
clrOldText = dc.SetTextColor( g_PaintManager->GetColor( COLOR_3DHILIGHT) );
rc.top -= 3;
dc.DrawText(strText,rc,dwFlags);
rc = rcClient;
rc.top -= 1;
rc.left += 2;
dc.SetTextColor(GetSysColor(COLOR_3DSHADOW));
dc.DrawText(strText,rc,dwFlags);
rc = rcClient;
rc.left += 1;
rc.top -= 2;
dc.SetTextColor( RGB(0,0,255) );
dc.DrawText(strText,rc,dwFlags);
dc.SelectObject( pOldFont );
f.DeleteObject();
dc.SetBkMode( nOldBkMode );
dc.SetTextColor( clrOldText );
g_PaintManager->OnPaintSessionComplete( this );
}
//////////////////////////////////////////////////////////////////////////
BOOL CExtLabel::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
return CStatic::OnSetCursor(pWnd, nHitTest, message);
}
|
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 article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.