Solved

AfxMessageBox title

Posted on 2000-04-17
5
1,526 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
[X]
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
5 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 50 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"));
0
 

Author Comment

by:tullhead
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"));



0
 
LVL 23

Expert Comment

by:chensu
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.
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
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:

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

Featured Post

Technology Partners: 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: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

690 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