当前位置:网站首页>Vs2019 MFC IP address control control inherits cipaddressctrl class redrawing
Vs2019 MFC IP address control control inherits cipaddressctrl class redrawing
2022-06-12 07:25:00 【lzc881012】
CMyIPAddressCtrl.h Inheritance class h The header file
#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 Implementation file
#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();
}
边栏推荐
- sql——课程实验考查
- 5、 El expression & JSTL tag library
- Missing getting in online continuous learning with neuron calibration thesis analysis + code reading
- AcWing——4269校庆
- 新知识:Monkey 改进版之 App Crawler
- How to stop MySQL service under Linux
- Kali and programming: how to quickly build the OWASP website security test range?
- d中的解耦
- Jackson XML is directly converted to JSON without writing entity classes manually
- Talk about vscode configuration settings JSON knows why (with a large number of configurations)
猜你喜欢
![[image detection] SAR image change detection based on depth difference and pcanet with matlab code](/img/c7/05bfa88ef1a4a38394b81755966e46.png)
[image detection] SAR image change detection based on depth difference and pcanet with matlab code

2022年G3锅炉水处理复训题库及答案

Detailed explanation of 14 registers in 8086CPU

Interview intelligence questions

Adaptive personalized federated learning paper interpretation + code analysis

Detailed explanation of TF2 command line debugging tool in ROS (parsing + code example + execution logic)

Hongmeng OS first training

knife4j 初次使用

Detailed explanation of multi coordinate transformation in ROS (example + code)

C language sizeof strlen
随机推荐
Golang quickly generates model and queryset of database tables
GD32F4(5):GD32F450时钟配置为200M过程分析
Pyhon的第六天
Unable to load bean of class marked with @configuration
鸿蒙os-第一次培训
Nine project management issues that PM should understand
RT thread studio learning (VIII) connecting Alibaba cloud IOT with esp8266
Personalized federated learning with exact stochastic gradient descent
Use of gt911 capacitive touch screen
Missing getting in online continuous learning with neuron calibration thesis analysis + code reading
d不能用非常ctfe指针
The first demand in my life - batch uploading of Excel data to the database
Imx6q pwm3 modify duty cycle
Esp8266 firmware upgrade method (esp8266-01s module)
Why must coordinate transformations consist of publishers / subscribers of coordinate transformation information?
Summary of software testing tools in 2021 - unit testing tools
LED lighting experiment with simulation software proteus
Jackson XML is directly converted to JSON without writing entity classes manually
Scons编译IMGUI
Kali与编程:如何快速搭建OWASP网站安全实验靶场?