[MFC] Cum aflam unde e docat un control-bar?

Despre MFC, ATL si alte biblioteci C++ de la Microsoft (forum moderat)
Post Reply
User avatar
Ovidiu Cucu
Fondator
Fondator
Posts: 3778
Joined: 11 Jul 2007, 16:10
Judet: Iaşi
Location: Iasi
Contact:

[MFC] Cum aflam unde e docat un control-bar?

Post by Ovidiu Cucu » 28 Jul 2011, 21:55

Intrebare
Cum aflam in care parte a frame-ului este docat un control-bar (CToolBar, CStatusBar, CDialogBar, CReBar, sau COleResizeBar)?

Raspuns
Cu functia CControlBar::IsFloating aflam daca este docat sau nu. Daca da, chemam CControlBar::GetBarStyle.
Flag-urile care dau partea frame-ului sunt CBRS_ALIGN_LEFT, CBRS_ALIGN_TOP, CBRS_ALIGN_RIGHT si CBRS_ALIGN_BOTTOM.

Exemplu

Code: Select all

class CAppToolBar : public CToolBar
{
// ...
public:
   enum e_DockState {eFloating, eLeftDoked, eTopDocked, eRightDocked, eBottomDocked};
   e_DockState GetDockState();
// ...
};

Code: Select all

CAppToolBar::e_DockState CAppToolBar::GetDockState()
{
   e_DockState eDockState = eFloating;
   if(! IsFloating())
   {
      switch(CBRS_ALIGN_ANY & GetBarStyle())
      {
      case CBRS_ALIGN_LEFT:
         eDockState = eLeftDoked;
         break;
      case CBRS_ALIGN_TOP:
         eDockState = eTopDocked;
         break;
      case CBRS_ALIGN_RIGHT:
         eDockState = eRightDocked;
         break;
      case CBRS_ALIGN_BOTTOM:
         eDockState = eBottomDocked;
         break;
      default:
         ASSERT(FALSE); // unknown state
      }
   }
   return eDockState;
}
<< Back to MFC index



Post Reply