Solved

Dialog Caption

Posted on 2002-07-30
7
1,615 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
7 Comments
 
LVL 8

Expert Comment

by:VinExpert
Comment Utility
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
Comment Utility
... 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
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:jkelly061597
Comment Utility
Samarat did you find the code?
0
 
LVL 2

Expert Comment

by:SamratAshok
Comment Utility
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 75 total points
Comment Utility
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
Comment Utility
Thnk you very much... I got it.

jeff
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Generic progress indicator 6 109
Define unique primary key 9 81
How to determine file rename from EventLog ? 2 36
wordappend challenge 8 83
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…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 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

10 Experts available now in Live!

Get 1:1 Help Now