Solved

Change child window title in doc/view MDI.

Posted on 2001-08-03
8
248 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 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

630 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