📄 transbutton1.cpp
字号:
// Transbutton1.cpp : implementation file
//
#include "stdafx.h"
#include "TransButton.h"
#include "Transbutton1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTransbutton
CTransbutton::CTransbutton()
{
m_TextColorDark=m_TextColorLight=RGB(255,255,255);
}
CTransbutton::~CTransbutton()
{
}
BEGIN_MESSAGE_MAP(CTransbutton, CButton)
//{{AFX_MSG_MAP(CTransbutton)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTransbutton message handlers
void CTransbutton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your code to draw the specified item
CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CString sCaption;
CRect rect=lpDrawItemStruct->rcItem;
GetWindowText(sCaption);
// MessageBox(sCaption);
pDC->SetBkMode(TRANSPARENT);
if(m_hHdc!=NULL)
PaintBG(pDC);
pDC->SetTextColor(m_TextColorDark);
pDC->DrawText(sCaption, rect, DT_SINGLELINE|DT_RIGHT|DT_VCENTER);
}
void CTransbutton::PaintBG(CDC *pDC)
{
CClientDC dc(GetParent());
CRect cltRect, wndRect;
GetClientRect(&cltRect);
GetWindowRect(&wndRect);
GetParent()->ScreenToClient(&wndRect);
::BitBlt(pDC->m_hDC, 0, 0, cltRect.Width(), cltRect.Height(), m_hHdc, wndRect.left, wndRect.top, SRCCOPY);
}
void CTransbutton::SetTransparent()
{
HBITMAP hBmp = ::LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP_BACK));
m_hHdc = ::CreateCompatibleDC(NULL);
SelectObject(m_hHdc, hBmp);
}
COLORREF CTransbutton::SetTextColor(COLORREF DarkColor, COLORREF LightColor)
{
m_TextColorDark=DarkColor;
m_TextColorLight=LightColor;
return (DarkColor);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -