-
September 13th, 2013, 06:24 AM
#16
Re: [RESOLVED] Creating DialogBar with my own controls (MFC)
Dear VictorN,
Code:
LRESULT CControlBar::OnSizeParent(WPARAM, LPARAM lParam)
{
AFX_SIZEPARENTPARAMS* lpLayout = (AFX_SIZEPARENTPARAMS*)lParam;
DWORD dwStyle = RecalcDelayShow(lpLayout);
if ((dwStyle & WS_VISIBLE) && (dwStyle & CBRS_ALIGN_ANY) != 0)
{
// align the control bar
CRect rect;
rect.CopyRect(&lpLayout->rect);
CSize sizeAvail = rect.Size(); // maximum size available
// get maximum requested size
DWORD dwMode = lpLayout->bStretch ? LM_STRETCH : 0;
if ((m_dwStyle & CBRS_SIZE_DYNAMIC) && m_dwStyle & CBRS_FLOATING)
dwMode |= LM_HORZ | LM_MRUWIDTH;
else if (dwStyle & CBRS_ORIENT_HORZ)
dwMode |= LM_HORZ | LM_HORZDOCK;
else
dwMode |= LM_VERTDOCK;
CSize size = CalcDynamicLayout(-1, dwMode);
size.cx = min(size.cx, sizeAvail.cx);
size.cy = min(size.cy, sizeAvail.cy);
if (dwStyle & CBRS_ORIENT_HORZ)
{
lpLayout->sizeTotal.cy += size.cy;
lpLayout->sizeTotal.cx = max(lpLayout->sizeTotal.cx, size.cx);
if (dwStyle & CBRS_ALIGN_TOP)
lpLayout->rect.top += size.cy;
else if (dwStyle & CBRS_ALIGN_BOTTOM)
{
rect.top = rect.bottom - size.cy;
lpLayout->rect.bottom -= size.cy;
}
}
else if (dwStyle & CBRS_ORIENT_VERT)
{
lpLayout->sizeTotal.cx += size.cx;
lpLayout->sizeTotal.cy = max(lpLayout->sizeTotal.cy, size.cy);
if (dwStyle & CBRS_ALIGN_LEFT)
lpLayout->rect.left += size.cx;
else if (dwStyle & CBRS_ALIGN_RIGHT)
{
rect.left = rect.right - size.cx;
lpLayout->rect.right -= size.cx;
}
}
else //Line 881 Barcore.cpp
{
ASSERT(FALSE); // can never happen
}
rect.right = rect.left + size.cx;
rect.bottom = rect.top + size.cy;
// only resize the window if doing layout and not just rect query
if (lpLayout->hDWP != NULL)
AfxRepositionWindow(lpLayout, m_hWnd, &rect);
}
return 0;
}
In the instruction says that The Dialog has:
Style: Child
Boarder: None
Visible: Unchecked (It means that I need to set "FALSE", is it right?).
Yes, I've tried changing code, I still I don't know where is the error.
Thank you so much.
-
September 13th, 2013, 07:08 AM
#17
Re: [RESOLVED] Creating DialogBar with my own controls (MFC)
I'm confused... Don't you understand this code snippet from barcore.cpp you have posted?
Code:
if (dwStyle & CBRS_ORIENT_HORZ)
{
lpLayout->sizeTotal.cy += size.cy;
lpLayout->sizeTotal.cx = max(lpLayout->sizeTotal.cx, size.cx);
if (dwStyle & CBRS_ALIGN_TOP)
lpLayout->rect.top += size.cy;
else if (dwStyle & CBRS_ALIGN_BOTTOM)
{
rect.top = rect.bottom - size.cy;
lpLayout->rect.bottom -= size.cy;
}
}
else if (dwStyle & CBRS_ORIENT_VERT)
{
lpLayout->sizeTotal.cx += size.cx;
lpLayout->sizeTotal.cy = max(lpLayout->sizeTotal.cy, size.cy);
if (dwStyle & CBRS_ALIGN_LEFT)
lpLayout->rect.left += size.cx;
else if (dwStyle & CBRS_ALIGN_RIGHT)
{
rect.left = rect.right - size.cx;
lpLayout->rect.right -= size.cx;
}
}
else //Line 881 Barcore.cpp
{
ASSERT(FALSE); // can never happen
}
dwStyle must contain either CBRS_ORIENT_VERT or CBRS_ORIENT_HORZ flag. But in your case neither was set! Therefore you see this "assertion failed" dialog!
Victor Nijegorodov
-
September 13th, 2013, 08:16 AM
#18
Re: [RESOLVED] Creating DialogBar with my own controls (MFC)
Dear VictorN,
Thank you so much for your help. It works now, I have wonderful feeling now.
Once again, Thank you so much.
Wishing you a beautiful weekend.
-
September 13th, 2013, 08:18 AM
#19
Re: [RESOLVED] Creating DialogBar with my own controls (MFC)
You are welcome and thankyou!
Victor Nijegorodov
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|