12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- // 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); // -Ô;
- GetParent()->PostMessage(WM_COMMAND,wParam,lParam); // -¸Ä.2014-02-19;
- TRACE("-------------------------0.0----------------------------");
- 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;
- }
|