Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dialog Caption

Posted on 2002-07-30
7
Medium Priority
?
1,634 Views
Last Modified: 2013-11-20
A few things:

I do not want MFC to display the current filename in the Title bar of the main window, and I want to have the ability to change the caption at various runtime points... what do I need?

Also: How do I change the caption on a dialog box at runtime? Is it the same as for the main window?

thanks
jeff
0
Comment
Question by:jkelly061597
[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
7 Comments
 
LVL 8

Expert Comment

by:VinExpert
ID: 7188724
Hi,

For all ur questions, there is only one answer. Use the function SetWindowText(). If U want to set the title for the main window in an SDi/MDI, then use the mainframe pointer and call SetWindowText(...) specifying ur new title. And for dialog, use ur dialog pointer or from the dialog class call SetWindowText(...) function.

If u want to set the title bar initially itself, then for MainFrame, do it in OnCreate function before returning and for dialog, map OnInitDialog message map and call SetWindowText.

Try it out.
VinExpert
0
 
LVL 8

Expert Comment

by:fl0yd
ID: 7189276
... so far so good :) ...

To get the mainframe pointer from any location call the AfxGetMainWnd-function. It returns a CWnd*

Other than that, VinExpert has already answered your question.

.f
0
 
LVL 2

Expert Comment

by:SamratAshok
ID: 7189431
From your questions, I gather that you are using
Document-view architecture and most likely MDI!

In this case, you have to override functions in
CDocument; I don't remember the exact name, but is
something like GetTitle.

Even if you do suppress the name, it still leaves
that annoying separator "-" To suppress this, I tinkered
with CMainframe, I will dig up my old code and let you
know; I don't remember as of now.

If you cannot wait, then set break point on CDocument
override; debug it into MFC to figure out how it
peices name together and then break the chain.

For dialog boxes; you can call SetWindowText.

For views : Never call SetWindow text indiscriminately
without understanding which window you are calling for.
There is much more behind the screens then you can see
for a view.

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:jkelly061597
ID: 7218418
Samarat did you find the code?
0
 
LVL 2

Expert Comment

by:SamratAshok
ID: 7227934
jkelly

was too busy to check ee. Will be able to look and
let u know!

Sorry for delay!
0
 
LVL 2

Accepted Solution

by:
SamratAshok earned 300 total points
ID: 7228508
Hello jkelly

Finally, did the code dig up as promised. Found
couple of different methods exist where you can
control appearance of title. Listing them in
order of simplicity.

1) Override CDocument::SetTitle method

2) Override CMainFrame::PreCreateWindow

Add a line which looks like
cs.style &= ~FWS_ADDTOTITLE;

// This line changes window style settings that
// affect the title generation. play with them
// to see which override works the best.

3) Override CChildFrame::PreCreateWindow

This function is exactly identical to above
one needs same source code, but affects inner
child window behaviour.

Again experiment by setting both on, first only, second only or none permutations.

4) Edit resource string in  editor
Read documentation for further details
or look up source code for AfxExtractSubString
in winstr.cpp to see how it parses the string.

5) Last option. Override OnUpdateFrameTitle function
and code your requirements exactly.

override this function if and only if you absolutely must.
You will be preety much out and open with no MFC intervention regarding titles. You can actually copy
existing MFC source and then tweak it to make it work
for you.


Hope this helps

0
 

Author Comment

by:jkelly061597
ID: 7228813
Thnk you very much... I got it.

jeff
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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…
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.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

719 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