当前位置:网站首页>VS2019 MFC IP Address Control 控件继承CIPAddressCtrl类重绘
VS2019 MFC IP Address Control 控件继承CIPAddressCtrl类重绘
2022-06-12 07:25:00 【lzc881012】
CMyIPAddressCtrl.h继承类h头文件
#include"MacroDefinition.h"
#pragma once
class CMyIPAddressCtrl:public CIPAddressCtrl
{
DECLARE_DYNAMIC(CMyIPAddressCtrl)
public:
CMyIPAddressCtrl();
virtual ~CMyIPAddressCtrl();
CBrush m_NrBkBrush;
CBrush m_SlBkBrush;
BOOL m_SelectedFlag;
CFont* p_Font;
COLORREF m_SlTextCtrl;
COLORREF m_UnSlTextCtrl;
COLORREF m_SlTextBkCtrl;
COLORREF m_UnSlTextBkCtrl;
CFont m_Text;
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
void SetTextNrBackColor(COLORREF eTextNrBkCtrl);
void SetTextSlBackColor(COLORREF eTextSlBkCtrl);
void SetTextNrColor(COLORREF eNrTextCtrl);
void SetTextSlColor(COLORREF eSlTextColor);
void SetIPAddressCtrlBackColorNormal(COLORREF iPAddressBkCtrlNormal);
void SetIPAddressCtrlBackColorSelect(COLORREF iPAddressBkCtrlSelect);
bool SetTextFont(LONG nHeight, bool bBold, bool bItalic, bool bunderline ,const CString& sFaceName);
bool SetTextFont(CFont *m_cfont);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnMouseLeave();
};
CMyIPAddressCtrl.CPP实现文件
#include "pch.h"
#include "CMyIPAddressCtrl.h"
IMPLEMENT_DYNAMIC(CMyIPAddressCtrl, CIPAddressCtrl);
CMyIPAddressCtrl::CMyIPAddressCtrl()
{
m_SelectedFlag = FALSE;
SetIPAddressCtrlBackColorNormal(RGB(150,130,50));
SetIPAddressCtrlBackColorSelect(RGB(0,0,255));
SetTextNrBackColor(RGB(150, 130, 50));
SetTextSlBackColor(RGB(0, 0, 255));
SetTextNrColor(RGB(0, 0, 255));
SetTextSlColor(RGB(255, 0, 0));
p_Font = NULL;
p_Font = new CFont;
}
CMyIPAddressCtrl::~CMyIPAddressCtrl()
{
p_Font->Detach();
p_Font->DeleteObject();
p_Font = NULL;
m_NrBkBrush.DeleteObject();
m_SlBkBrush.DeleteObject();
}
BEGIN_MESSAGE_MAP(CMyIPAddressCtrl, CIPAddressCtrl)
ON_WM_CTLCOLOR()
ON_WM_MOUSEMOVE()
ON_WM_MOUSELEAVE()
END_MESSAGE_MAP()
HBRUSH CMyIPAddressCtrl::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
pDC->SetBkMode(TRANSPARENT);
if (m_SelectedFlag==FALSE)
{ pDC->SetTextColor(m_UnSlTextCtrl);
pDC->SetBkColor(m_UnSlTextBkCtrl);
return(HBRUSH)m_NrBkBrush;
}
else
{
pDC->SetTextColor(m_SlTextCtrl);
pDC->SetBkColor(m_SlTextBkCtrl);
return(HBRUSH)m_SlBkBrush;
}
}
void CMyIPAddressCtrl::SetTextNrBackColor(COLORREF eTextNrBkCtrl)
{
m_UnSlTextBkCtrl = eTextNrBkCtrl;
}
void CMyIPAddressCtrl::SetTextSlBackColor(COLORREF eTextSlBkCtrl)
{
m_SlTextBkCtrl = eTextSlBkCtrl;
}
void CMyIPAddressCtrl::SetTextNrColor(COLORREF eNrTextCtrl)
{
m_UnSlTextCtrl = eNrTextCtrl;
}
void CMyIPAddressCtrl::SetTextSlColor(COLORREF eSlTextColor)
{
m_SlTextCtrl = eSlTextColor;
}
void CMyIPAddressCtrl::SetIPAddressCtrlBackColorNormal(COLORREF iPAddressBkCtrlNormal)
{
m_NrBkBrush, Detach();
m_NrBkBrush.CreateSolidBrush(iPAddressBkCtrlNormal);
}
void CMyIPAddressCtrl::SetIPAddressCtrlBackColorSelect(COLORREF iPAddressBkCtrlSelect)
{
m_SlBkBrush.Detach();
m_SlBkBrush.CreateSolidBrush(iPAddressBkCtrlSelect);
}
bool CMyIPAddressCtrl::SetTextFont(LONG nHeight, bool bBold, bool bItalic,bool bunderline, const CString& sFaceName)
{
p_Font->CreateFontW(nHeight, 0, 0, 0, bBold, bItalic, bunderline, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, sFaceName);
return this->SetTextFont(p_Font);
}
bool CMyIPAddressCtrl::SetTextFont(CFont *m_cfont)
{
this->SetFont(m_cfont, TRUE);
return true;
}
void CMyIPAddressCtrl::OnMouseMove(UINT nFlags, CPoint point)
{
TRACKMOUSEEVENT csTME;
if (!m_SelectedFlag)
{
m_SelectedFlag = TRUE;
Invalidate();
csTME.cbSize = sizeof(csTME);
csTME.dwFlags = TME_LEAVE;
csTME.hwndTrack = m_hWnd;
csTME.dwHoverTime = 1;
::_TrackMouseEvent(&csTME);
}
CIPAddressCtrl::OnMouseMove(nFlags, point);
}
void CMyIPAddressCtrl::OnMouseLeave()
{
if (m_SelectedFlag)
{
m_SelectedFlag = FALSE;
Invalidate();
}
CIPAddressCtrl::OnMouseLeave();
}
边栏推荐
- Dynamic coordinate transformation in ROS (dynamic parameter adjustment + dynamic coordinate transformation)
- 新知识:Monkey 改进版之 App Crawler
- New knowledge: monkey improved app crawler
- Summary of software testing tools in 2021 - unit testing tools
- Unable to load bean of class marked with @configuration
- Pyhon的第五天
- Day 6 of pyhon
- LVDS drive adapter
- There is no solid line connection between many devices in Proteus circuit simulation design diagram. How are they realized?
- sql——课程实验考查
猜你喜欢

