routine WIN.CTRL given FIELD, WIN.PTR yielding BLOCK.DEFAULT
''
''    AUTHOR: Steve Bailey
''    CREATED: 1-20-95
''    DESCRIPTION:
''        Example control routine for a window.  Anytime the user resizes,
''        closes, scrolls, clicks in, or moves the mouse in the window given
''        by WIN.PTR, this routine will be called. 
''

define FIELD as a text variable
define WIN.PTR as a pointer variable
define BLOCK.DEFAULT as an integer variable

if DLG.PTR eq 0
    return
always

'' see which of the predefined actions was taken on the window
select case FIELD
  case "CLOSE"            '' window was closed
    let BLOCK.DEFAULT = 1    '' Dont terminate the application

    call MESSAGEBOX.R("Window was CLOSED", "Window event...")

  case "RESIZE"           '' window was resized
    let BLOCK.DEFAULT = 1    '' Dont redraw window contents on resize

  case "HSCROLL"           '' window was scrolled
      '' update fields in dialog to match those in window
    let DDVAL.A(DFIELD.F("HTHUMBPOS", DLG.PTR)) = 
        DDVAL.A(DFIELD.F("HTHUMBPOS", WIN.PTR))
    display DFIELD.F("HTHUMBPOS", DLG.PTR)

  case "VSCROLL"           '' window was scrolled
      '' update fields in dialog to match those in window
    let DDVAL.A(DFIELD.F("VTHUMBPOS", DLG.PTR)) = 
        DDVAL.A(DFIELD.F("VTHUMBPOS", WIN.PTR))
    display DFIELD.F("VTHUMBPOS", DLG.PTR)

  case "MOUSECLICK"
      '' update fields in dialog to match those in window
    let DDVAL.A(DFIELD.F("XCLICK", DLG.PTR)) = 
        DDVAL.A(DFIELD.F("XCLICK", WIN.PTR))
    let DDVAL.A(DFIELD.F("YCLICK", DLG.PTR)) = 
        DDVAL.A(DFIELD.F("YCLICK", WIN.PTR))
    let DDVAL.A(DFIELD.F("BUTTONDOWN", DLG.PTR)) = 
        DDVAL.A(DFIELD.F("BUTTONDOWN", WIN.PTR))
    let DDVAL.A(DFIELD.F("BUTTON", DLG.PTR)) = 
        DDVAL.A(DFIELD.F("BUTTON", WIN.PTR))
    let DDVAL.A(DFIELD.F("DOUBLECLICK", DLG.PTR)) = 
        DDVAL.A(DFIELD.F("DOUBLECLICK", WIN.PTR))
    display DFIELD.F("XCLICK", DLG.PTR)
    display DFIELD.F("YCLICK", DLG.PTR)
    display DFIELD.F("BUTTONDOWN", DLG.PTR)
    display DFIELD.F("BUTTON", DLG.PTR)
    display DFIELD.F("DOUBLECLICK", DLG.PTR)

  case "MOUSEMOVE"           '' mouse was moved in the window
      '' update fields in dialog to match those in window
    let DDVAL.A(DFIELD.F("XMOVE", DLG.PTR)) = 
        DDVAL.A(DFIELD.F("XMOVE", WIN.PTR))
    let DDVAL.A(DFIELD.F("YMOVE", DLG.PTR)) = 
        DDVAL.A(DFIELD.F("YMOVE", WIN.PTR))
    display DFIELD.F("XMOVE", DLG.PTR)
    display DFIELD.F("YMOVE", DLG.PTR)

endselect
return
end
