📄 label.cpp
字号:
//
// INPUTS: Windows API
//
// RETURNS: Windows API
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
// NT ALMOND 02072002 1.6 Added Mail support
//////////////////////////////////////////////////////////////////////////
void CXLabel::OnLButtonDown(UINT nFlags, CPoint point)
{
if (!m_bNotifyParent) // Fix
{
CString strLink;
GetWindowText(strLink);
if (m_Link == HyperLink)
{
ShellExecute(NULL,_T("open"),m_sLink.IsEmpty() ? strLink : m_sLink,NULL,NULL,SW_SHOWNORMAL);
}
if (m_Link == MailLink)
{
strLink = "mailto:" + strLink;
ShellExecute( NULL, NULL, strLink, NULL, NULL, SW_SHOWNORMAL );
}
}
else
{
// To use notification in parent window
// Respond to a OnNotify in parent and disassemble the message
//
NMHDR nm;
nm.hwndFrom = GetSafeHwnd();
nm.idFrom = GetDlgCtrlID();
nm.code = NM_LINKCLICK;
GetParent()->SendMessage(WM_NOTIFY,nm.idFrom,(LPARAM) &nm);
}
CStatic::OnLButtonDown(nFlags, point);
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// THE FUNCTIONS START HERE :----
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// Function: CXLabel::SetText
//
// Description: Short cut to set window text - caption - label
//
// INPUTS: Text to use
//
// RETURNS: Reference to this
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26081998 1.0 Origin
// NT ALMOND 02072002 1.6 Crash Fix
//////////////////////////////////////////////////////////////////////////
CXLabel& CXLabel::SetText(const CString& strText)
{
if(IsWindow(this->GetSafeHwnd()))
{
SetWindowText(strText);
UpdateSurface();
}
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CXLabel::SetTextColor
//
// Description: Sets the text color
//
// INPUTS: True or false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 22/10/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CXLabel& CXLabel::SetTextColor(COLORREF crText)
{
m_crText = crText;
UpdateSurface();
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CXLabel::SetFontBold
//
// Description: Sets the font ot bold
//
// INPUTS: True or false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 22/10/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CXLabel& CXLabel::SetFontBold(BOOL bBold)
{
m_lf.lfWeight = bBold ? FW_BOLD : FW_NORMAL;
ReconstructFont();
UpdateSurface();
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CXLabel::SetFontUnderline
//
// Description: Sets font underline attribue
//
// INPUTS: True of false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CXLabel& CXLabel::SetFontUnderline(BOOL bSet)
{
m_lf.lfUnderline = bSet;
ReconstructFont();
UpdateSurface();
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CXLabel::SetFontItalic
//
// Description: Sets font italic attribute
//
// INPUTS: True of false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CXLabel& CXLabel::SetFontItalic(BOOL bSet)
{
m_lf.lfItalic = bSet;
ReconstructFont();
UpdateSurface();
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CXLabel::SetSunken
//
// Description: Sets sunken effect on border
//
// INPUTS: True of false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CXLabel& CXLabel::SetSunken(BOOL bSet)
{
if (!bSet)
ModifyStyleEx(WS_EX_STATICEDGE,0,SWP_DRAWFRAME);
else
ModifyStyleEx(0,WS_EX_STATICEDGE,SWP_DRAWFRAME);
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CXLabel::SetBorder
//
// Description: Toggles the border on/off
//
// INPUTS: True of false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CXLabel& CXLabel::SetBorder(BOOL bSet)
{
if (!bSet)
ModifyStyle(WS_BORDER,0,SWP_DRAWFRAME);
else
ModifyStyle(0,WS_BORDER,SWP_DRAWFRAME);
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CXLabel::SetFontSize
//
// Description: Sets the font size
//
// INPUTS: True of false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CXLabel& CXLabel::SetFontSize(int nSize)
{
CFont cf;
LOGFONT lf;
cf.CreatePointFont(nSize * 10, m_lf.lfFaceName);
cf.GetLogFont(&lf);
m_lf.lfHeight = lf.lfHeight;
m_lf.lfWidth = lf.lfWidth;
// nSize*=-1;
// m_lf.lfHeight = nSize;
ReconstructFont();
UpdateSurface();
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CXLabel::SetBkColor
//
// Description: Sets background color
//
// INPUTS: Colorref of background color
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CXLabel& CXLabel::SetBkColor(COLORREF crBkgnd, COLORREF crBkgndHigh , BackFillMode mode)
{
m_crLoColor = crBkgnd;
m_crHiColor = crBkgndHigh;
m_fillmode = mode;
if (m_hBackBrush)
::DeleteObject(m_hBackBrush);
if (m_fillmode == Normal)
m_hBackBrush = ::CreateSolidBrush(crBkgnd);
UpdateSurface();
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CXLabel::SetFontName
//
// Description: Sets the fonts face name
//
// INPUTS: String containing font name
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
// NT ALMOND 15092000 1.5 Support internation windows
//////////////////////////////////////////////////////////////////////////
CXLabel& CXLabel::SetFontName(const CString& strFont, BYTE byCharSet /* Default = ANSI_CHARSET */)
{
m_lf.lfCharSet = byCharSet;
_tcscpy(m_lf.lfFaceName,strFont);
ReconstructFont();
UpdateSurface();
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CXLabel::FlashText
//
// Description: As the function states
//
// INPUTS: True or false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CXLabel& CXLabel::FlashText(BOOL bActivate)
{
if (m_bTimer)
KillTimer(1);
if (bActivate)
{
m_bState = FALSE;
m_bTimer = TRUE;
SetTimer(1,500,NULL);
m_Type = Text;
}
else
m_Type = None; // Fix
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CXLabel::FlashBackground
//
// Description: As the function states
//
// INPUTS: True or false
//
// RETURNS: Reference to 'this' object
//
// NOTES:
//
// MODIFICATIONS:
//
// Name Date Version Comments
// NT ALMOND 26/08/98 1.0 Origin
//
//////////////////////////////////////////////////////////////////////////
CXLabel& CXLabel::FlashBackground(BOOL bActivate)
{
if (m_bTimer)
KillTimer(1);
if (bActivate)
{
m_bState = FALSE;
m_bTimer = TRUE;
SetTimer(1,500,NULL);
m_Type = Background;
}
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Function: CXLabel::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
//
//////////////////////////////////////////////////////////////////////////
CXLabel& CXLabel::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: CXLabel::SetLinkCursor
//
// Description: Sets the internet browers link
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -