Click here to Skip to main content
15,886,026 members
Articles / Desktop Programming / MFC

AIM-Style Scrolling Banner Control

Rate me:
Please Sign up or sign in to vote.
4.14/5 (4 votes)
30 Jun 20013 min read 108.4K   2.5K   29  
A scrolling banner control containing strings with individual styles and colors.
#ifndef MULTICOLORSTATIC_H_
#define MULTICOLORSTATIC_H_

#include "ColorString.h"

class CMultiColorStatic : public CStatic
{
public:
   CMultiColorStatic();
   virtual ~CMultiColorStatic();

public:
  	virtual BOOL SetString(const int& nIndex, const CColorString& strData);
	virtual CColorString GetString(const int& nIndex = 0) const;
	virtual BOOL AddString(const CColorString& strData);
   virtual BOOL AddString(LPCTSTR lpszText, const DWORD& dwStyle = 0x00000000,
                          const COLORREF& crBackColor = 0xFFFFFFFF);
   virtual BOOL RemoveString(const int& nIndex);
   virtual void RemoveAllStrings(void);
   DWORD GetNumStrings(void) const;

	void SetBackColor(const COLORREF& crBackColor = 0xFFFFFFFF);
	COLORREF GetBackColor(void) const;

   void SetAutoSize(const bool& fAutoSize);
   bool GetAutoSize(void) const;

   void SetWindowText(LPCTSTR lpszValue);
   int GetWindowText(LPTSTR lpszStringBuf, int nMaxCount);
   void GetWindowText(CString& strData);

protected:
   void DetermineFont(const CColorString* const pstrData);
   void CalculateWindowText(void);

protected:
   CPtrArray   m_astrData;       // array of CColorString's to paint
   COLORREF    m_crBackColor;    // background color -- used for ALL strings
   CBrush      m_brBackGround;   // background brush -- used for ALL strings
   CFont       m_ftText;         // used for all strings for now
   CRect       m_rcBounds;       // client area -- update on size
   CString     m_strWindowText;  // text for the entire window
   bool        m_fAutoSize;      // should the text height adjust itself to client height?

protected:
   virtual void PreSubclassWindow(void);

   afx_msg void OnPaint();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnDestroy();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);

   DECLARE_MESSAGE_MAP()
};

#endif

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions