Solved

getting open window count

Posted on 2002-04-08
3
256 Views
Last Modified: 2013-11-20
I have an MDI application, and I need to count all currently open views. One way to do it would be using GetTopWindow() and GetNextWindow() functions, which would permit me to start from the topmost window and count all of them in z order, step by step. But isn't there a shorter way to get this count, maybe, from a single function call ?

I even need not the exact count, but rather a close upper bound estimate: how many views do I have currently open at most.
0
Comment
Question by:olegsp
3 Comments
 
LVL 3

Accepted Solution

by:
GGRUNDY earned 50 total points
Comment Utility
If counting your own views is all you are after then, I suppose you could have your views increment and decrement a global variable.
But really you ought to consider yourself lucky that GetTopWindow etc is so straight forward, most simple tasks that one wants to perform in Windows turn out to be way more annoying/complicated/tricky/frustrating/unobvious/error-prone than this.
0
 
LVL 86

Expert Comment

by:jkr
Comment Utility
Why don't you just

UINT CMyDoc::GetViewCount ()
{
   UINT unViews = 0;

   POSITION pos = GetFirstViewPosition();
   while (pos != NULL)
   {
      CView* pView = GetNextView(pos);
      unViews++;
   }  
   return nViews;
}
0
 
LVL 1

Author Comment

by:olegsp
Comment Utility
jkr,
You are offering essentially the same iterator-based approach as I have with GetNextWindow(). I was looking rather for a single API function call to retrieve the total number of current views.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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 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 video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 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

9 Experts available now in Live!

Get 1:1 Help Now