Solved

AfxMessageBox title

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand LInux Boot partition remotly 3 90
fix34  challenge 9 116
How to convert MFC::CString to UTF8 wchar_t* 10 200
mapAB Challlenge 35 142
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

813 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

11 Experts available now in Live!

Get 1:1 Help Now