AfxMessageBox() title
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: AfxMessageBox() title

  1. #1
    Join Date
    Jan 2005
    Posts
    317

    Cool AfxMessageBox() title

    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

  2. #2
    Join Date
    Dec 2001
    Location
    Greece, Athens
    Posts
    1,015

    Re: AfxMessageBox() title

    Use ::MessageBox() instead. I am not sure if you can easily change the title using AfxMessageBox.
    Theodore
    Personal Web Page (some audio segmentation tools): www.di.uoa.gr/~tyiannak

  3. #3
    Join Date
    May 2006
    Posts
    327

    Re: AfxMessageBox() title

    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.

  4. #4
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,021

    Re: AfxMessageBox() title

    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;
    }
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center