New DC_WindowList() function

This forum is for posting of useful information
Post Reply
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4804
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

New DC_WindowList() function

#1 Post by rdonnay »

I was asked to write a function that would popup a list of open windows and let the user bring that window to the front.
The user who asked for this said that he has so many open windows that some get hidden behind others. This only works
for child windows of the application.

Here is how you would put a button on the bottom status bar to popup a menu with the title of each window.

Code: Select all

   DCSTATUSBAR oStatBot TYPE XBPSTATIC_TYPE_RECESSEDBOX HEIGHT 20 ALIGN DCGUI_ALIGN_BOTTOM

   @ 0,0 DCSAY '' PARENT oStatBot SIZE 300,20 PIXEL ;
         OBJECT oMessage COLOR GRA_CLR_BLUE FONT '10.Lucida Console' SAYLEFT

   @ 0,0 DCSTATIC TYPE XBPSTATIC_TYPE_RAISEDBOX PARENT oStatBot SIZE 5,20 PIXEL

   @ 0,0 DCPUSHBUTTON CAPTION 'Windows' SIZE 80,20 PIXEL ;
         ACTION {|a,b,o|DC_WindowList(oDlg:drawingArea,o)} PARENT oStatBot


FUNCTION DC_WindowList( oParent, oButton )

LOCAL GetList[0], GetOptions, aWindows, aChildren, i, oMenu, oXbp

aChildren := oParent:childList()

DCSUBMENU oMenu PROMPT 'Windows' OWNERDRAW

FOR i := 1 TO Len(aChildren)
  oXbp := aChildren[i]
  IF oXbp:isDerivedFrom('XbpDialog')
    DCMENUITEM oXbp:title ACTION _ActionBlock(oXbp) PARENT oMenu
  ENDIF
NEXT

DCREAD GUI EXIT SAVE PARENT AppDeskTop()

oMenu:PopUp( oButton:setParent(), oButton:currentPos(), 2 , ;
             XBPMENU_PU_DEFAULT + XBPMENU_PU_MOUSE_RBDOWN  )

RETURN nil

* --------------

STATIC FUNCTION _ActionBlock( oXbp )

RETURN {||oXbp:setFrameState(XBPDLG_FRAMESTAT_NORMALIZED), ;
          oXbp:toFront()}
The eXpress train is coming - and it has more cars.

Post Reply