CCheckBox控件默认背景和字体颜色
来源:互联网 发布:增量内部收益率的算法 编辑:程序博客网 时间:2024/05/19 00:42
- #pragma once
- /*
- Title:改变MFC CCheckBox控件默认字体的颜色
- Test Environment: VS2013Update3
- Author: kagula
#pragma once/*Title:改变MFC CCheckBox控件默认字体的颜色Test Environment: VS2013Update3Author: kagula
- LastUpdateDate:2014-10-20
- */
- class CCheckBox : public CButton
- {
- DECLARE_DYNAMIC(CCheckBox)
- public:
- CCheckBox();
- virtual ~CCheckBox();
- protected:
- DECLARE_MESSAGE_MAP()
- public:
- COLORREF m_clrFore;
- COLORREF m_clrBK;
- int m_fontSize;
- afx_msg void OnPaint();
- };
LastUpdateDate:2014-10-20*/class CCheckBox : public CButton{ DECLARE_DYNAMIC(CCheckBox)public: CCheckBox(); virtual ~CCheckBox();protected: DECLARE_MESSAGE_MAP()public: COLORREF m_clrFore; COLORREF m_clrBK; int m_fontSize; afx_msg void OnPaint();};
- // CheckBox.cpp : implementation file
- //
- #include “stdafx.h”
- #include “cat8637_brand.h”
- #include “CheckBox.h”
- // CCheckBox
- IMPLEMENT_DYNAMIC(CCheckBox, CButton)
- CCheckBox::CCheckBox()
- {
- m_clrFore = RGB(127, 127, 127);
- m_clrBK = RGB(255, 255, 255);
- m_fontSize = 100;
- }
- CCheckBox::~CCheckBox()
- {
- }
- BEGIN_MESSAGE_MAP(CCheckBox, CButton)
- ON_WM_PAINT()
- END_MESSAGE_MAP()
- // CCheckBox message handlers
- void CCheckBox::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
- // TODO: Add your message handler code here
- // Do not call CButton::OnPaint() for painting messages
- //Draw box
- RECT rect;
- GetClientRect(&rect);
- rect.right = rect.left + 20;
- CMFCVisualManager::GetInstance()->DrawCheckBox(
- &dc
- , rect
- , false // highlighted
- , GetCheck() == TRUE ? 1 : 0 // state
- , true // enabled
- , false // pressed
- );
- //draw text
- GetClientRect(&rect);
- rect.left += 20;
- CString text;
- GetWindowText(text);
- if (text.GetLength() > 0)
- {
- COLORREF oldClrFore = dc.SetTextColor(m_clrFore);
- COLORREF oldClrBK = dc.SetBkColor(m_clrBK);
- CFont *fontOld = nullptr;
- if (m_fontSize > 0)
- {
- CFont font;
- font.CreatePointFont(m_fontSize, L”宋体”, &dc);
- fontOld = dc.SelectObject(&font);
- }
- CSize size = dc.GetTextExtent(text);
- rect.top = ((rect.bottom - rect.top) - size.cy) / 2 + rect.top;
- dc.DrawText(text.GetBuffer(), &rect, DT_LEFT);
- if (m_fontSize > 0 && fontOld != nullptr)
- {
- dc.SelectObject(fontOld);
- }
- dc.SetBkColor(oldClrBK);
- dc.SetTextColor(oldClrFore);
- }
- }
// CheckBox.cpp : implementation file//
0 0
- CCheckBox控件默认背景和字体颜色
- 改变MFC CCheckBox控件默认字体的颜色
- 设置static控件背景颜色、控件字体的背景颜色和控件字体的颜色
- 改变控件的背景颜色和字体颜色
- MyEclipse字体背景颜色和jsp默认字符格式设置
- 关于设置对话框的背景颜色,和设置控件的字体颜色或背景颜色
- 关于设置对话框的背景颜色,和设置控件的字体颜色或背景颜色
- 关于设置对话框的背景颜色,和设置控件的字体颜色或背景颜色VC++
- 设置Dialog的背景颜色及其中控件的背景颜色和字体颜色
- WM_CTLCOLOR设置控件设置背景和字体颜色
- MFC更改控件的背景和字体颜色
- UITextField字体颜色和默认字体颜色
- css字体和背景颜色
- VC设置控件的字体颜色和背景颜色和字体大小和样式
- 对话框控件背景、字体颜色设置
- 对话框控件背景、字体颜色设置
- MFC更改控件字体颜色背景等
- 设置样式:字体颜色和背景颜色
- iphone获取当前运行进程列表遇到一个问题
- JAVA 后端知识体系
- 索引的选择性
- 深度神经网络结构以及Pre-Training的理解
- HTML响应式
- CCheckBox控件默认背景和字体颜色
- FaceBook第三方登录的接入封装
- Android5.x Notification应用解析
- 网站收藏
- C#后台拼接参数,前台显示数据
- 关于android多应用互相调起的问题
- 参加第六届全球游戏大会( GMGC 北京 2017 )的十大理由!
- Xcode中修改变量名、类名及字符串的替换操作
- div层调整zindex属性无效原因分析及解决方法