;Autor: Green Snake EnableExplicit Interface RebarControl Release.i () GetHandle.i () GetParentHandle.i () AddControl.i (hControl.i, text.s, minWidth.i = -1, minHeight.i = -1, newLine.i = #False) DeleteBand.i (band.i) ShowBand.i (band.i, show.i) Resize.i () GetHeight.i () EndInterface Structure cRebarControl *VTable hParent.i hRebar.i EndStructure Define *RebarControl.RebarControl Define Button.i Define String.i Define HyperLink.i Define EventID ProcedureDLL.i RebarControl_CreateObject(hParent.i) Protected *This.cRebarControl Protected rebarInfo.REBARINFO Protected rebarBand.REBARBANDINFO Protected rect.RECT Protected commonControlsEx.INITCOMMONCONTROLSEX If Not hParent ProcedureReturn #False EndIf *This = AllocateMemory(SizeOf(cRebarControl)) If Not *This ProcedureReturn #False Else *This\VTable = ?Label_RebarControl_Methods commonControlsEx\dwSize = SizeOf(INITCOMMONCONTROLSEX) commonControlsEx\dwICC = #ICC_COOL_CLASSES | #ICC_BAR_CLASSES InitCommonControlsEx_(@commonControlsEx) *This\hParent = hParent *This\hRebar = CreateWindowEx_(#WS_EX_TOOLWINDOW, "RebarWindow32", #Null, #WS_CHILD | #WS_VISIBLE | #WS_CLIPSIBLINGS | #WS_CLIPCHILDREN | #RBS_VARHEIGHT | #CCS_NODIVIDER | #RBS_AUTOSIZE, 0, 0, 0, 0, hParent, #Null, GetModuleHandle_(0), #Null) If Not *This\hRebar FreeMemory(*This) ProcedureReturn #False EndIf rebarInfo\cbSize = SizeOf(REBARINFO) rebarInfo\fMask = 0 rebarInfo\himl = #Null SendMessage_(*This\hRebar, #RB_SETBARINFO, 0, @rebarInfo) ProcedureReturn *This EndIf ProcedureReturn #False EndProcedure Procedure.i RebarControl_Release(*This.cRebarControl) DestroyWindow_(*This\hRebar) ProcedureReturn FreeMemory(*This) EndProcedure Procedure.i RebarControl_GetHandle (*ThisObject.RebarControl) Protected *This.cRebarControl = *ThisObject ProcedureReturn *This\hRebar EndProcedure Procedure.i RebarControl_GetParentHandle (*ThisObject.RebarControl) Protected *This.cRebarControl = *ThisObject ProcedureReturn *This\hParent EndProcedure Procedure.i RebarControl_AddControl (*ThisObject.RebarControl, hControl.i, text.s, minWidth.i = -1, minHeight.i = -1, newLine.i = #False) Protected *This.cRebarControl = *ThisObject Protected rebarBand.REBARBANDINFO Protected rect.RECT GetWindowRect_(hControl,@rect) If minWidth < 0 minWidth = rect\right - rect\left EndIf If minHeight < 0 minHeight = rect\bottom - rect\top EndIf rebarBand\cbSize = SizeOf(REBARBANDINFO) rebarBand\fMask = #RBBIM_COLORS | #RBBIM_CHILDSIZE | #RBBIM_SIZE | #RBBIM_TEXT | #RBBIM_STYLE | #RBBIM_CHILD If Not newLine rebarBand\fStyle = #RBBS_CHILDEDGE Else rebarBand\fStyle = #RBBS_CHILDEDGE | #RBBS_BREAK EndIf rebarBand\lpText = @text rebarBand\hWndChild = hControl rebarBand\cxMinChild = minWidth rebarBand\cyMinChild = minHeight rebarBand\clrBack = GetSysColor_(#COLOR_BTNFACE) rebarBand\clrFore = GetSysColor_(#COLOR_BTNTEXT) ProcedureReturn SendMessage_(*This\hRebar, #RB_INSERTBAND, -1, @rebarBand) EndProcedure Procedure.i RebarControl_DeleteBand (*ThisObject.RebarControl, band.i) Protected *This.cRebarControl = *ThisObject Protected rebarBand.REBARBANDINFO Protected rect.RECT ProcedureReturn SendMessage_(*This\hRebar, #RB_DELETEBAND, band, 0) EndProcedure Procedure.i RebarControl_ShowBand (*ThisObject.RebarControl, band.i, show.i) Protected *This.cRebarControl = *ThisObject ProcedureReturn SendMessage_(*This\hRebar, #RB_SHOWBAND, band, show) EndProcedure Procedure.i RebarControl_Resize (*ThisObject.RebarControl) Protected *This.cRebarControl = *ThisObject SendMessage_(*This\hRebar, #WM_SIZE, 0, 0) ProcedureReturn #True EndProcedure Procedure.i RebarControl_GetHeight (*ThisObject.RebarControl) Protected *This.cRebarControl = *ThisObject ProcedureReturn SendMessage_(*This\hRebar, #RB_GETBARHEIGHT, 0, 0) EndProcedure If OpenWindow(0,0,0,500,250,"Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible) *RebarControl.RebarControl = RebarControl_CreateObject(WindowID(0)) Button = ButtonGadget(#PB_Any, 0, 0, 100, 20, "Hallo Welt") String = StringGadget(#PB_Any, 0, 0, 100, 20, "PureBasic") HyperLink = HyperLinkGadget(#PB_Any, 0, 0, 100, 15, "Lounge", $FF) *RebarControl\AddControl(GadgetID(Button), "") *RebarControl\AddControl(GadgetID(String), "Demo Text") *RebarControl\AddControl(GadgetID(HyperLink), "Hyper-Link", -1, -1, #True) SmartWindowRefresh(0, 1) HideWindow(0, #False) Repeat EventID=WaitWindowEvent() If EventID=#PB_Event_SizeWindow *RebarControl\Resize() EndIf Until EventID = #PB_Event_CloseWindow EndIf *RebarControl\Release() : *RebarControl = #Null DataSection Label_RebarControl_Methods: Data.i @RebarControl_Release () Data.i @RebarControl_GetHandle () Data.i @RebarControl_GetParentHandle () Data.i @RebarControl_AddControl () Data.i @RebarControl_DeleteBand () Data.i @RebarControl_ShowBand () Data.i @RebarControl_Resize () Data.i @RebarControl_GetHeight () EndDataSection