AfxMessageBox title

Posted on 2000-04-17
Medium Priority
Last Modified: 2013-11-20
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...

Question by:tullhead
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 23

Accepted Solution

chensu earned 200 total points
ID: 2724934
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"));

Author Comment

ID: 2725022
You second suggestion put me on the right track.  In fact, I added this to the constructor of myApp:    

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

LVL 23

Expert Comment

ID: 2725524
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.
//Change the name of the application file.
//The CWinApp destructor will free the memory.

Author Comment

ID: 2727424
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:

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....?

LVL 23

Expert Comment

ID: 2727487
>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.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question