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 » Changing app from using a different toolbar implementation to Prof-UIS toolbars... Collapse All
Subject Author Date
Daisy Peterson Apr 25, 2008 - 10:15 PM

So we are in the process of updating our application to now use the Prof-UIS toolbars and docking windows.  We have toolbars and docking windows from a previous library we used, but have decided to change.


This previous library would, as yours does, save and load the state of toolbars if so desired.  I am in trying to load this old information in, set the data as appropriate in the new toolbars, and get things to at least closely approximate the locations where they were saved.  No customization is in place, this is strictly which toolbars are showing and where.


I get the data out of the old system’s file, and place all relevant information into a CControlBarInfo structure.  I update locations and rectangle sizes as needed to accomodate the new toolbar sizes with the current theme that is being used.  I utilize SetBarInfo to pass the information to the individual toolbars.  However, if I don’t also call CFrameWnd::DockControlBar with an appropriate rectangle, toolbars will always appear on their own rows.  Basically this equates to the following steps:



  1. Find out from the old file which dockbar we are dealing with.  The old file will tell me the IDs of the bars docked to this side.

  2. Find the bar info of the bars docked to this side that are visible.

  3. Adjust the m_pointPos and m_rectMRUDockPos as needed to accomodate new height and width of Prof-UIS version of toolbar.

  4. Call CControlBar::SetBarInfo, passing in the new information.

  5. Call CFrameWnd::DockControlBar with the appropriate dock bar ID and m_rectMRUDockPos (updated to screen coordinates).


The first set of data i load works beautifully.  Any subsequent loads, even loading the same information twice, results in the bars not going where they should.  If, for example, all bars are docked to the top, upon first load they are neatly placed next to one another.  Upon the second load of the saved data, their X coordinate is correct, but each bar is on its own row.



[.....][.....]   <-- First load of saved toolbar data and first use of the above sequence.


[.....]

       [.....]   <-- Second load of same data, second time through the above sequence.



Am I leaving something out?  Is there something extra I need to do?  If I debug through the sequence, the same coordinates are calculated every time through with the same data load...


 


Kevin Murray


AGI

Technical Support Apr 29, 2008 - 5:50 AM

Thank you for the interesting question. The control bar state in MFC is controlled by an array of CControlBarInfo objects. In Prof-UIS we follow a very similar approach. But Prof-UIS toolbars also support affixment coefficients called affixment weights and affixment shift values. The affixment parameters allow one toolbar to shift the position of another toolbar after drag-n-drop based redocking. So, the binary data format of serialized state of toolbars is not compatible between MFC and Prof-UIS. We suppose other libraries still does not provide this feature with persistence.

We think you can use more simplified state restoring. Here is the order of toolbars in the horizontal direction (which is used by top and bottom dock bars inside the main frame window):

[1][2][3][4][5]
[6][7][8][9]
And here is the order for vertical dock bars on left/right:
[1][6]
[2][7]
[3][8]
[4][9]
[5]
We suppose the real order of bars can contain any count of rows/columns, any bars can be hidden, any row/column contain any count of bars, and, finally, any row/column contain all its bars in hidden state.

Here is how the bars are ordered in the CDockBar::m_arrBars array and serialization sequence order. If you are able to load the array of bar identifiers and their screen rectangles in the order described above, then you can dock them using the CFrameWnd::DockControlBar() method by specifying the desired screen rectangle and invoking the CFrameWnd::RecalcLayout() method after docking each bar.