Click to See Complete Forum and Search --> : How do I change Title bar text


Rossi
May 26th, 1999, 01:51 AM
I want to know how to replace the titlebar text in my SDI to something useful.
I've tried these:

CWnd::GetWindowText();
CWnd::SetWindowText();

But no luck, if I set nothing changes, and if I get after I set, the new value is returned by GetWindowText().
And if I get before calling SetWindowText(), I get garbage instead of the "Untitled - MyApp" I thought I would get, since that is what I am seeing in the title bar.

What do I do now?
PS: I call these functions in my View (CListView) class, after construction of the view.
And also, I want to know how to flicker the titlebar on a given event, when it is minimized.

Thanks in advance

Cheers
Rossi.

==============================================
Allen Van Der Ross
Systems Programmer
Software Performance Improvement
South Africa
E-Mail: allen@ct.spi.co.za
==============================================

Vicky
May 26th, 1999, 02:10 AM
You can use CDocument::GetTitle and CDocument::SetTitle in OnInitialUpdate() of your View. For Example

CMyAppDoc* pDoc = GetDocument();
pDoc->SetTitle("Changing title");



This will change the "Untitled" to "Changing title".

Hope this helps you.

Roger Allen
May 26th, 1999, 03:51 AM
Here's how I have flashed the title bar before :

You need to declare

int m_TimerID ;
bool m_bFlashTitle ; (init to false)

void CMainFrame::StartFlashingTitleBar()
{
// only start to flash if not active
if (m_TimerID == 0 && !m_bActive)
{
m_TimerID = SetTimer(2, ::GetCaretBlinkTime(), MainWndTimerProc) ;
m_bFlashTitle = true ;
}
}

void CALLBACK EXPORT MainWndTimerProc(
HWND hWnd, // handle of CWnd that called SetTimer
UINT nMsg, // WM_TIMER
UINT nIDEvent, // timer identification
DWORD dwTime
)
{
((CMainFrame*)(AfxGetMainWnd()))->FlashWindowNow() ;

dwTime = 0 ;
nIDEvent = 0 ;
nMsg = 0 ;
hWnd = 0 ;
}

void CMainFrame::FlashWindowNow()
{
static bool bFlash = true ;

FlashWindow(bFlash) ;
bFlash = !bFlash ;
}

void CMainFrame::OnActivateApp(BOOL bActive, HTASK hTask)
{
CMDIFrameWnd::OnActivateApp(bActive, hTask);

if (!bActive)
{
// the application has been deactivated
m_bActive = false ;
}
else
{
m_bActive = true ;
// if we are flashing, stop it
if (m_bFlashTitle)
{
KillTimer(m_TimerID) ;
m_TimerID = 0 ;
}
m_bFlashTitle = false ;
}
}

I hope this helps


Roger Allen

Marqy
May 26th, 1999, 03:52 AM
The title bar of your SDI is the frame window, not the view. Try AfxGetMainWnd()->SetWindowText("MyNewTitle")



MJA

reddy_satya
June 1st, 1999, 04:58 AM
Add the following line of code in your Application class, (in your case List.cpp? )

ccode
BOOL CListApp::InitInstance()
{
--
--
m_pMainWnd->SetWindowText("Name of Application");
return TRUE;
}
/ccode
let me know, if it works

--SatyaReddy