Write to status bar using sprintf syntax

CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.


#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();
}
}
}

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read