[futurebasic] Whole screen window

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 1999 : Group Archive : Group : All Groups

From: Robert Purves <robert.purves@...>
Date: Sun, 28 Feb 1999 20:21:17 +1300
Many programs, including games, use a window covering the whole screen.
For this, you may need to:-
1 Hide the menu bar. [Hide it _before_ creating the window]
2 Allow mbar to be seen, for example when user presses Cmd key
   or moves mouse to menu bar. [Special code to restore ability to
   draw to top of window after menu disappears again]
3 Quit / suspend gracefully, hiding the main window, showing mbar
   and replacing those "roundies" at the screen bottom. [Black out all,
   or at least the bottom 10 rows of, the window before exiting]
4a  Hide the Control Strip (CS).
4b  Disable that pesky CS so that a click on it has no effect.
5  Allow user to choose one of multiple monitors.

It is not obvious how these tasks should be programmed. [Some hard-won
hints are given above]. The code below manages 1 to 3 quite well, 4a
nearly, 4b and 5 not at all. On my system when this program is run, the CS
_is_ initially invisible and disabled. Holding down the Cmd key makes the
CS visible and active. Releasing the Cmd key makes the CS invisible but
active; a click at the right place makes a CS menu suddenly pop up out of
nowhere. What's going on? Any suggestions to fix it (perhaps FN
HideCtrlStrip)? Lastly, has anyone got code for task 5 or better code for
1-3?

Robert

COMPILE ,_dimmedVarsOnly
DIM gOldMBarHeight,gOldDeskRgn&,gScrnRect.8,gWndPtr&,gInBkGrnd
DIM gMBHtForMouse
_mainWnd=1
END GLOBALS

LOCAL FN HideMenuBar
 DIM tmpRgn&
 LONG IF gOldMBarHeight=0' Not already hidden
  gOldDeskRgn&=FN NEWRGN
  CALL COPYRGN ([_GrayRgn],gOldDeskRgn&)
  gOldMBarHeight={_MbarHeight}
  gMBHtForMouse=gOldMBarHeight' Save for FN IsMouseInMenuBar
  % _MbarHeight,0
  tmpRgn&=FN NEWRGN
  CALL SETRECTRGN(tmpRgn&,0,0,SYSTEM(_scrnWidth),SYSTEM(_scrnHeight))
  CALL UNIONRGN([_GrayRgn], tmpRgn&,[_GrayRgn])
  CALL PAINTONE(_nil,tmpRgn&)
  CALL DISPOSERGN(tmpRgn&)
 END IF
END FN

LOCAL FN ShowMenuBar
 LONG IF gOldMBarHeight' Not already showing
  % _Mbarheight,gOldMBarHeight
  CALL COPYRGN (gOldDeskRgn&,[_GrayRgn])
  CALL DISPOSERGN (gOldDeskRgn&)
  CALL DRAWMENUBAR
  gOldMBarHeight=0
 END IF
END FN

LOCAL FN SetVisRgnWholeWnd
 CALL RECTRGN([gWndPtr&+_visRgn],#gWndPtr&+_portRect)
END FN

LOCAL FN IsCmdKeyDown'True if cmd key currently down
 DIM keys(7)
 CALL GETKEYS(keys(0))
END FN=(keys (3) AND &8000)=&8000

LOCAL FN IsMouseInMenuBar
 DIM mPtY,mPtX
 CALL GETMOUSE(mPtY)
END FN=(mPtY<gMBHtForMouse)

LOCAL FN ClearUp
 WINDOW OUTPUT _mainWnd
 FN SetVisRgnWholeWnd
 COLOR=_zBlack
 CALL PAINTRECT(gScrnRect)'Make black to fix "roundies" at bottom
 FN ShowMenuBar
END FN

LOCAL FN HandleDialog
 DIM evnt,id
 evnt=DIALOG(0): id= DIALOG(evnt)
 SELECT evnt
  CASE _mfEvent
   SELECT CASE id
    CASE _mfResume
     FN HideMenuBar
     CALL SHOWWINDOW(gWndPtr&)
     gInBkGrnd=_false
    CASE _mfSuspend
     FN ClearUp
     CALL HIDEWINDOW(gWndPtr&)
     gInBkGrnd=_zTrue
   END SELECT
 END SELECT
END FN

LOCAL FN HandleStop
 FN ClearUp
 END
END FN

' -----main------
ON DIALOG FN HandleDialog
ON BREAK FN HandleStop
ON STOP FN HandleStop
ON MENU FN HandleStop
MENU 1,0,1,"File": MENU 1,1,1,"Quit/Q"
gInBkGrnd=_false
gOldMBarHeight=0
CALL SETRECT(gScrnRect, 0,0,SYSTEM(_scrnWidth),SYSTEM(_scrnHeight))
FN HideMenuBar                   ' Must be in...
WINDOW _mainWnd,"",@gScrnRect,3  '...this order.
GET WINDOW _mainWnd,gWndPtr&
CALL TEXTMODE(_srcCopy)
DO
 HANDLEEVENTS
 LONG IF NOT gInBkGrnd
  LONG IF FN IsCmdKeyDown OR FN IsMouseInMenuBar
   FN ShowMenuBar
  XELSE
   FN HideMenuBar
   FN SetVisRgnWholeWnd  'Allow overwriting of mbar / Control Panel
   WINDOW OUTPUT _mainWnd'Also needed for overwriting of mbar
   CLS ' tiny graphics program
   PRINT @(0,22) "To see menu bar, press Cmd or move mouse to top."
   PRINT @(0,24)"Cmd-. OR Cmd-Q to end"
  END IF
 END IF
UNTIL 0