#include once "window9.bi"

Function ListBoxGadget(ByVal gadget As Long, _
						ByVal x As long, ByVal y As Long, _
						ByVal w As Long, ByVal h As long, _
						ByVal Style As Long, _
						ByVal ExStyle As long) As HWND Export
	Var hWin = CreateWindowEx(ExStyle, "ListBox", "", WS_CHILD Or WS_VISIBLE or LBS_NOINTEGRALHEIGHT Or Style ,x,y,w,h, win9GetCurrent(),Cast(HMENU,CInt(gadget)),0,0)
	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,GetSysColor(COLOR_WINDOW),GetSysColor(COLOR_WINDOWTEXT))
	If win9GetGadgetFont()<>0 Then SendMessage(hWin,WM_SETFONT,win9GetGadgetFont(),0)
	Return hWin
End Function
