.h
// ColorStatic.h
///////////////////////////////////////////////////////////////////////////////
#ifndef COLORSTATIC_H
#define COLORSTATIC_H
/////////////////////////////////////////////////////////////////////////////
// CColorStatic window
class CColorStatic : public CStatic
{
// Construction
public:
CColorStatic();
virtual ~CColorStatic();
// Attributes
public:
void SetBackgroundColor(COLORREF rgb, BOOL bRedraw = TRUE);
void SetTextColor(COLORREF rgb, BOOL bRedraw = TRUE);
void SetFont(LPCTSTR lpszFaceName, int nPointSize);
void SetTrans(bool bTranslate);
void ShowText(LPCTSTR sText);
void SetAlign(DWORD dAlign);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CColorStatic)
protected:
// virtual void PreSubclassWindow();
//}}AFX_VIRTUAL
// Implementation
protected:
COLORREF m_rgbText;
COLORREF m_rgbBackground;
BOOL m_bBold;
BOOL m_bTrans;
int m_iFontSize;
CString m_ShowText;
DWORD m_Align; //SS_CENTER SS_LEFT SS_RIGHT
LPCTSTR m_sFontName;
int GetFontHeight(int nPointSize);
// Generated message map functions
protected:
//{{AFX_MSG(CColorStatic)
afx_msg void OnPaint();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif //COLORSTATIC_H
------解决方案--------------------
想知道有没有内存泄露,直接运行一段时间就可以知道,实在不行运行个一周试试
------解决方案--------------------
那就照博客里的做法,改下程序呗