Hi All,
If i display a message using AfxMessageBox() then the title of the popup window is the name of the project. Is there anyway that i can change that to something else?
Any help would be great.
naim1
Printable View
Hi All,
If i display a message using AfxMessageBox() then the title of the popup window is the name of the project. Is there anyway that i can change that to something else?
Any help would be great.
naim1
Use ::MessageBox() instead. I am not sure if you can easily change the title using AfxMessageBox.
If it is suitable, you can change the name of your application (set by default to the name of the project) by editing a resource string named AFX_IDS_APP_TITLE. This string seems to be used by AfxMessageBox as the caption.
I hope this helps.
One solution to change the caption text in whole application when call AfxMessageBox is to override CWinApp::DoMessageBox:
Code:class CMyApp : public CWinApp
{
// ...
// Overrides
public:
virtual int DoMessageBox(LPCTSTR lpszPrompt, UINT nType, UINT nIDPrompt);
// ...
};
Code:int CMyApp::DoMessageBox(LPCTSTR lpszPrompt, UINT nType, UINT nIDPrompt)
{
// disable windows for modal dialog
EnableModeless(FALSE);
HWND hWndTop;
HWND hWnd = CWnd::GetSafeOwner_(NULL, &hWndTop);
// determine icon based on type specified
if ((nType & MB_ICONMASK) == 0)
{
switch (nType & MB_TYPEMASK)
{
case MB_OK:
case MB_OKCANCEL:
nType |= MB_ICONEXCLAMATION;
break;
case MB_YESNO:
case MB_YESNOCANCEL:
nType |= MB_ICONEXCLAMATION;
break;
case MB_ABORTRETRYIGNORE:
case MB_RETRYCANCEL:
break;
}
}
LPCTSTR pszCaption = _T("Asta-i pohta ce-am pohtit");
int nResult = ::MessageBox(hWnd, lpszPrompt, pszCaption, nType);
// re-enable windows
if (hWndTop != NULL)
::EnableWindow(hWndTop, TRUE);
EnableModeless(TRUE);
return nResult;
}