FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

WINDOWS

Manage a grow box


Here is a small demo. Note that "AUTOCLIP = _False" is NOT optional. Thanks to Mars and the rest of the guys that originally helped me with this same problem.

Jamin

WINDOW OFF
COORDINATE WINDOW
WIDTH = _NoTextWrap
DEFSTR LONG

DIM gUserQuits%
DIM OverWriteProtection$
END GLOBALS

CLEAR LOCAL
  DIM rect.8
  DIM oldClip&
'=================
LOCAL FN DrawGrowIcon(WindowID%)
'---------------------------------------
  WINDOW OUTPUT WindowID%
  CALL PENNORMAL
  oldClip& = FN NEWRGN
  IF oldClip& THEN CALL GETCLIP(oldClip&)
  myWindowPtr& = WINDOW(_wndPointer)
  CALL SETRECT(rect,WINDOW(_width)-16,WINDOW(_height)-16,WINDOW(_width),WINDOW(_height))
  CALL CLIPRECT(rect)
  CALL DRAWGROWICON(myWindowPtr&)
  IF oldClip& THEN CALL SETCLIP(oldClip&):CALL DISPOSERGN(oldClip&)
END FN

CLEAR LOCAL
  DIM rect.8
  DIM maxSizeRect.8
  DIM thePoint.4
  DIM LongPoint&;0,longY%,longX%
'=================
LOCAL FN CheckGrowWindow(MouseHorz%,MouseVert%)
'---------------------------------------
  AUTOCLIP = _False
  thePoint.h% = MouseHorz%
  thePoint.v% = MouseVert%
  WindowID% = WINDOW(_activeWnd)
  CALL SETRECT(rect,WINDOW(_width)-16,WINDOW(_height)-16,WINDOW(_width),WINDOW(_height))
  LONG IF FN PTINRECT(thePoint,rect)
    myWindowPtr& = WINDOW(_wndPointer)
    LONG IF myWindowPtr& > 0
      CALL LOCALTOGLOBAL(thePoint)
      CALL SETRECT(maxSizeRect,100,100,400,400)
      LongPoint& = FN GROWWINDOW(myWindowPtr&,thePoint,maxSizeRect)
      LONG IF LongPoint& > 0
        CALL ERASERECT(rect)
        CALL SIZEWINDOW(myWindowPtr&,longX%,longY%,_False)
        CALL SETRECT(rect,0,0,longX%,longY%)
        CALL INVALRECT(rect)
      END IF
    END IF
  END IF
END FN

'=================
LOCAL FN MouseHandler
'---------------------------------------
  ClickType% = MOUSE(0)
  LONG IF ClickType% <> 0
    MouseHorz% = MOUSE(_lastMHorz)
    MouseVert% = MOUSE(_lastMVert)
    FN CheckGrowWindow(MouseHorz%,MouseVert%)
  END IF
END FN

'=================
LOCAL FN DialogHandler
'---------------------------------------
  evnt% = DIALOG(0)
  id% = DIALOG(evnt%)
  LONG IF evnt% = _wndRefresh AND id% = 1
    FN DrawGrowIcon(id%)
  END IF
END FN

ON DIALOG FN DialogHandler
ON MOUSE FN MouseHandler

WINDOW 1,"Grow Window Test",(0,0)-(300,300),_DocNoGrow_NoGoAway

DO
  HANDLEEVENTS
UNTIL gUserQuits%
END


Whenever you get a redraw or activate event in your special window, simply call this function:

LOCAL FN drawOnlyGrow
  DIM t,l,b,r
  DIM oldOut, grwRgn&, saveCurClipRgn&

  oldOut = WINDOW(_outputWnd)
  WINDOW OUTPUT(gWhichWindow)
  b = WINDOW(_height)
  r = WINDOW(_width)
  t = b - 16
  l = r - 16
  grwRgn& = FN NEWRGN
  CALL RECTRGN(grwRgn&,t)
  saveCurClipRgn& = FN NEWRGN
  CALL GETCLIP(saveCurClipRgn&)
  CALL SETCLIP(grwRgn&)
  CALL DRAWGROWICON(WINDOW(_wndPointer))
  CALL SETCLIP(saveCurClipRgn&)
  CALL DISPOSERGN(grwRgn&)
  CALL DISPOSERGN(saveCurClipRgn&)
  IF oldOut THEN WINDOW OUTPUT(oldOut)
END FN

Greg