Click here to Skip to main content
15,896,606 members
Articles / Desktop Programming / MFC

CEdit & CStatic Transparency Control

Rate me:
Please Sign up or sign in to vote.
4.58/5 (24 votes)
6 Oct 2001CPOL 202.4K   9K   67  
This acticle explain how to apply transparency on CEdit and CStatic Controls
/*===========================================================================
====                                                                     ====
====    File name           :  StaticTrans.h                             ====
====    Creation date       :  7/10/2001                                 ====
====    Author(s)           :  Dany Cantin                               ====
====                                                                     ====
===========================================================================*/

#ifndef STATICTRANS_H
#define STATICTRANS_H

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


/////////////////////////////////////////////////////////////////////////////
// CStaticTrans window

#define TRANS_BACK -1

class CStaticTrans : public CStatic
{
    // Construction
public:
    CStaticTrans();
    
private:
    COLORREF m_TextColor;
    COLORREF m_BackColor;
    CBrush   m_Brush;
    
// Operations
public:
    void SetTextColor(COLORREF col) { m_TextColor = col;
                                      UpdateCtrl();      }
    void SetBackColor(COLORREF col) { m_BackColor = col;
                                      UpdateCtrl();      }

private:
    void UpdateCtrl();
    
// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CStaticTrans)
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CStaticTrans();

	// Generated message map functions
protected:
	//{{AFX_MSG(CStaticTrans)
	afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};


#endif // STATICTRANS_H

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
CEO
Canada Canada

Comments and Discussions