Write to status bar using sprintf syntax


#include < stdarg.h >

// StatusBarMessage() - Writes to status bar using sprintf syntax.
//
// Author: Keith Rule -- keithr@europa.com
//
// Copyright (c) 1995-1996, Keith Rule
// May be freely used provided this comment
// is included with the source and all derived
// versions of this source.
void StatusBarMessage(char* fmt, ...)
{
	if (AfxGetApp() != NULL && AfxGetApp()->m_pMainWnd != NULL) {
		char buffer[256];
		CStatusBar* pStatus = (CStatusBar*) 
			AfxGetApp()->m_pMainWnd->GetDescendantWindow(AFX_IDW_STATUS_BAR);
		va_list argptr;
		va_start(argptr, fmt);
		vsprintf(buffer, fmt, argptr);
		va_end(argptr);
		if (pStatus != NULL) {
			pStatus->SetPaneText(0, buffer);
			pStatus->UpdateWindow();
		}
	}
}



Comments

  • HomePage

    Posted by Legacy on 03/02/2002 12:00am

    Originally posted by: amit

    See My Statusbar

    Reply
  • Im New How Do I Use that code?

    Posted by Legacy on 08/31/2001 12:00am

    Originally posted by: RYan Zimmerman

    How Would I call that code up? Im very new. I have programmed in C++ long long time ago though.

    Reply
  • Update Version II

    Posted by Legacy on 06/26/2001 12:00am

    Originally posted by: V�ctor Carre�o

    Use this code
    
    

    void StatusBarMessage ( int nPanel, LPCTSTR pszFmt, ... )
    {
    TCHAR pszBuffer[1001];
    va_list argptr;

    va_start( argptr, pszFmt );

    int cch = _vsntprintf( pszBuffer,
    sizeof( pszBuffer )/sizeof( TCHAR ),
    pszFmt,
    argptr );
    va_end(argptr);

    if ( cch == -1 )
    {
    return;
    }

    if (AfxGetApp() != NULL && AfxGetApp()->m_pMainWnd != NULL)
    {
    CStatusBar* pStatus = (CStatusBar*)AfxGetApp()->m_pMainWnd->GetDescendantWindow(AFX_IDW_STATUS_BAR);

    if (pStatus != NULL)
    {
    pStatus->SetPaneText ( nPanel, pszBuffer );
    pStatus->UpdateWindow();
    }
    }
    }

    Reply
  • updated version

    Posted by Legacy on 04/15/2000 12:00am

    Originally posted by: Jeff Miller


    Here's what worked for me.

    void CMainFrame::StatusBarMessage(
    LPCTSTR pszFmt,
    ...
    )
    {
    TCHAR pszBuffer[256];

    va_list argptr;
    va_start( argptr, pszFmt );

    int cch = _vsntprintf( pszBuffer,
    sizeof( pszBuffer )/sizeof( TCHAR ),
    pszFmt,
    argptr );

    va_end(argptr);

    if ( cch == -1 )
    {
    return;
    }

    m_wndStatusBar.SetPaneText( 0, pszBuffer );
    m_wndStatusBar.UpdateWindow();
    }

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

  • You probably have several goals for your patient portal of choice. Is "community" one of them? With a bevy of vendors offering portal solutions, it can be challenging for a hospital to know where to start. Fortunately, YourCareCommunity helps ease the decision-making process. Read this white paper to learn more. "3 Ways Clinicians can Leverage a Patient Portal to Craft a Healthcare Community" is a published document owned by www.medhost.com

  • Ever-increasing workloads and the challenge of containing costs leave companies conflicted by the need for increased processing capacity while limiting physical expansion. Migration to HP's new generation of increased-density rack-and-blade servers can address growing demands for compute capacity while reducing costly sprawl. Sponsored by: HP and Intel® Xeon® processors Intel, the Intel logo, and Xeon Inside are trademarks of Intel Corporation in the U.S. and/or other countries. HP is the sponsor …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds