Solved

AfxMessageBox title

Posted on 2000-04-17
5
1,484 Views
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...

0
Comment
Question by:tullhead
  • 3
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
Comment Utility
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
 

Author Comment

by:tullhead
Comment Utility
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
 
LVL 23

Expert Comment

by:chensu
Comment Utility
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
 

Author Comment

by:tullhead
Comment Utility
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
 
LVL 23

Expert Comment

by:chensu
Comment Utility
>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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
if loop error 4 76
Excel Use VBA to get user's Mac Address for their computer 5 79
no14 challenge 14 55
fix34  challenge 9 95
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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now