Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - auto shrink the CXTPControlCombox
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

auto shrink the CXTPControlCombox

 Post Reply Post Reply
Author
Message
blueseaing View Drop Down
Groupie
Groupie


Joined: 14 June 2004
Status: Offline
Points: 42
Post Options Post Options   Thanks (0) Thanks(0)   Quote blueseaing Quote  Post ReplyReply Direct Link To This Post Topic: auto shrink the CXTPControlCombox
    Posted: 01 July 2005 at 3:29am
    When a CXtpControlCombox set xtpFlagStretched flag, it will fill the toolbar, but when I try to drag another toolbar to the row of the stretched toolbar, I can't. How to auto shrink the CXtpControlCombox size before drag the toolbar?
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 03 July 2005 at 11:29pm

Hi,

in 9.70 was added xtpFlagStretchedShared,

use it instead xtpFlagStretched for your toolbar

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
blueseaing View Drop Down
Groupie
Groupie


Joined: 14 June 2004
Status: Offline
Points: 42
Post Options Post Options   Thanks (0) Thanks(0)   Quote blueseaing Quote  Post ReplyReply Direct Link To This Post Posted: 04 July 2005 at 5:37am
but my version is 9.6, can you give me a hot fix to support  the xtpFlagStretchedShared flag, my project is so hopeful for the feature. Thanks a lot.
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 05 July 2005 at 5:54am

Hi, try to patch yourself:

1. add

xtpFlagStretchedShared = 0x100000 // Bar is stretched, but not fill whole row

2. Replace this member:

int CXTPDockBar::_AdjustRow(CToolBarArray& arrRow, CPoint pt, int nLength, BOOL bHorz, AFX_SIZEPARENTPARAMS* lpLayout, int& nRemove)

