Last Modification: February 25, 2000

Is there a way to find out from, a controlbar, on which side of the parent frame it is docked?

First check whether the control bar is actually docked using IsFloating(). Then, If its docked, get the parent of the ControlBar which will be CDockBar (Undocumented) and check the ID of the given CDockBar. It should be one of 


AFX_IDW_DOCKBAR_TOP
AFX_IDW_DOCKBAR_BOTTOM
AFX_IDW_DOCKBAR_RIGHT
AFX_IDW_DOCKBAR_LEFT

These are defined in afxres.h. The following code will do that for you:


int GetDockPos (CControlBar * pBar)
{
   if (!pBar->IsFloating ()) 
   {
      int id = pBar->GetParent ()->GetDlgCtrlID (); 
      switch (id) 
      { 
      case AFX_IDW_DOCKBAR_TOP: 
          // AfxMessageBox ("AFX_IDW_DOCKBAR_TOP"); 
          break; 
      case AFX_IDW_DOCKBAR_BOTTOM: 
          // AfxMessageBox ("AFX_IDW_DOCKBAR_BOTTOM"); 
          break; 
      case AFX_IDW_DOCKBAR_RIGHT: 
          // AfxMessageBox ("AFX_IDW_DOCKBAR_RIGHT"); 
          break; 
      case AFX_IDW_DOCKBAR_LEFT: 
          // AfxMessageBox ("AFX_IDW_DOCKBAR_LEFT"); 
          break; 
      } 
      return id; 
   } 
   return -1; 
}