How to save and restore the position of TCoolBar bands (Views: 300)
Problem/Question/Abstract: I can save the TToolbar positions but I never succeed in restoring their positions. I put them in either in TControlBar or TCoolBar. How do I position them correctly? Answer: Saving: {Coolbar} for i := 0 to Coolbar.Bands.Count - 1 do with Coolbar.Bands[i] do seOptions['Band' + IntToStr(ID)] := Format('%d,%d,%d,%d', [Integer(Break), Width, Index, Integer(Control.Visible)]); Loading: {Coolbar} for i := 0 to Coolbar.Bands.Count - 1 do with Coolbar.Bands[i] do begin BandInfo := seOptions['Band' + IntToStr(ID)]; if BandInfo <> '' then try Break := Boolean(StrToInt(CutFirst(BandInfo))); Width := StrToInt(CutFirst(BandInfo)); Index := StrToInt(CutFirst(BandInfo)); Control.Visible := Boolean(StrToInt(CutFirst(BandInfo))); {this line untested} except; end; end; seOptions is a settings object and can store values 'by name'. BandInfo is a string. CutFirst returns the first value from a comma separated list string and removes it from the string. |