{

CXTPDockInfoArray arrInfo;

int nPos;

// Step 1. Getting maximum available size;

for (nPos = 0; nPos < arrRow.GetSize(); nPos++)

{

CXTPToolBar* pBar = arrRow[nPos];

CSize sizeBar = pBar->CalcDockingLayout(nLength, _GetMode(bHorz, pBar));

CPoint p = bHorz? CPoint(pBar->m_pDockContext->m_rectMRUDockPos.left, pt.y):

CPoint(pt.x, pBar->m_pDockContext->m_rectMRUDockPos.top);

XTP_DOCK_INFO dockInfo(pBar, CRect(p, sizeBar), nPos);

arrInfo.Add(dockInfo);

}

ASSERT(arrInfo.GetSize() == arrRow.GetSize());

if (!bHorz) arrInfo.InvertRects();

arrInfo.Sort();

// Step 2. if Total length is more than available, fill empty area.

int nIndex = -1;

int nLen = 0; BOOL bMove = TRUE;

for (nPos = 0; nPos < arrInfo.GetSize(); nPos++ )

{

CRect& rect = arrInfo[nPos].rcBar;

bMove = (rect.left < nLen && (nIndex < arrInfo[nPos].nIndex || bMove));

if (bMove) rect.OffsetRect(nLen - rect.left, 0);

nLen = rect.right;

nIndex = arrInfo[nPos].nIndex;

}

nLen = nLength; nIndex = -1; bMove = TRUE;

for (nPos = (int)arrInfo.GetSize() - 1; nPos >= 0; nPos--)

{

CRect& rect = arrInfo[nPos].rcBar;

bMove = (rect.right - nLen > 0 && (nIndex < arrInfo[nPos].nIndex || bMove));

if (bMove) rect.OffsetRect(nLen - rect.right, 0);

nLen = rect.left;

nIndex = arrInfo[nPos].nIndex;

}

nLen = 0;

for (nPos = 0; nPos < arrInfo.GetSize(); nPos++ )

{

CRect& rect = arrInfo[nPos].rcBar;

if (rect.left < nLen)

rect.OffsetRect(nLen - rect.left, 0);

nLen = rect.left + rect.Width();

}

// Step 3. if Total length is more than available, make it expandable.

if (nLen > nLength)

{

int nSum = 0;

for (nPos = 0; nPos < arrInfo.GetSize(); nPos++ )

{

CXTPToolBar* pBar = arrInfo[nPos].pBar;

if (!(_GetMode(bHorz, pBar) & LM_HIDEWRAP))

arrInfo[nPos].nMinWidth = nLength;

else

{

CSize sz = pBar->CalcDockingLayout(1, _GetMode(bHorz, pBar));

arrInfo[nPos].nMinWidth = bHorz? sz.cx: sz.cy;

}

arrInfo[nPos].nTotlaMinWidth = nSum;

nSum += arrInfo[nPos].nMinWidth;

}

int nLen = nLength;

for (nPos = (int)arrInfo.GetSize() - 1; nPos >= 0; nPos--)

{

CRect& rect = arrInfo[nPos].rcBar;

int nLeft = bHorz? arrInfo[nPos].rcMRUPos.left: arrInfo[nPos].rcMRUPos.top;

if (nLeft >rect.left) nLeft = rect.left;

if (nLeft < nLen - rect.Width()) nLeft = nLen - rect.Width();

if (nLeft < arrInfo[nPos].nTotlaMinWidth) nLeft = arrInfo[nPos].nTotlaMinWidth;

if (nLen - nLeft < arrInfo[nPos].nMinWidth) nLeft = nLen - arrInfo[nPos].nMinWidth;

if ((nLen - nLeft < arrInfo[nPos].nMinWidth || nLeft < arrInfo[nPos].nTotlaMinWidth)

&& arrInfo.GetSize() != 1)

{

nRemove = arrInfo[arrInfo.GetSize() - 1].nIndex;

return 0;

}

rect.right = nLen;

nLen = rect.left = max(0, nLeft);

}

}

if (!bHorz) arrInfo.InvertRects();

 

int nWidth = 0;

// Calculate total width

for (nPos = 0; nPos < arrInfo.GetSize(); nPos++)

{

CXTPToolBar* pBar = arrInfo[nPos].pBar;

CRect& rect = arrInfo[nPos].rcBar;

CSize sizeBar = pBar->CalcDockingLayout(bHorz? rect.Width(): rect.Height(), _GetMode(bHorz, pBar));

nWidth = max(nWidth, bHorz? sizeBar.cy: sizeBar.cx);

}

// Step 4. Move it.

for (nPos = 0; nPos < arrInfo.GetSize(); nPos++)

{

CXTPToolBar* pBar = arrInfo[nPos].pBar;

CRect& rect = arrInfo[nPos].rcBar;

int nMode = _GetMode(bHorz, pBar) | LM_COMMIT;

if (pBar->GetFlags() & xtpFlagStretchedShared)

{

if (bHorz)

{

rect.right = nPos == arrInfo.GetSize() - 1? nLength: arrInfo[nPos + 1].rcBar.left;

rect.left = nPos == 0? 0: min(arrInfo[nPos - 1].rcBar.right, rect.left);

}

else

{

rect.bottom = nPos == arrInfo.GetSize() - 1? nLength: arrInfo[nPos + 1].rcBar.top;

rect.top = nPos == 0? 0: min(arrInfo[nPos - 1].rcBar.bottom, rect.top);

}

nMode |= LM_STRETCH;

}

CSize sz = pBar->CalcDockingLayout(bHorz? rect.Width(): rect.Height(), nMode, nWidth );

rect = CRect(rect.TopLeft(), sz);

pBar->m_pDockContext->m_uMRUDockPosition= GetPosition();

AfxRepositionWindow(lpLayout, pBar->m_hWnd, &rect);

pBar->Invalidate(FALSE);

}

return nWidth;

}

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
blueseaing View Drop Down
Groupie
Groupie


Joined: 14 June 2004
Status: Offline
Points: 42
Post Options Post Options   Thanks (0) Thanks(0)   Quote blueseaing Quote  Post ReplyReply Direct Link To This Post Posted: 05 July 2005 at 6:39am

It work, Thanks very much for your help.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.

This page was generated in 0.375 seconds.