[RESOLVED] Creating DialogBar with my own controls (MFC) - Page 2
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19

Thread: [RESOLVED] Creating DialogBar with my own controls (MFC)

  1. #16
    Join Date
    Sep 2013
    Posts
    5

    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.

  2. #17
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,301

    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

  3. #18
    Join Date
    Sep 2013
    Posts
    5

    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.

  4. #19
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,301

    Re: [RESOLVED] Creating DialogBar with my own controls (MFC)

    You are welcome and thankyou!
    Victor Nijegorodov

Page 2 of 2 FirstFirst 12

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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center