📄 label.cpp
字号:
if (bActivate)
{
m_bState = FALSE;
m_bTimer = TRUE;
SetTimer(1,500,NULL);
m_Type = Background;
}
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetLink
//
// Description: Indicates the string is a link
//
// INPUTS: True or false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
// NT ALMOND 26/08/99 1.2 Added flexbility of
// Sending Click meessage to parent
//
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetLink(BOOL bLink,BOOL bNotifyParent)
{
if (bLink)
m_Link = HyperLink;
else
m_Link = LinkNone;
m_bNotifyParent = bNotifyParent;
if (m_Link != LinkNone)
ModifyStyle(0,SS_NOTIFY);
else
ModifyStyle(SS_NOTIFY,0);
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetLinkCursor
//
// Description: Sets the internet browers link
//
// INPUTS: Handle of cursor
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetLinkCursor(HCURSOR hCursor)
{
m_hCursor = hCursor;
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetTransparent
//
// Description: Sets the Label window to be transpaent
//
// INPUTS: True or false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 22/10/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetTransparent(BOOL bSet)
{
m_bTransparent = bSet;
ModifyStyleEx(0,WS_EX_TRANSPARENT); // Fix for transparency
UpdateSurface();
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetFont3D
//
// Description: Sets the 3D attribute of the font.
//
// INPUTS: True or false, Raised or Sunken
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 22/10/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetFont3D(BOOL bSet,Type3D type)
{
m_bFont3d = bSet;
m_3dType = type;
UpdateSurface();
return *this;
}
void CLabel::OnSysColorChange()
{
if (m_hwndBrush)
::DeleteObject(m_hwndBrush);
m_hwndBrush = ::CreateSolidBrush(GetSysColor(COLOR_3DFACE));
UpdateSurface();
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetRotationAngle
//
// Description: Sets the rotation angle for the current font.
//
// INPUTS: Angle in Degress
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 22/10/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetRotationAngle(UINT nAngle,BOOL bRotation)
{
// Arrrrh...
// Your looking in here why the font is rotating, aren't you?
// Well try setting the font name to 'Arial' or 'Times New Roman'
// Make the Angle 180 and set bRotation to true.
//
// Font rotation _ONLY_ works with TrueType fonts...
//
//
m_lf.lfEscapement = m_lf.lfOrientation = (nAngle * 10);
m_bRotation = bRotation;
ReconstructFont();
UpdateSurface();
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetText3DHiliteColor
//
// Description: Sets the 3D font hilite color
//
// INPUTS: Color
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 17/07/00 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetText3DHiliteColor(COLORREF cr3DHiliteColor)
{
m_cr3DHiliteColor = cr3DHiliteColor;
UpdateSurface();
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::PreSubclassWindow
//
// Description: Assigns default dialog font
//
// INPUTS:
//
// RETURNS:
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 15092000 1.5 Origin
// NT ALMOND 02072002 1.6 Fix crash when GetFont returns NULL
//////////////////////////////////////////////////////////////////////////
void CLabel::PreSubclassWindow()
{
CStatic::PreSubclassWindow();
CFont* cf = GetFont();
if(cf !=NULL)
{
cf->GetObject(sizeof(m_lf),&m_lf);
}
else
{
GetObject(GetStockObject(SYSTEM_FONT),sizeof(m_lf),&m_lf);
}
ReconstructFont();
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::PreCreateWindow
//
// Description:
//
// INPUTS:
//
// RETURNS:
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 15092000 1.5 Origin
//////////////////////////////////////////////////////////////////////////
BOOL CLabel::PreCreateWindow(CREATESTRUCT& cs)
{
return CStatic::PreCreateWindow(cs);
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::DrawGradientFill
//
// Description: Internal help function to gradient fill background
//
// INPUTS:
//
// RETURNS:
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 15092000 1.5 Origin
//////////////////////////////////////////////////////////////////////////
void CLabel::DrawGradientFill(CDC* pDC, CRect* pRect, COLORREF crStart, COLORREF crEnd, int nSegments)
{
// Get the starting RGB values and calculate the incremental
// changes to be applied.
COLORREF cr;
int nR = GetRValue(crStart);
int nG = GetGValue(crStart);
int nB = GetBValue(crStart);
int neB = GetBValue(crEnd);
int neG = GetGValue(crEnd);
int neR = GetRValue(crEnd);
if(nSegments > pRect->Width())
nSegments = pRect->Width();
int nDiffR = (neR - nR);
int nDiffG = (neG - nG);
int nDiffB = (neB - nB);
int ndR = 256 * (nDiffR) / (max(nSegments,1));
int ndG = 256 * (nDiffG) / (max(nSegments,1));
int ndB = 256 * (nDiffB) / (max(nSegments,1));
nR *= 256;
nG *= 256;
nB *= 256;
neR *= 256;
neG *= 256;
neB *= 256;
int nCX = pRect->Width() / max(nSegments,1), nLeft = pRect->left, nRight;
pDC->SelectStockObject(NULL_PEN);
for (int i = 0; i < nSegments; i++, nR += ndR, nG += ndG, nB += ndB)
{
// Use special code for the last segment to avoid any problems
// with integer division.
if (i == (nSegments - 1))
nRight = pRect->right;
else
nRight = nLeft + nCX;
cr = RGB(nR / 256, nG / 256, nB / 256);
{
CBrush br(cr);
CBrush* pbrOld = pDC->SelectObject(&br);
pDC->Rectangle(nLeft, pRect->top, nRight + 1, pRect->bottom);
pDC->SelectObject(pbrOld);
}
// Reset the left side of the drawing rectangle.
nLeft = nRight;
}
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetFont
//
// Description: Sets font with LOGFONT structure
//
// INPUTS:
//
// RETURNS:
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 02072002 1.6 Origin
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetFont(LOGFONT lf)
{
CopyMemory(&m_lf, &lf, sizeof(m_lf));
ReconstructFont();
UpdateSurface();
return *this;
}
BOOL CLabel::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
return TRUE;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetMailLink
//
// Description: Sets the label so it becomes Mail enabled
//
// INPUTS:
//
// RETURNS:
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 02072002 1.6 Origin
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetMailLink(BOOL bEnable, BOOL bNotifyParent)
{
if (bEnable)
m_Link = MailLink;
else
m_Link = LinkNone;
m_bNotifyParent = bNotifyParent;
if (m_Link != LinkNone)
ModifyStyle(0,SS_NOTIFY);
else
ModifyStyle(SS_NOTIFY,0);
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CLabel::SetHyperLink
//
// Description: Sets the label so it becomes hyperlink enabled
//
// INPUTS:
//
// RETURNS:
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 02072002 1.6 Origin
//////////////////////////////////////////////////////////////////////////
CLabel& CLabel::SetHyperLink(const CString& sLink)
{
m_sLink = sLink;
return *this;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -