Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Change child window title in doc/view MDI.

Posted on 2001-08-03
8
Medium Priority
?
250 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
[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
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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

722 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