September 14th, 2010, 01:41 PM
Using a CDialogBar with an MDI app
What I need to do is add an area (preferably at the top) to my app that will host some custom controls like buttons or whatever else I happen to need. I can't seem to get it working though. Here's what I'm doing, starting from scratch in Visual Studio 2010:
Name it skeleton
On the application type window:
Application type: Multiple Documents (uncheck tabbed documents)
Project style: MFC Standard
Now I add a dialog to the app by right-clicking my project, and going:
I now have a dialog, and add some buttons or text just so I can see it easily. For this skeleton app I'll leave it's id as IDD_DIALOGBAR.
Now I go to MainFrm.cpp (generated by the app wizard), find the OnCreate() function, and add the following code to the bottom of the function (but above the return in the function):
And in the protected section in MainFrm.h I add:
if (!m_wndDlgBar.Create(this, IDD_DIALOGBAR,
TRACE0("Failed to create DlgBar\n");
return -1; // fail to create
From what I've read, I would think that it would work at this point. But I get nothing. No error, just the dialogbar doesn't appear. A couple things I searched up on the net indicated that I would have to make a DockControlBar call to get it added, so I try adding this below the Create() call:
Now, at this point it bails on an assert in DockControlBar which says:
// assert fails when initial CBRS_ of bar does not
// match available docking sites, as set by EnableDocking()
I find this odd, as I think I specified any available dock site. Then again, I'm not convinced that I should even be doing these last two lines.
Anyone know what I'm missing here?
Edit: There is a working test project that does the kind of thing I want at:
I'm not sure what he's doing differently from me. The only significant difference I see is that my class is based on CMDIFrameWndEx and his is CMDIFrameWnd. Would that make a big difference?
Last edited by Ankheg; September 14th, 2010 at 01:51 PM.
Reason: Added more info
Tags for this Thread
Click Here to Expand Forum to Full Width