Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Relatively positioning docking bars Collapse All
Subject Author Date
Andrew Harding Jan 18, 2006 - 9:20 AM

This is the second time I’m tyring to post this so sorry if there are duplicates, the message board seems to be experiencing some difficulty.


How do I programmatically dock one window a specified direction relative to another docking bar.  IE: When dragging a docking bar using the CExtPaintManagerStudio2005 you see 2 sets of targets appear, the inner one docks a window relative to the window you’re hovering over and the outer targets dock relative to the docking frame.  I’ve figured out how to dock relative to the CFrameWnd but I’m not sure how to programmatically reproduce the effect generated by the inner target set.


I would like to be able to detect how a CExtControlBar is docked whether it be relative to the frame or to another docking bar, and what direction it is docked IE: AFX_IDW_DOCKBAR_LEFT.


I have tried docking windows and then querying them using the following functions to see if I could do this on my own but it appeared that the functions were either not working or I was misinterpreting them, only the IsDocked or IsFloating functions seemed to give me believable results.


bool IsDocked() const;
bool IsFloating() const;
bool IsDockedAtTop() const;
bool IsDockedAtBottom() const;
bool IsDockedAtLeft() const;
bool IsDockedAtRight() const;
bool IsDockedHorizontally() const;
bool IsDockedVertically() const;


I need to be able to do this both with docking bars that are already docked and bars that are docked for the first time, if it makes a difference in how it’s done then I’ll also need to know how to detect which case I’m dealing with.

Technical Support Jan 18, 2006 - 12:33 PM

The following method of the of the CExtControlBar class docks the resizable control bar relative to the sides of the main frame window:

 
virtual bool DockControlBarInnerOuter(
   UINT nDockBarID,
   bool bInner,
   CFrameWnd * pDockSite = NULL, // can be NULL only if bar already was at least once docked
   bool bRecalcLayout = true
);
The newly docked bar will occupy the entire row/column at the side of the main frame window specified by the nDockBarID parameter which can be AFX_IDW_DOCKBAR_TOP, AFX_IDW_DOCKBAR_BOTTOM, AFX_IDW_DOCKBAR_LEFT, or AFX_IDW_DOCKBAR_RIGHT. The bInner flag indicates where the newly docked resizable control bar should appear relative to the already docked bars. The pDockSite parameter is a pointer to the main frame window.

The following two methods of the of the CExtControlBar class dock the resizable control bar relative to an already docked bar:
bool DockControlBarLTRB(
   CExtControlBar * pBarTarget,
   UINT nDockBarID = AFX_IDW_DOCKBAR_BOTTOM,
   bool bRecalcLayout = true
);
virtual bool DockControlBarLTRB(
   int nPercentToOccupy, // greater then zero and less than one hundred
   CExtControlBar * pBarTarget,
   UINT nDockBarID = AFX_IDW_DOCKBAR_BOTTOM,
   bool bRecalcLayout = true
);
The nDockBarID parameter specifies the side of the already docked bar to occupy by the bar being docked (values are the same as described above). The nPercentToOccupy value specifies the percent of space to occupy. The first method assumes 50%.

You can also detect the exact location of any bar. This is based on analyzing the run-time classes of the windows in the chain of resizable bar’s parents up to the main frame window or floating mini frame window. There are two types of compound bar containers: tabbed groups (the CExtDynTabControlBar window with the CExtDockDynTabBar container for other bars inside) and linear groups (the CExtDynControlBar window with the CExtDockDynBar container for other bars inside) for organizing columns of bars inside rows of bars and vice versa. The main rule for re-dockable bars is: the parent of the CControlBar window is the CDockBar window. The main frame window contains an array of the CExtDockBar dock bars which are containers for all the Prof-UIS bars. Four outer CExtDockOuterBar dock bars are designed especially for toolbars and other fixed size bars. All the other inner dock bar circles with four CExtDockBar dock bars in each are created dynamically and used for resizable control bars only. The CExtDockBar contains a set of the CExtControlBar windows. Some of the CExtControlBar windows can be the CExtDynTabControlBar windows if they are tab groups or the CExtDynControlBar windows if they are linear containers. Both tabbed and linear container are used as a parent window for one inner dock bar window that is parent for nested CExtControlBar windows and so on. Each dock bar window has the m_arrBars array of child control bars. This array allows you to detect the order and location of each bar.

Andrew Harding Jan 23, 2006 - 9:51 AM

Thank you.  If I want to determine which direction a window is docked relative to it’s parent is there a function I can call or do I need to try to guess based on the windows extents?  As I had mentioned I had tried playing around with the


bool IsDockedAtTop() const;
bool IsDockedAtBottom() const;
bool IsDockedAtLeft() const;
bool IsDockedAtRight() const;
bool IsDockedHorizontally() const;
bool IsDockedVertically() const;


functions but they didn’t seem to work.

Technical Support Jan 26, 2006 - 10:53 AM

The listed methods of the CExtControlBar class do not relate to what you are doing. The first four methods detect the side of the main frame window where the bar is located. The last two methods detect the type of the next linear container bar container which can be a column of bars or a row of bars. That is very close to your questions but the bars can be organized into a row of bars inside a column of bars and vice versa.

As we mentioned before, you need to get pointers to the bar’s parent windows and analyze their MFC’s run time type information. At present, this is the single way to find out exactly where the bar is. Unfortunately we have no ready to use API for this task. It is possible to code methods for detecting mutual positions of two bars relatively to each other. But the number of possible combinations can large enough and your app users will not need to think about the bar’s mutual locations and detailed description of the docked states.