?? staticfilespec.cpp
字號:
/*
* StaticFilespec.cpp
*
*功能:靜態標簽擴展類,用來顯示長路徑名
* 修改人:徐景周
*日期:2001年7月18日
*
*/
#include "stdafx.h"
#include "StaticFilespec.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CStaticFilespec
CStaticFilespec::CStaticFilespec
(DWORD dwFormat /* = DT_LEFT | DT_NOPREFIX | DT_VCENTER */,
BOOL bPathEllipsis /* = FALSE */ )
{
m_bPathEllipsis = bPathEllipsis;
m_dwFormat = dwFormat;
}
CStaticFilespec::~CStaticFilespec()
{
}
BEGIN_MESSAGE_MAP(CStaticFilespec, CWnd)
//{{AFX_MSG_MAP(CStaticFilespec)
ON_MESSAGE( WM_SETTEXT, OnSetText )
ON_WM_ERASEBKGND()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStaticFilespec message handlers
BOOL CStaticFilespec::OnEraseBkgnd(CDC* pDC)
{
RECT rectWnd; // window rectangle
// Erase background
GetClientRect (&rectWnd);
//修改靜態框背景色和對話框相一致
pDC->FillSolidRect (&rectWnd, RGB(160,180,220));//::GetSysColor (COLOR_3DFACE));
return (TRUE);
}
void CStaticFilespec::OnPaint()
{
CPaintDC dc (this); // device context for painting
DWORD dwFormat; // text format
RECT rectWnd; // window rectangle
CString strText; // window text
CWnd* pWndParent = NULL; // parent window
// Set default font
pWndParent = GetParent();
if (pWndParent)
dc.SelectObject (pWndParent->GetFont());
// Draw text
GetWindowText (strText);
GetClientRect (&rectWnd);
dwFormat = m_dwFormat | (m_bPathEllipsis ? DT_PATH_ELLIPSIS : DT_END_ELLIPSIS);
::DrawTextEx (dc.m_hDC,
strText.GetBuffer (0),
strText.GetLength(),
&rectWnd,
dwFormat,
NULL);
strText.ReleaseBuffer();
// Do not call CWnd::OnPaint() for painting messages
}
BOOL CStaticFilespec::OnSetText
(WPARAM wParam,
LPARAM lParam)
{
DefWindowProc (WM_SETTEXT, wParam, lParam);
Invalidate();
return (TRUE);
}
// End StaticFilespec.cpp
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -