[MFC]dialogBar not showing
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: [MFC]dialogBar not showing

  1. #1
    Join Date
    May 2010
    Posts
    12

    Angry [MFC]dialogBar not showing

    Hi, Im developing an SDI with no File/View support app with MFC using Visual Studio 2010 RC and I need to add a dialogBar with some owner drawn buttons, so I'm following this tutorial (and the links to the MSDN it provides):

    http://www.codeproject.com/KB/toolba...vedDlgBar.aspx

    I derived the class and drawn the dialogbar resource like it said there and in fact my bar seems to be created but for some reason its not showing! I'm reading in the MSDN doccumentation that the resorce must have the visible attribute "unchecked" or even not having it at all, but in the resource editor you just can change it to true/false. I opened the .rc file with a text editor and deleted WS_VISIBLE , rebuild, execute...and still nothing happens.

    I tried in 2 kind of wizard generated projects , one checking "Use a classic menu" and "menu bar and toolbar"

    The first one just not shows the dialogbar without any errors, warning or assertions/exceptions, but the in the second option an assertion is triggered
    [code]
    DockControlBar(&m_myDlgBar);

    Code:
    m_myDlgBar.EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
    	m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
    	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
    	EnableDocking(CBRS_ALIGN_ANY);
    	DockControlBar(&m_myDlgBar);// ---------------------------------------->CRASHES HERE
    	DockPane(&m_wndMenuBar);
    	DockPane(&m_wndToolBar);
    (in winfrm2.cpp)
    Code:
    void CFrameWnd::DockControlBar(CControlBar* pBar, CDockBar* pDockBar, LPCRECT lpRect)
    {
    	ENSURE_ARG(pBar != NULL);
    	// make sure CControlBar::EnableDocking has been called
    	ASSERT(pBar->m_pDockContext != NULL);
    
    	if (pDockBar == NULL)
    	{
    		for (int i = 0; i < 4; i++)
    		{
    			if ((dwDockBarMap[i][1] & CBRS_ALIGN_ANY) ==
    				(pBar->m_dwStyle & CBRS_ALIGN_ANY))
    			{
    				pDockBar = (CDockBar*)GetControlBar(dwDockBarMap[i][0]);
    				ASSERT(pDockBar != NULL);
    				// assert fails when initial CBRS_ of bar does not
    				// match available docking sites, as set by EnableDocking()
    				break;
    			}
    		}
    	}
    	ENSURE_ARG(pDockBar != NULL); <----------------------------------------------THAT ONE
    	ASSERT(m_listControlBars.Find(pBar) != NULL);
    	ASSERT(pBar->m_pDockSite == this);
    	// if this assertion occurred it is because the parent of pBar was not initially
    	// this CFrameWnd when pBar's OnCreate was called
    	// i.e. this control bar should have been created with a different parent initially
    
    	pDockBar->DockControlBar(pBar, lpRect);
    }
    I've been researching a little and a "Dockbar" object it supposed to be created when you call the enableDocking methods...

    I don't know what to do! This last case doesn't matter that much because i will probably stick with the classic menu (I don't need any toolbar/menubar in my project), but I think maybe posting it would help to clarify somehow(?)

    So what do you suggest? Maybe is Visual Studio fault? Need to format the computer?Throwing it out of the window perhaps?I have no clue ...

    Thank in advance for your help!

  2. #2
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,100

    Re: [MFC]dialogBar not showing

    Quote Originally Posted by Rez_Spain View Post
    I've been researching a little and a "Dockbar" object it supposed to be created when you call the enableDocking methods...
    Where did you pick that up ? The only thing enabledocking do is doing some housekeeping to allow the window to be docked into the frame.

    You need to create your child windows (in this case the dialogbar) yourself, the ideal place to do so is in the OnCreate() of the framewindow.

  3. #3
    Join Date
    May 2010
    Posts
    12

    Re: [MFC]dialogBar not showing

    Quote Originally Posted by OReubens View Post
    Where did you pick that up ? The only thing enabledocking do is doing some housekeeping to allow the window to be docked into the frame.

    You need to create your child windows (in this case the dialogbar) yourself, the ideal place to do so is in the OnCreate() of the framewindow.
    Honestly i have a mess of articles in my head right now and probably i didnt understand well that one

    As I posted previously, i create the dialogbar like this:

    Code:
    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
       ..........................
    
    if (!m_myDlgBar.Create(this, IDD_DIALOGBAR,
                            CBRS_TOP | CBRS_GRIPPER |CBRS_TOOLTIPS | 
                            CBRS_FLYBY | CBRS_HIDE_INPLACE,
                            IDD_VIEW_DIALOGBAR))
                    {
                            TRACE0("Failed to create dialog bar m_wndDlgBar\n");
                            return -1;              // fail to create
    
                    }
    
    ...
    and later do
    Code:
    	m_myDlgBar.EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
    .....
    	EnableDocking(CBRS_ALIGN_ANY);
    	DockControlBar(&m_myDlgBar);
    Is that what you mean?

  4. #4
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,100

    Re: [MFC]dialogBar not showing

    yes. you create the dialogbar, then tell it to be dockable.

    skipping the call to enabledocking, means the dialogbar will be "hard docked" in the side you mentioned in the create-call and the user can't float the dialog or dock it at another side of the frame.

  5. #5
    Join Date
    May 2010
    Posts
    12

    Re: [MFC]dialogBar not showing

    Well, the I will skip the last part because I want it hard docked,thanks.
    But the problem is that the dialog bar is not showing either way (dockable or not), and I'm sure than the
    m_myDlgBar.Create(this, IDD_DIALOGBAR,
    CBRS_TOP | CBRS_GRIPPER |CBRS_TOOLTIPS |
    CBRS_FLYBY | CBRS_HIDE_INPLACE,
    IDD_VIEW_DIALOGBAR)

    is executed and returns no error. This is what puzzles me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center