#include once "window9.bi"

Function TrackBarGadget(ByVal gadget As Long, _
						ByVal x As Long, ByVal y As Long, _
						ByVal w As Long, ByVal h As Long, _
						ByVal iMin As Integer, ByVal iMax As Integer, _
						ByVal Style As Integer) As HWND Export
	Var hWin = CreateWindowEx( 0, TRACKBAR_CLASS, "", WS_VISIBLE Or WS_CHILD Or Style, CInt(x),CInt(y),CInt(w),CInt(h), win9GetCurrent(), Cast(HMENU,CInt(gadget)), 0, 0 )
	SendMessage(hWin, TBM_SETRANGEMAX, 0, iMax)
	SendMessage(hWin, TBM_SETRANGEMin, 0, iMin)
	win9AddNewGadget(gadget,hWin)
    dim as hwnd hwParent = Cast(HWND,win9GetCurrent())
    for i as Long = 0 to 1000
        dim as USTRING sz = getclassname_(hwParent)
        if instr(sz , "CLASSCLASS_") andalso getparent(hwParent) = 0 then
            if getprop(hwParent , "tabstopenable") then
                win9AddTabStop(hwParent , gadget)
            EndIf
            exit for
        else
            hwParent = getparent(hwParent)
            if hwParent = 0 then exit for
        EndIf
    Next
	win9AddColor(hWin,15790320,0)
	Return hWin
End Function
