zoukankan      html  css  js  c++  java
  • CEdit自绘点

    就几个点:

    背景色,字体颜色,字体大小,

    注意的是字体大小最好用WM_SETFONT来处理,我也是在挂钩时打印消息发现了它,直接看MSDN就知道怎么发送了。

    代码:

    HBRUSH CSkinEdit::CtlColor(CDC* pDC, UINT nCtlColor)
    {
         m_Brush.DeleteObject();
    	 m_Brush.CreateSolidBrush(m_BkClr);
    	 pDC->SetBkColor(m_BkClr);
    	 pDC->SetTextColor(m_TextClr);
    
    	return (HBRUSH)m_Brush;
    }

    必须return 一个HBRUSH对象,表示你设置了,不然设置无效

    void CSkinEdit::SetTextFont(LONG FontHeight, CString szFontName, int FontType)
    {
    	BOOL bRedraw = FALSE;
    	if ((FontHeight != m_FontHeight)&&FontHeight)
    	{
    		m_FontHeight = FontHeight;
    		bRedraw = TRUE;
    	}
    	if (!szFontName.IsEmpty()&&(m_szFontName != szFontName))
    	{
    		m_szFontName = szFontName;
    		bRedraw = TRUE;
    	}
    	if(FontType != m_FontType)
    	{
    		m_FontType = FontType;
    		bRedraw = TRUE;
    	}
    
    	if (bRedraw)
    	{
    		LOGFONT lf;
    		m_Font.GetLogFont(&lf);
    
    		lf.lfHeight = m_FontHeight;   
    		lf.lfWeight = m_FontType;  
    
    		memcpy(lf.lfFaceName, m_szFontName.GetBuffer(LF_FACESIZE), LF_FACESIZE);
    		m_szFontName.ReleaseBuffer(LF_FACESIZE);
    
    		m_Font.DeleteObject();
    		m_Font.CreateFontIndirect(&lf);
    
    		SendMessage(WM_SETFONT, (WPARAM)((HFONT)m_Font), MAKELPARAM(TRUE, 0));
    	}
    }

    
    
    szFontName可以是TEXT("Arial"),TEXT("宋体")
    
  • 相关阅读:
    PredictionIO+Universal Recommender快速开发部署推荐引擎的问题总结(1)
    SpringJDBC的JdbcTemplate在MySQL5.7下不支持子查询的问题
    POP3接收邮件
    发送邮件
    电子邮件介绍
    线程优先级队列
    线程同步
    threading模块
    _thread模块
    使用线程
  • 原文地址:https://www.cnblogs.com/hgy413/p/3693592.html
Copyright © 2011-2022 走看看