#Include once "window9.bi"

Function SetTextRebarGadget(ByVal gadget As Integer, ByVal index As Integer, byval text as string) As integer Export
  Dim As REBARBANDINFO rbBand
  rbBand.cbSize=sizeof(REBARBANDINFO)
  rbBand.fMask  = RBBIM_TEXT
  rbBand.lptext = cast(LPTSTR,StrPtr(text))
  rbBand.cch=len(text)
  Return SendMessage(GadgetID(gadget),RB_SETBANDINFO,cast(WPARAM,index),cast(LPARAM,@rbBand))
End Function

Function IDinIndexRebarGadget(ByVal gadget As Integer, ByVal ID As Integer) As integer Export
  Return SendMessage(GadgetID(gadget),RB_IDTOINDEX,ID,0)
End Function

Function MoveTabRebarGadget(ByVal gadget As Integer, ByVal IndexMove As Integer, byval IndexNew as Integer) As integer Export
  Function = SendMessage(GadgetID(gadget),RB_MOVEBAND,cast(WPARAM,IndexMove),cast(LPARAM,IndexNew))
  SendMessage (GadgetID(3), RB_SHOWBAND, cast(WPARAM,IndexNew), 1)
End Function

Function DeleteTabRebarGadget(ByVal gadget As Integer, ByVal Index As Integer) As integer Export
  If SendMessage(GadgetID(gadget),RB_GETBANDCOUNT,0, 0)=1 Then
    Dim As RECT RE
    RE.right=GadgetWidth(GADGET)
    re.bottom=SendMessage(GadgetID(gadget),RB_GETBARHEIGHT,0, 0)
    Function = SendMessage(GadgetID(gadget),RB_DELETEBAND,cast(WPARAM,Index),0)
    SendMessage (GadgetID(3), RB_SHOWBAND, 0, 1)
    InvalidateRect(GetParent(GadgetID(gadget)),@re,1)
  Else
    Function = SendMessage(GadgetID(gadget),RB_DELETEBAND,cast(WPARAM,Index),0)
    SendMessage (GadgetID(3), RB_SHOWBAND, 0, 1)
  EndIf
End Function
