⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 skinstatic.cpp

📁 If you are not using these features and wish to reduce the size
💻 CPP
字号:
// SkinStatic.cpp : implementation file
//

#include "stdafx.h"
#include "dialog.h"
#include "SkinStatic.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSkinStatic

CSkinStatic::CSkinStatic()
{
	m_nX=0;
	m_nY=0;
	m_strText="";
}

CSkinStatic::~CSkinStatic()
{
}


BEGIN_MESSAGE_MAP(CSkinStatic, CStatic)
	//{{AFX_MSG_MAP(CSkinStatic)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSkinStatic message handlers
void CSkinStatic::LoadBitmap(LPCTSTR szImagePath)
{
	m_bmpStatic.LoadImage(szImagePath); 
}



void CSkinStatic::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	CRect rcClient;
	GetClientRect(&rcClient);
	CEnBitmap bmp;
	if (m_bmpStatic.m_hObject !=0)
		m_bmpStatic.ExtendDraw(&dc,rcClient,m_nX,m_nY); 

	CRect rc=rcClient;
	rc.left =m_nTextStart;
	DrawText(&dc,rc,m_strText);
}

BOOL CSkinStatic::OnCommand(WPARAM wParam, LPARAM lParam) 
{
	GetParent()->SendMessage(WM_COMMAND,wParam,lParam); 	
	return CStatic::OnCommand(wParam, lParam);
}

void CSkinStatic::SetText(CString strText, int nStart,COLORREF cr)
{
	m_strText=strText;
	m_nTextStart=nStart;
	m_crText=cr;
}


BOOL CSkinStatic::DrawText(CDC *pDC,CRect rc ,CString strText)
{
	CRect r;
	CString str;
	CRect rcButton;
	if (strText.GetLength() )
	{
		CFont *ofont;
		ofont = pDC->SelectObject( GetParent()->GetFont() );

		pDC->SetTextColor(m_crText);
		pDC->SetBkMode(TRANSPARENT);
		pDC->DrawText( strText, rc, DT_SINGLELINE | DT_VCENTER );
		pDC->SelectObject(ofont);
	}

	return TRUE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -