📄 ztransparentstatic.cpp
字号:
// ZTransparentStatic.cpp : implementation file
//
#include "stdafx.h"
#include "ZTransparentStatic.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CZTransparentStatic
CZTransparentStatic::CZTransparentStatic()
{
}
CZTransparentStatic::~CZTransparentStatic()
{
}
BEGIN_MESSAGE_MAP(CZTransparentStatic, CStatic)
//{{AFX_MSG_MAP(CZTransparentStatic)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CZTransparentStatic message handlers
void CZTransparentStatic::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
//**************************************************
// Where to draw text
CRect client_rect;
GetClientRect(client_rect);
// Get the caption
CString szText;
GetWindowText(szText);
// Get the font
CFont *pFont, *pOldFont;
pFont = GetFont();
pOldFont = dc.SelectObject(pFont);
// Map "Static Styles" to "Text Styles"
#define MAP_STYLE(src, dest) if(dwStyle & (src)) dwText |= (dest)
#define NMAP_STYLE(src, dest) if(!(dwStyle & (src))) dwText |= (dest)
DWORD dwStyle = GetStyle(), dwText = 0;
MAP_STYLE( SS_RIGHT, DT_RIGHT );
MAP_STYLE( SS_CENTER, DT_CENTER );
MAP_STYLE( SS_CENTERIMAGE, DT_VCENTER | DT_SINGLELINE );
MAP_STYLE( SS_NOPREFIX, DT_NOPREFIX );
MAP_STYLE( SS_WORDELLIPSIS, DT_WORD_ELLIPSIS );
MAP_STYLE( SS_ENDELLIPSIS, DT_END_ELLIPSIS );
MAP_STYLE( SS_PATHELLIPSIS, DT_PATH_ELLIPSIS );
NMAP_STYLE( SS_LEFTNOWORDWRAP |
SS_CENTERIMAGE |
SS_WORDELLIPSIS |
SS_ENDELLIPSIS |
SS_PATHELLIPSIS, DT_WORDBREAK );
// Set transparent background
dc.SetBkMode(TRANSPARENT);
// Draw the text
dc.DrawText(szText, client_rect, dwText);
// Select old font
dc.SelectObject(pOldFont);
//**************************************************
// Do not call CStatic::OnPaint() for painting messages
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -