⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 colorstatic.cpp

📁 一个modbus的编程库
💻 CPP
字号:
// ColorStatic.cpp : implementation file
//

#include "stdafx.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CColorStatic

CColorStatic::CColorStatic()
{
   m_color = RGB(255,0,0); //initialize to red by default, so that folks 
   // know that we are here.
}

CColorStatic::~CColorStatic()
{
}


BEGIN_MESSAGE_MAP(CColorStatic, CStatic)
	//{{AFX_MSG_MAP(CColorStatic)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
   ON_WM_CTLCOLOR_REFLECT()
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CColorStatic message handlers

//////////////////// Handle reflected WM_CTLCOLOR to set custom control color.
// For a text control, use visited/unvisited colors and underline font.
// For non-text controls, do nothing. 
//
HBRUSH CColorStatic::CtlColor(CDC* pDC, UINT nCtlColor)
{
   ASSERT(nCtlColor == CTLCOLOR_STATIC);
   DWORD dwStyle = GetStyle();
/*
   if (!(dwStyle & SS_NOTIFY)) {
         // Turn on notify flag to get mouse messages and STN_CLICKED.
         // Otherwise, I'll never get any mouse clicks!
         ::SetWindowLong(m_hWnd, GWL_STYLE, dwStyle | SS_NOTIFY);
     }
  */   
   HBRUSH hbr = NULL;
   if ((dwStyle & 0xFF) <= SS_RIGHT) 
   {
      // this is a text control: set up font and colors
      if (!(HFONT)m_font) 
      {
         // first time init: create font
         LOGFONT lf;
         GetFont()->GetObject(sizeof(lf), &lf);
         m_font.CreateFontIndirect(&lf);
      }
 
      // use ...
      pDC->SelectObject(&m_font);
      pDC->SetTextColor(m_color);
      pDC->SetBkMode(TRANSPARENT);
 
      // return hollow brush to preserve parent background color
      hbr = (HBRUSH)::GetStockObject(HOLLOW_BRUSH);
   }
   return hbr;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -