[futurebasic] [FB^3] Getting a list of open windows

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 2000 : Group Archive : Group : All Groups

From: "Brian J. Hughes" <BrianHughes@...>
Date: Mon, 24 Apr 2000 22:38:22 -0700
I mentioned before that I was creating a 'Windows' menu.  I had some 
trouble figuring out how to get the id's of open windows behind the 
active window.  It's a good thing I've kept my FBII manuals.  There 
is a great deal of information available in there.  It does a better 
job of explaining the window record than what's in IM:Window Manager

Below is the FN I use to update my menus on a _preMenuClick event. 
The 'Windows' menu is created front to back with the active window 
menu item checked.  Now I just have to figure out how to select a 
window from the menu.

I'm storing the window title is a simple array. gWndTitle$(wndNum%) 
I also need to keep a number of variables and static labels stored 
globally for each window.

Would I be correct in thinking that it might be better to create a 
record for each window to store these in?

Let me know if there is anything I can do better or easier in the code below.

'-------
LOCAL FN updateMenus
   DIM wndNum%, itemId%, actWnd%,
   DIM wndTitle$
   DIM @ activeWindPtr&, nextWnd&

   wndNum% = 0
   itemId% = 1
   actWnd% = WINDOW(_activeWnd)

   MENU _WindowsMenu, 0, _enable, "Windows"

   LONG IF actWnd% = 0
     MENU _WindowsMenu, itemId%, _enable, "No Windows Open"
     EXIT FN
   XELSE
     MENU _WindowsMenu, itemId%, _checked, gWndTitle$(actWnd%)
   END IF

   DO
     INC (itemId%)

     GET WINDOW actWnd%, activeWindPtr&
     nextWnd& = activeWindPtr&.nextWindow&
     wndNum% = USR WPTR2WNUM(nextWnd&)

     wndTitle$ = gWndTitle$(wndNum%)

     MENU _WindowsMenu, itemId%, _enable, wndTitle$
     actWnd% = wndNum%

   UNTIL nextWnd& = 0

END FN

P.S. FBII does do a nice job of reformatting the text from FB^3

------------
Brian Hughes