Show scrolling text in a status bar pane


Application Security Testing: An Integral Part of DevOps

This simple trick uses string pointer manipulation to give scrolling effect in a status bar. The code is not robust. It only demonstrates how it could be done.

1. Derive your own CMyStatusBar from CstatusBar.

2. In MainFrm.h, change the type of status bar as:

	CMyStatusBar m_wndStatusBar;

3. Also change the indicator array in MainFrm.cpp as:
	static UINT indicators[] =
		IDS_SCROLL_PANE,				//scrolling text

4. Add IDS_SCROLL_PANE in the string table with few blanks. The size of pane will depend on this blank string. There are other painfull ways of sizing a pane too.

5. Add following member to CMyStatusBar: Cstring m_strScrollText;

6. Add OnTimer() to the CMyStatusBar:

void CMyStatusBar::OnTimer(UINT nIDEvent) 
	// TODO: Add your message handler code here and/or call default
	if (m_strScrollText.IsEmpty())
		SetPaneText(CommandToIndex(IDS_SCROLL_PANE), "");
	static UINT str_idx = 0;        //offset into string
	//if end of string, return to top
	if (str_idx >= (UINT) (m_strScrollText.GetLength() / 2) - 1)
		str_idx = 0;
	//display string
	SetPaneText(CommandToIndex(IDS_SCROLL_PANE), ((LPCSTR) 
	//scroll one character
	str_idx = str_idx + 1;

7. Destroy timer:

void CMyStatusBar::OnDestroy() 
	// TODO: Add your message handler code here

8. Add a method to start scrolling text. This method must be called after the mainframe (and the status bar) has been constructed to display scrolling text. Perhaps from the CWinApp::InitInstance().

void CMyStatusBar::StartDisplay(void) 
	//set text for scrolling
	m_strScrollText = "   Hello! World.   "
		//to make it circular scroll
		m_strScrollText += m_strScrollText;
	VERIFY(SetTimer(1, 200, NULL) != 0);    //timer


  • desktop

    Posted by Legacy on 08/05/1999 12:00am

    Originally posted by: atif

    do u know how to display on desktop client area not in application client area

    • Take a look!

      Posted by owuag on 12/03/2008 09:03pm


  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.