Click here to Skip to main content
15,899,663 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have created my Application without Document/View Architecture. Reason is its not file based, its mostly related with database. Mostly I am using for Reporting. And before I go any further with the question, I did look for the solution in google. Not enough help.

When I did:
when user open a report window it has a basic caption at the top. After user select a Customer and request to display the data, a bunch of statement do the change of the caption of the tab bar. So far this is good. It work. Code is as below:

C++
CWnd *pr=this->GetParent();
pr->SetWindowTextW(ch);


The problem i am facing is :
1. When I minimize the code Caption got changed to the initial caption.
2. When I open a new window in new tab the previous window lost the caption immediately.

What can be the proper way to keep it all the time?

Thanks in advance
Posted
Updated 18-Oct-12 2:05am
v2
Comments
Richard MacCutchan 18-Oct-12 9:09am    
Are you sure there is not some code somewhere that is resetting this? A window will normally hold its text caption until reset by another WM_SETTEXT message.
[no name] 18-Oct-12 9:11am    
That's what I am looking for, From where it get rested. but no luck.
Richard MacCutchan 18-Oct-12 9:29am    
Well since we cannot see what is going on in your program it's impossible to make any other suggestions.

1 solution

This solution applies only when your report windows are derived from CFrameWnd.

The basic window title of CFrameWnd and CDocument classes is stored in the member variable m_strTitle which can be set and retrieved with the virtual functions SetTitle() and GetTitle(). So you should use SetTitle() to change the title or overwrite the function. Note that this will only change the member variable. You must still call SetWindowText(). The member variable is initialized by Create() with the window name passed to Create().

If not using SetTitle(), the on screen title will be updated using the m_strTitle text.

Another point that must be observed is the automatic creation of frame windows. CFrameWnd windows created by document templates have the implicit style FWS_ADDTOTITLE. When this style is set, the title is updated each time when an internal idle flag is set. To remove the flag, overwrite PreCreateWindow() of your frame window class:
BOOL CMyFrame::PreCreateWindow(CREATESTRUCT& cs)
{
    // Style FWS_ADDTOTITLE is always set when creating a frame window.
    // See CDocTemplate::CreateNewFrame() in doctmpl.cpp
    cs.style &= ~FWS_ADDTOTITLE;
    // Change CFrameWnd to the base class if necessary
    return CFrameWnd::PreCreateWindow(cs);
}
 
Share this answer
 
Comments
[no name] 18-Oct-12 13:16pm    
Thanks for the answer, I will check
[no name] 18-Oct-12 21:43pm    
I did not found any SetTitle Function but you suggestion with style bailed me out.

I added the above statement in my PreCreateWindow Working fine.

But It creates another issue. When New window get created it get created without Title. So, I add statement in OnCreate Function to add Pre defined titled.
Thanks for your reply
Jochen Arndt 19-Oct-12 2:42am    
Thank you for your feedback.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900