Show scrolling text in a status bar pane

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[] =
	{
		ID_SEPARATOR, 
		IDS_SCROLL_PANE,				//scrolling text
		ID_INDICATOR_CAPS,
		ID_INDICATOR_NUM,
		ID_INDICATOR_SCRL,
	};

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())
	{
		KillTimer(1);
		SetPaneText(CommandToIndex(IDS_SCROLL_PANE), "");
		return;
	}
	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) 
		m_strScrollText)+str_idx); 
	
	//scroll one character
	str_idx = str_idx + 1;
	
	CStatusBar::OnTimer(nIDEvent);
}

7. Destroy timer:

void CMyStatusBar::OnDestroy() 
{
	CStatusBar::OnDestroy();
	
	// TODO: Add your message handler code here
	
	KillTimer(1);
}

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;
	
	KillTimer(1);
	VERIFY(SetTimer(1, 200, NULL) != 0);    //timer
}

IT Offers

Comments

  • Jordan shoes mentioned Gene to buy the variety, a disunion of Nike

    Posted by TaddyGaffic on 04/20/2013 12:12pm

    The sole of shoes are made from high quality rubber material and come with the lining. One can easily search for Vans footwear in the various online stores where they are easily available at great discount prices. These come in almost an infinite amount of [url=http://northernroofing.co.uk/roofins.cfm]nike free uk[/url] color and are usually on the cheap side. Experts as well as the rights of employees in regards to the apple can annihilate the Nike Air Max For travel arrangements in developing abjection can be a acceptable accord added in comparison to they're prevention, nonetheless they do accommodate sports sports athletes while using high duke inside their profession. Bargain Nike Air Max 2009 aswell provides countless jobs inside the nations absolutely area it's hardly accessible to acquire a job. In Indonesia, for archetype nike air max 90, even acknowledging baby assets [url=http://northernroofing.co.uk/roofins.cfm]nike free run 3[/url] in barter for plan Air Max, however, Nike bargain shoes inside a aught bulk adaptation and utilisation of the circadian needs.. Nike Zoom Vapor VI Tour Men`s tennis shoe is a great shoe popular in the tennis courts. It has Fly wire upper for ultra support and light weight ability, it sits on a frame that gives extra heel support and contains a full-length durable rubber support and herring bone pattern. It also has extra traction for all surfaces of play.. Write a Shakespeare Sonnet without any effort! Express loving [url=http://northernroofing.co.uk/roofins.cfm]nike free uk[/url] feelings in a sonnet in Shakespeare's own words in 15 minutes. The rhyme scheme of a Sonnet is a,b,a,b,c,d,c,d,e,f,e,f,g,g. Think of a theme like "love" "death" or "deceit", then choose your lines in the rhyme pattern and put a Sonnet together using the programme

    Reply
  • 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

      Check

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

Go Deeper

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds