Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Change child window title in doc/view MDI.

Posted on 2001-08-03
8
Medium Priority
?
253 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 225 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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
 
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

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: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
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.
Suggested Courses

824 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