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
Solved

getting open window count

Posted on 2002-04-08
3
262 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
ID: 6926637
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
ID: 6928191
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
ID: 6932148
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.

856 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