15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Changing the title of the mainframe window

Seetharaman G -- CGS@wintegrity.com
Tuesday, December 31, 1996


Hi,
	Environment: VC++ 4.2-flat, WIN95,NT 3.51/4.0

We are using VC++ ver 4.2 and are in the process of migrating from the
16bit version. How do we change the title in the mainframe window ? In
the 16bit version we had a function in CMainFrame class called SetTitle
which would initialize the m_strTitle member variable of the CMainFrame
class. We used to call this function from the InitInstance and it used
to do the job for us. The same scheme gives an exception in the 32bit
version. The function we used in the 16bit version is as follows

void CMainFrame::SetTitle(CString strTitle)
{
	m_strTitle = strTitle;
	SetWindowText(m_strTitle);
}

We used to invoke this from the InitInstance as follows
	((CMainFrame*)(AfxGetApp()->m_pMainWnd))->SetTitle(strAppTitle);

Any help would be greatly appreciated.

Thanks.
Ram





smith137@mc.duke.edu
Tuesday, December 31, 1996

Ram:
  Where precisely are you asking for the value of m_pMainWnd
in InitInstance?  Is your GPF the result of m_pMainWnd being
NULL?  I can still do something similar to what you are doing,
so I suspect this has something to do with where you are
doing it.  Can you send me the code for your InitInstance
method?

Dwight

_______________________ Reply Separator _______________________

Subject: Changing the title of the mainframe window
Author:  CGS@wintegrity.com at Internet
Date:    12/31/96 10:10 AM

Hi,
        Environment: VC++ 4.2-flat, WIN95,NT 3.51/4.0

We are using VC++ ver 4.2 and are in the process of migrating from the
16bit version. How do we change the title in the mainframe window ? In
the 16bit version we had a function in CMainFrame class called SetTitle
which would initialize the m_strTitle member variable of the CMainFrame
class. We used to call this function from the InitInstance and it used
to do the job for us. The same scheme gives an exception in the 32bit
version. The function we used in the 16bit version is as follows

void CMainFrame::SetTitle(CString strTitle)
{
        m_strTitle = strTitle;
        SetWindowText(m_strTitle);
}

We used to invoke this from the InitInstance as follows
        ((CMainFrame*)(AfxGetApp()->m_pMainWnd))->SetTitle(strAppTitle);

Any help would be greatly appreciated.

Thanks.
Ram



Antonio Jorge Marques Pires -- AntonioPires@mail.telepac.pt
Thursday, January 02, 1997

Seetharaman,

Changing title, menu and icon to IDR_TECHNICAL_MAINFRAME ...

void CMainFrame::OnConfigurarModotecnico() 
{
//	CPasswordDlg::OperationMode Mode = CPasswordDlg::OperationMode::Tecnico;
//	if (CPasswordDlg::CheckPassword(Mode, FALSE)) {
		CMenu newMenu;
		newMenu.LoadMenu (IDR_TECHNICAL_MAINFRAME);
		AfxGetMainWnd()->SetMenu( &newMenu );
		AfxGetMainWnd()->DrawMenuBar();
		newMenu.Detach ();

		AfxGetMainWnd()->SetIcon(AfxGetApp()->LoadIcon(IDR_TECHNICAL_MAINFRAME),
FALSE);

		AfxGetMainWnd()->SetWindowText ( "Your Title is here" ) ;

//		theApp.m_Mode = CPasswordDlg::OperationMode::Tecnico;
//	}
}

-- Antonio Pires



RIchard -- kdtexas@Onramp.NET
Sunday, January 05, 1997

Try virtual void SetTitle( LPCTSTR lpszTitle ) which is a virtual
function in CDocument .

If you are using a MDI interface you can use this as long as the views
do not share the same document. If they do, the easiest way is to
override the CView function OnUpdate() and use the CWnd function
SetWindowText(lpsz Ttitle). This will change the title of the window on
a window by window basis.


    All things are possible, however, some are not needed.




| Вернуться в корень Архива |