Error mcrypt in php7 version of official encryption and decryption library of enterprise wechat_ module_ Open has no method defined and is discarded by PHP. The solution is to use OpenSSL

knife4j 初次使用

8086/8088 instruction execution pipeline disconnection reason

ROS dynamic parameter configuration: use of dynparam command line tool (example + code)

Set up a remote Jupiter notebook

Personalized federated learning with Moreau envelopes

Interview intelligence questions

Explain in detail the use of dynamic parameter adjustment and topic communication in ROS (principle + code + example)

Design an open source continuous deployment pipeline based on requirements

Learning to continuously learn paper notes + code interpretation
随机推荐
Explain ADC in stm32
Lambda function perfect use guide
Paddepaddl 28 supports the implementation of GHM loss, a gradient balancing mechanism for arbitrary dimensional data (supports ignore\u index, class\u weight, back propagation training, and multi clas
Detailed principle of 4.3-inch TFTLCD based on warship V3
Embedded gd32 code read protection
Scons compiling imgui
SQL -- course experiment examination
Interview intelligence questions
Set up a remote Jupiter notebook
Beginners can't tell the difference between framework and class library
Putty installation and use
Golang 快速生成数据库表的 model 和 queryset
12.13-12.19 summary
Decryption game of private protocol: from secret text to plaintext
Gradient epic memory for continuous learning
2022电工(初级)考试题库及模拟考试
Formatting the generalization forgetting trade off in continuous learning
速度自关联函数—LAMMPS V.S MATALB
Vscode outline preview cannot find file symbol
Adaptive personalized federated learning paper interpretation + code analysis