当前位置:网站首页>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();
}
边栏推荐
- LED lighting experiment with simulation software proteus
- sql——课程实验考查
- Scons编译IMGUI
- 【WAX链游】发布一个免费开源的Alien Worlds【外星世界】脚本TLM
- Exploring shared representations for personalized federated learning paper notes + code interpretation
- Federated meta learning with fast convergence and effective communication
- Scons compiling imgui
- Interview intelligence questions
- AcWing——4268. 性感素
- openwrt uci c api
猜你喜欢

Detailed principle of 4.3-inch TFTLCD based on warship V3

1. Foundation of MySQL database (1- installation and basic operation)

FCPX插件:简约线条呼出文字标题介绍动画Call Outs With Photo Placeholders for FCPX

Interview intelligence questions

Adaptive personalized federated learning paper interpretation + code analysis
![[image denoising] image denoising based on nonlocal Euclidean median (nlem) with matlab code](/img/1e/386cf601f8f60197adbc853f321472.png)
[image denoising] image denoising based on nonlocal Euclidean median (nlem) with matlab code

Introduction to JDE object management platform and use of from

Golang 快速生成数据库表的 model 和 queryset

5 lines of code identify various verification codes
![‘CMRESHandler‘ object has no attribute ‘_timer‘,socket.gaierror: [Errno 8] nodename nor servname pro](/img/de/6756c1b8d9b792118bebb2d6c1e54c.png)
‘CMRESHandler‘ object has no attribute ‘_timer‘,socket.gaierror: [Errno 8] nodename nor servname pro
随机推荐
The function of C language string Terminator
Putty installation and use
循环链表和双向链表—课上课后练
Test manager defines and implements test metrics
2022起重机械指挥考试题模拟考试平台操作
TypeScript基础知识全集
右击文件转圈卡住、刷新、白屏、闪退、桌面崩溃的通用解决方法
Machine learning from entry to re entry: re understanding of SVM
5、 El expression & JSTL tag library
Continuous local training for better initialization of Federated models
Jackson XML is directly converted to JSON without writing entity classes manually
Golang 快速生成数据库表的 model 和 queryset
Gd32f4 (5): gd32f450 clock is configured as 200m process analysis
RT thread studio learning (IX) TF Card File System
Expansion of D @nogc
There is no solid line connection between many devices in Proteus circuit simulation design diagram. How are they realized?
Summary from November 29 to December 5
Set up a remote Jupiter notebook
FCPX插件:简约线条呼出文字标题介绍动画Call Outs With Photo Placeholders for FCPX
Complete set of typescript Basics