#include once "window9.bi"

Sub SetTextRebarGadget(ByVal gadget As Long, ByVal index As Integer, byval text as USTRING) Export
	Dim As REBARBANDINFO rbBand
	rbBand.cbSize=sizeof(REBARBANDINFO)
	rbBand.fMask  = RBBIM_TEXT
	#ifdef UNICODE
		rbBand.lptext = cast(LPTSTR,*text)
	#else	
		rbBand.lptext = cast(LPTSTR,StrPtr(text))
	#EndIf	
	rbBand.cch=len(text)
	SendMessage(GadgetID(gadget),RB_SETBANDINFO,cast(WPARAM,index),cast(LPARAM,@rbBand))
End Sub

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

Function MoveTabRebarGadget(ByVal gadget As Long, 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(gadget), RB_SHOWBAND, cast(WPARAM,IndexNew), 1)
End Function

Sub DeleteTabRebarGadget(ByVal gadget As long, ByVal Index As long) 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)
		SendMessage(GadgetID(gadget),RB_DELETEBAND,cast(WPARAM,CInt(Index)),0)
		SendMessage (GadgetID(gadget), RB_SHOWBAND, 0, 1)
		InvalidateRect(GetParent(GadgetID(gadget)),@re,1)
	Else
		SendMessage(GadgetID(gadget),RB_DELETEBAND,cast(WPARAM,CInt(Index)),0)
		SendMessage (GadgetID(gadget), RB_SHOWBAND, 0, 1)
	EndIf
End Sub
