Solved

getting open window count

Posted on 2002-04-08
3
258 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Importing  SSL Certificate into Firefox using GPO 28 202
if loop in java 3 128
VBA "SendKeys" Syntax for Multiple Keystrokes 7 103
withoutTen challenge 14 97
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: 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…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

914 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

21 Experts available now in Live!

Get 1:1 Help Now