Solved

Change child window title in doc/view MDI.

Posted on 2001-08-03
8
237 Views
Last Modified: 2013-11-20
How can I change a child windows title to reflect an arbitrary number? i.e. Rotation Calibration: 99 Units.

0
Comment
Question by:sgraves66
8 Comments
 
LVL 2

Expert Comment

by:Lockias
ID: 6349999
Assuming you have a pointer (or know how to get it) to the child window, simply call SetWindowText(sTitle).

~Lockias
0
 
LVL 1

Author Comment

by:sgraves66
ID: 6350103
Ok. Actually, now I override CDocument::SetTitle(LPCTSTR lpszTitle). Doing this, how can I append the number of current document instanes to the title? I would like to reflect the number of units as the number of open documents. Originally, I wanted to set this to an arbitrary number and had forgotten SetWindowText() altogether, but I've changed how I wish to implement this.
0
 
LVL 2

Accepted Solution

by:
Lockias earned 75 total points
ID: 6350307
I will assume you know the number of documents some how.  Then you just need to format a string the way you want it.  There are many ways to format strings, some arguably better than others, but I will show you one, because that gets into a whole other question.

-----------------------------
CString sTitle = pDoc->GetTitle();

CString sNewTitle;
sNewTitle.Format("%s - %d", sTitle, nDocCount);
pDoc->SetTitle(sNewTitle);

-----------------------------

Something like that.

~Lockias
0
 
LVL 1

Author Comment

by:sgraves66
ID: 6350647
Well, I understand how to format the string output. I need to know how to calculate the number of open documents for a specific doc template. I suppose I will have to use a nested loop within my CWinApp derived class. Just thought there might be a way to quickly determine the value.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 12

Expert Comment

by:migel
ID: 6350924
Hi!
you can ask docTemplate from document:
CDocTemplate* pTemplate = pDco->GetDocTemplate();
int nCount = 0;
POSITION pos = pTemplate->GetFirstDocPosition();
while (pos)
{
pTemplate->GetNextDoc(pos);
nCount++;
}
0
 
LVL 1

Author Comment

by:sgraves66
ID: 6351027
Ok. I see, I would need to create a public member function in my CMultiDocTemplate-derived class to calculate the number of documents. i.e. UINT CMyMultiDocTemplate::NumDocs()
Then call pTemplate->NumDocs, correct?
0
 
LVL 1

Expert Comment

by:pkreddy
ID: 6351060
hi,
 Its not necessary to derive a class form CDocTemplate to count no. of docs. You can use migels's code in any function of your CDocument derived class with slight modification.

I am writing a funtion for a CMyDocument derived class

int CMyDocument::GetNumDocuments()
{
  CDocTemplate* pTemplate = GetDocTemplate();
  int nCount = 0;
  POSITION pos = pTemplate->GetFirstDocPosition();
  while (pos)
  {
    pTemplate->GetNextDoc(pos);
    nCount++;
  }
  return nCount;
}

 and you can call it anywhere and display the no.

- PK
0
 
LVL 1

Author Comment

by:sgraves66
ID: 6351534
Cool. I alreadly have a class derived from CMultiDocTemplate and have several different documents based upon this. I would have to write code for every CDocument-derived class to produce the count, so I think, in my situation, it would be more efficient to create a new class member function. Thx for all the help.

BTW - Both answers were correct, since I asked 2 questions. How should I allocate the points? I'll let you two decide.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

16 Experts available now in Live!

Get 1:1 Help Now