• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1585
  • Last Modified:

AfxMessageBox title

Here's a simple little question:  I have used AfxMessageBox throughout my App.  The title on these panels is the name of my project.  But my project name is an 'internal' name that I don't want customers to see.  How can I change that title?

Method A: Some way to set the title of my choice in the AfxMessageBox call

Method B: I could rename my project to match the 'external' name, but i don't see any EASY way to rename a project (I'm using VC++ 6.0 and the IDE).  I recall once renaming a very small project "manually" and it was a bear -- took quite a while to find all occurances of the former name and change them all...

0
tullhead
Asked:
tullhead
  • 3
  • 2
1 Solution
 
chensuCommented:
Use the CWnd::MessageBox function, which allows you to set the title. Another way is to pass the application name to the constructor of the application object.

// CMyApp constructor should pass the parameter to CWinApp constructor.
CMyApp theApp(_T("My Application"));
0
 
tullheadAuthor Commented:
You second suggestion put me on the right track.  In fact, I added this to the constructor of myApp:    


this->m_pszAppName = _tcsdup(_("MyName"));



0
 
chensuCommented:
Don't forget to free the memory associated with the current pointer before assigning a new value.

//First free the string allocated by MFC at CWinApp startup.
//The string is allocated before InitInstance is called.
free((void*)m_pszAppName);
//Change the name of the application file.
//The CWinApp destructor will free the memory.
m_pszAppName=_tcsdup(_T("d:\\somedir\\myapp.exe"));
0
 
tullheadAuthor Commented:
Chensu --

I don't understand your setting a full pathname in the Appname....  Presently,
I have the following as the first two lines in my InitInstance:

free((void*)m_pszAppName);
m_pszAppName = _tcsdup(_("MyName"));

This all seems to work fine as far as
I can tell.  What do you think?

Anyway, how would I know in code where
my .exe file is sitting on a user's computer even if I wanted to set the full pathname....?





0
 
chensuCommented:
>I don't understand your setting a full pathname in the Appname....

Don't worry. The name can be anything. I just copied the example code from the MFC documentation.

>Anyway, how would I know in code where
my .exe file is sitting on a user's computer even if I wanted to set the full pathname....?

Call the GetModuleFileName function.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now