[futurebasic] Re: Slider MDEF

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2001 : Group Archive : Group : All Groups

From: Ken Shmidheiser <k.shmidheiser@...>
Date: Thu, 11 Jan 2001 01:30:54 -0500
Osamu Shigematsu asked:

>I'm looking for an MDEF of slider like Sound Volume Control Strip.
>Is there anybody who had done that work?

Osamu,

In addition to Robert's suggestion, you could use Appearance 
Manager's built-in slider. One advantage is that it is compliant with 
Appearance Themes. Varying the height and width of the slider 
automatically determines if it will appear horizontal or vertical. 
Also, there are built-in variations in case you need tick marks or 
live scrolling.

Here is a quick sample of code that you may find useful.

Ken


Please adjust code for e-mail line breaks

'--------- BEGIN FB^3 CODE-----------

INCLUDE "Tlbx Appearance.Incl"

BEGIN GLOBALS
DIM gArrowValue
END GLOBALS

_arrowWnd = 10
_arrowBtn = 10
_arrowFld = 10
_arrowX = 90
_arrowY = 90

LOCAL FN initializeMenu
APPLE MENU "(Appearance Slider Bar Demo..."

MENU 1,0,_enable,"File"
MENU 1,1,_disable,"-"
MENU 1,2,_enable,"Quit/Q"

EDIT MENU 2
END FN

LOCAL FN init
DIM AS INTEGER a, x, y, x1, y1
DIM err          AS HANDLE
DIM wndPtr       AS POINTER
DIM arrowValueH  AS HANDLE
DIM AS STR255 value,intro1,intro2

WINDOW _arrowWnd,"Slider Control Demo",(0,0)-(200,200),_docNoGrow

intro1 = "Press command period,"
intro2 = "or close window to end."
EDIT FIELD 1,CHR$(13)+intro1+intro2,(20,20)-(180,65),_statFramed,_centerJust
wndPtr = WINDOW(_wndpointer)
err = FN 
SetThemeWindowBackground(wndPtr,_kThemeActiveDialogBackgroundBrush,_zTrue)

x = _arrowX
y = _arrowY

x1 = x + 18        'Moves button to right from TEXT BOX
y1 = y + 100       'Sets length of slider control
BUTTON _arrowBtn,_activeBtn,,(x,y)-(x1,y1),53 '<-- Adjust this 
control number to experiment

arrowValueH = BUTTON&(_arrowBtn)

LONG IF arrowValueH

CALL SETCTLMIN(arrowValueH, 0)
CALL SETCTLMAX(arrowValueH, 10)
a = FN GETCTLVALUE(arrowValueH)

x = _arrowX - 25
y = _arrowY + 5
x1 = x + 20
y1 = y + 15
gArrowValue = 10 - a
value = STR$(gArrowValue)

EDIT FIELD _arrowFld, value,(x,y)-(x1,y1), _statNoFramed
END IF
END FN

LOCAL FN doDialog
DIM AS INTEGER evnt, id, a
DIM value AS STR255
DIM arrowValueH AS HANDLE

evnt=DIALOG(0)
id=DIALOG(evnt)

SELECT CASE evnt

CASE _btnClick
arrowValueH = BUTTON&(_arrowBtn)
LONG IF arrowValueH
a = FN GETCTLVALUE(arrowValueH)
gArrowValue = 10 - a
value = STR$(gArrowValue)
EDIT$(_arrowFld) = value
END IF
CASE _wndClose
END
END SELECT

END FN

LOCAL FN doMenu
DIM AS INTEGER menuID, itemID
menuID = MENU(_menuID)
itemID = MENU(_itemID)
SELECT CASE menuID
CASE 1
SELECT itemID
CASE 1
CASE 2
END
END SELECT
END SELECT
MENU
END FN

LOCAL FN Quit
END
END FN

ON DIALOG FN doDialog
ON MENU FN doMenu
ON BREAK FN Quit

FN initializeMenu
FN init

DO
HANDLEEVENTS
UNTIL 0
END

'--------- END CODE-----------