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.
Subject |
Author |
Date |
|
Kevin Murray
|
Jun 27, 2008 - 1:41 PM
|
So when last I asked about positioning toolbars in code after app startup, after they’ve been moved around, etc., based on a saved bit of data from an old, non-prof-uis system, you basically answered it would be really difficult to do. That remains true, but I’m getting closer, doing things I probably shouldn’t (or at least that you probably didn’t intend), and it works once or twice, but then my positioning code goes haywire again. And, of course, I’m being told to figure out how to make this work for backwards compatibility in our application. So, using the "Kill Bar" function found on this board, I have implemented the following: class CMyClass : public CExtCustomizeSite { ... void ReloadAllToolbars() { _EmptyContainers(); m_bInitComplete = false; m_pWndTop = NULL; // // loop through local toolbar list and remove them all using KillBar... // ... // reload the toolbars // EnableCustomization(...); } };
So, the first time I encounter settings that weren’t saved via Prof-UIS serialization system, I call the above, parse the data and start calling things like this:
CRect r; pPreviousBar->GetWindowRect( &r ); r.OffsetRect( 1, 0 ); m_pFrameWnd->DockControlBar( pBar, AFX_IDW_DOCKBAR_TOP, &r );
There’s a little more logic to interpret which bar goes where, but ultimately OffsetRect and DockControlBar are used as needed. After doing this, the toolbars are really durn close to being laid out the way the were in the old version of our application. Now after this, if you load a new settings file done through the Prof-UIS serialization again, the toolbars are now laid out fine as they were saved. All is fine. I then re-load the old version’s file, called my ReloadAllToolbars method again, do the docking logic again, and the toolbars don’t go where they should, with each getting it’s own row. Any help you can provide, even a different method than the above, would be greatly appreciated. I’m banging my head on the desk here... Kevin Murray AGI
|
|
Technical Support
|
Jun 30, 2008 - 1:10 PM
|
We believe the problem can really be caused by the r.top = 0; code. We also suspect that the difference between the first and next toolbar repositions can be related to the persistent affixment information which is stored inside each of Prof-UIS toolbars. This affixment information allows the toolbars to move each other after the user docks them into a new desired position inside the main frame window. Please invoke the pBar->_AffixmentSafeClearOuter(); code for each of toolbars before re-docking them.
|
|
Kevin Murray
|
Jun 30, 2008 - 6:10 PM
|
I tried the clear outer thing on just the current bar, the whole list of bars, current bar and last bar, to no avail. I also see the editor mangled my code. Here is the current state:
m_pFrameWnd->ShowControlBar( pBar, TRUE, TRUE );
if( pLastBar != NULL )
{
pLastBar->_AffixmentSafeClearOuter();
pBar->_AffixmentSafeClearOuter();
CRect r;
pLastBar->GetWindowRect( &r );
pBar->_CalcSize( !bHorz );
if( bHorz == TRUE )
{
if( pt.y == ptLast.y )
{
r.OffsetRect( 10, 0 );
}
else
{
r.OffsetRect( 0, 10 );
r.left = 0;
}
} // end if pInfo->m_bHorz
else
{
if( pt.x == ptLast.x )
{
r.OffsetRect( 0, 10 );
}
else
{
r.OffsetRect( 10, 0 );
r.top = 0;
}
} // end else (pInfo->m_bHorz == FALSE)
m_pFrameWnd->DockControlBar( pBar, iBarId, &r );
} // end if pLastBar
else
{
m_pFrameWnd->DockControlBar( pBar, iBarId );
}
pLastBar = pBar;
ptLast = pt;
m_pFrameWnd->RecalcLayout();
Hopefully easier to follow. The first time through, I get something like this:
[menu]
[toolbar1] [toolbar2] [toolbar3]
[toolbar4] [toolbar5] [toolbar6]
The second time through destroying and recreating the bars, then going through that same code loop above, I get something like this:
[menu]
[toolbar1] [toolbar2] [toolbar3]
[toolbar4]
[toolbar5]
[toolbar6]
|
|
Technical Support
|
Jul 1, 2008 - 12:49 PM
|
We believe the problem can be hidden in something very simple. For instance, it’s not recommended to compare variables with TRUE or true . Please use comparision with FALSE or false instead. Please also put the TRACE code into the code snippet in your message and take a look at the rectangles specified in the invocations of the DockControlBar() method. Please also insert some tracing of details like beginning new rows of bars. If the pLastBar pointer is NULL , then the pBar bar is docked without clearing its affixment.
|
|
Kevin Murray
|
Jul 1, 2008 - 1:15 PM
|
First run traces:
AFX_IDW_DOCKBAR_TOP
=====================
pLastBar’s (id = 6577) Window Rect = (6, 54) - (482, 80)
pBar’s (id = 4410) Offest Rect = (16, 54) - (492, 80)
pBar’s (id = 4410) Rect After DockControlBar = (16, 54) - (492, 80)
pLastBar’s (id = 4410) Window Rect = (482, 54) - (600, 80)
pBar’s (id = 4027) Offest Rect = (492, 54) - (610, 80)
pBar’s (id = 4027) Rect After DockControlBar = (492, 54) - (610, 80)
pLastBar’s (id = 4027) Window Rect = (600, 54) - (877, 80)
pBar’s (id = 4037) Offest Rect = (0, 64) - (877, 90)
pBar’s (id = 4037) Rect After DockControlBar = (0, 64) - (877, 90)
pLastBar’s (id = 4037) Window Rect = (6, 80) - (264, 106)
pBar’s (id = 205) Offest Rect = (16, 80) - (274, 106)
pBar’s (id = 205) Rect After DockControlBar = (16, 80) - (274, 106)
pLastBar’s (id = 205) Window Rect = (264, 80) - (429, 106)
pBar’s (id = 6612) Offest Rect = (0, 90) - (429, 116)
pBar’s (id = 6612) Rect After DockControlBar = (0, 90) - (429, 116)
pLastBar’s (id = 6612) Window Rect = (6, 106) - (246, 132)
pBar’s (id = 4053) Offest Rect = (16, 106) - (256, 132)
pBar’s (id = 4053) Rect After DockControlBar = (16, 106) - (256, 132)
AFX_IDW_DOCKBAR_LEFT
======================
The thread ’Win32 Thread’ (0x1754) has exited with code 0 (0x0).
pLastBar’s (id = 3990) Window Rect = (6, 132) - (33, 250)
pBar’s (id = 4020) Offest Rect = (0, 142) - (33, 260)
pBar’s (id = 4020) Rect After DockControlBar = (0, 142) - (33, 260)
Reload a Prof-UIS save, load above old set a second time:
AFX_IDW_DOCKBAR_TOP
=====================
pLastBar’s (id = 6577) Window Rect = (6, 54) - (482, 80)
pBar’s (id = 4410) Offest Rect = (16, 54) - (492, 80)
pBar’s (id = 4410) Rect After DockControlBar = (16, 54) - (492, 80)
pLastBar’s (id = 4410) Window Rect = (482, 54) - (600, 80)
pBar’s (id = 4027) Offest Rect = (492, 54) - (610, 80)
pBar’s (id = 4027) Rect After DockControlBar = (492, 54) - (610, 80)
pLastBar’s (id = 4027) Window Rect = (600, 54) - (877, 80)
pBar’s (id = 4037) Offest Rect = (0, 64) - (877, 90)
pBar’s (id = 4037) Rect After DockControlBar = (0, 64) - (877, 90)
pLastBar’s (id = 4037) Window Rect = (6, 80) - (264, 106)
pBar’s (id = 205) Offest Rect = (16, 80) - (274, 106)
pBar’s (id = 205) Rect After DockControlBar = (16, 80) - (274, 106)
pLastBar’s (id = 205) Window Rect = (16, 106) - (181, 132)
pBar’s (id = 6612) Offest Rect = (0, 116) - (181, 142)
pBar’s (id = 6612) Rect After DockControlBar = (0, 116) - (181, 142)
pLastBar’s (id = 6612) Window Rect = (6, 132) - (246, 158)
pBar’s (id = 4053) Offest Rect = (16, 132) - (256, 158)
pBar’s (id = 4053) Rect After DockControlBar = (16, 132) - (256, 158)
AFX_IDW_DOCKBAR_LEFT
======================
pLastBar’s (id = 3990) Window Rect = (6, 184) - (33, 302)
pBar’s (id = 4020) Offest Rect = (0, 194) - (33, 312)
pBar’s (id = 4020) Rect After DockControlBar = (0, 194) - (33, 312)
As you can see, in the second instance, the rect is calculated OK, but when GetWindowRect is called for it, the bar with id 205 isn’t on y value 80 anymore, but y value 106. I did add in the affixment clear after the NULL condition.
|
|
Technical Support
|
Jul 2, 2008 - 11:26 AM
|
Please try invoking pBar->MoveWindow( 0, 0, 0, 0, FALSE ); before each invocation of DockControlBar( ... ); . We suspect the bars are created with some large window rectangles and this affects row positions. If this does not help, we can connect to your computer remotely and try to find out what’s wrong.
|
|
Kevin Murray
|
Jul 2, 2008 - 12:29 PM
|
MoveWindow had no effect. My IS team tells me we can probably set up a Remote Assistance session or something similar. I’ll be out of the office tomorrow (July 3) through Monday, back on Tuesday (July 8). Feel free to email me details and I’ll see what we can get set up. Thanks, Kevin Murray
|
|
Technical Support
|
Jul 7, 2008 - 12:44 PM
|
We are sorry for the delay with this reply. Please tell us (via email) when and how we can connect to your desktop.
|
|
Technical Support
|
Jun 30, 2008 - 5:18 AM
|
Before answering, we would like to ask one important question: Do you invoke RecalcLayout() after processing each bar with ...OffsetRect() ... DockControlBar() ?
|
|
Kevin Murray
|
Jun 30, 2008 - 9:46 AM
|
Yes, I call: m_pFrameWind->ShowControlBar( pBar, TRUE, TRUE ); m_pFrameWnd->RecalcLayout();
Specifically, the loop I go through does this for each dock bar:
// ...retrieve data from file with (x, y) and whether horizontal or vertical // (x,y) in CPoint pt; horizontal in BOOL bHorz; // pBar and pLastBar are CExtToolControlBars m_pFrameWnd->ShowControlBar( pBar, TRUE, TRUE ); { CRect r; pLastBar->GetWindowRect( &r ); pBar->_CalcSize( !bHorz ); { { r.OffsetRect( 10, 0 ); } if( pLastBar != NULL ) if( bHorz == TRUE ) if( pt.y == ptLast.y ) else{ r.OffsetRect( 0, 10 ); r.left = 0; } } // end if pInfo->m_bHorz else{ { r.OffsetRect( 0, 10 ); } if( pt.x == ptLast.x ) else{ r.OffsetRect( 10, 0 ); r.top = 0; } } // end else (pInfo->m_bHorz == FALSE)m_pFrameWnd->DockControlBar( pBar, iBarId ); } pLastBar = pBar; ptLast = pt; m_pFrameWnd->RecalcLayout();
I use 10 for my offset value because I found if I use 1, putting the bar on a new row/column doesn’t always work. And, again, this works the first time I reset the toolbars, but not after that.
K.
|
|