Make your control bar from the following class derived from
TDockableControlBar (instead of TDockableControlBar itself):
class TMyToolbar : public TDockableControlBar
{
public:
TMyToolbar(TWindow* parent) : TDockableControlBar(parent) {}
void Hide()
{
GetHarbor()->Remove(*this);
}
void Show(THarbor* harbor)
{
harbor->Insert(*this, Location, &Rect.TopLeft());
harbor->Move(*this, Location, &Rect.TopLeft());
}
void SavePosition()
{
// get the absolute location of the toolbar
//
TDockingSlip* dockingSlip = TYPESAFE_DOWNCAST(Parent, TDockingSlip);
Location = (dockingSlip ? dockingSlip->GetLocation() : alTop);
// get the rectangle of the toolbar
//
TFloatingSlip* floatingSlip = TYPESAFE_DOWNCAST(Parent, TFloatingSlip);
if (floatingSlip) floatingSlip->GetWindowRect(Rect);
else GetRect(Rect);
}
TResult WindowProc(uint msg, TParam1 p1, TParam2 p2)
{
if (msg == WM_SHOWWINDOW && !p1) // we are being hidden
SavePosition();
return TDockableControlBar::WindowProc(msg, p1, p2);
}
protected:
TRect Rect;
TAbsLocation Location;
};