添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
玩命的火车  ·  搜索 / Search - ...·  1 月前    · 
被表白的橙子  ·  Setting Up the System ...·  10 月前    · 
耍酷的木瓜  ·  为前端保护 API ...·  1 年前    · 
直爽的猕猴桃  ·  Is there a Windows ...·  1 年前    · 
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register or Login before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. 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:
New->Project->MFC Application
Name it skeleton
On the application type window:
Application type: Multiple Documents (uncheck tabbed documents)
Project style: MFC Standard
Finish
Now I add a dialog to the app by right-clicking my project, and going:
Add->Resource
Dialog->IDD_DIALOGBAR
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):
Code:
if (!m_wndDlgBar.Create(this, IDD_DIALOGBAR,
	CBRS_LEFT|CBRS_TOOLTIPS|CBRS_FLYBY, IDD_DIALOGBAR))
	TRACE0("Failed to create DlgBar\n");
	return -1;      // fail to create
And in the protected section in MainFrm.h I add:
Code:
CDialogBar  m_wndDlgBar;
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:
Code:
m_wndDlgBar.EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndDlgBar);
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:
http://www.codeguru.com/forum/showthread.php?t=308712
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?
Code:
if (!m_wndDlgBar.Create(this, IDD_DIALOGBAR,
    CBRS_LEFT|CBRS_TOOLTIPS|CBRS_FLYBY, IDD_DIALOGBAR))
    TRACE0("Failed to create DlgBar\n");
    return -1;      // fail to create
And in the protected section in MainFrm.h I add:
Code:
CDialogBar  m_wndDlgBar;
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:
Code:
m_wndDlgBar.EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndDlgBar);
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. No you didn't. I'm not sure whether this is the reason for not showing the dialog bar but you specified CBRS_LEFT when creating the dialog bar and CBRS_ALIGN_ANY when trying to make it dockable.
Maybe this can help.
I do not know if it matters using CMDIFrameWndEx instead of CMDIFrameWnd. I would try it out with two projects from the scracth one using CMDIFrameWnd and the other one using CMDIFrameWndEx.
With regards
Programartist This was a helpful hint! I went back through the app wizard and created an app based on CMDIFrameWnd, and the dialogbar now displays with just the create() statement. The EnableDocking and DockControlBar aren't needed, at least with CMDIFrameWnd.
So I'm not really sure how to get it working with CMDIFrameWndEx, but I think what I'll do is just go back and rework my app to have no docking windows. Then I can use CMDIFrameWnd. * The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform. * Porting from Android to Windows 8: The Real Story
Do you have an Android application? How hard would it really be to port to Windows 8? * Guide to Porting Android Applications to Windows 8
If you've already built for Android, learn what do you really need to know to port your application to Windows Phone 8. * HTML5 Development Center
Our portal for articles, videos, and news on HTML5, CSS3, and JavaScript * Windows App Gallery
See the Windows 8.x apps we've spotlighted or submit your own app to the gallery! Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.