//创建对话框工具条
if(!this->m_wndDialogBar.Create(this,IDD_DIALOGBAR,CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC,IDD_DIALOGBAR))
{ TRACE0("Failed to create dialogbar\n"); return -1; // fail to create }运行后是这样:
那个dialog bar 死都不显示,
俺快要挂了,搞了一天了,baidu, goole的门槛都被我踩破了,找不到办法,只能求助各位牛人了!
谢谢!
{
TRACE0("Failed to create dialogbar - DlgBarScanner\n");
return -1; // fail to create
}
//创建对话框工具条
if(!this->m_wndDialogBar.Create(this,IDD_DIALOGBAR,CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE,IDD_DIALOGBAR))
{ TRACE0("Failed to create dialogbar\n"); return -1; // fail to create }这样不可以吗?
if (!m_wndDialogBar.Create(this,IDD_DIALOG1,WS_CHILD|WS_VISIBLE|CBRS_TOP,AFX_IDW_DIALOGBAR)) {
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
我用一模一样的方法在另外一个项目里写,可以显示,在这个里面他就是不显示,
死都不显示呀,网上能找到的方法都试了没用!
// MainFrm.cpp : CMainFrame 类的实现
//#include "stdafx.h"
#include "3DModoel Manager.h"#include "MainFrm.h"
#include "3DModoel ManagerView.h"#ifdef _DEBUG
#define new DEBUG_NEW
#endif// CMainFrameIMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx)BEGIN_MESSAGE_MAP(CMainFrame, CFrameWndEx)
ON_WM_CREATE()
ON_COMMAND(ID_VIEW_CUSTOMIZE, &CMainFrame::OnViewCustomize)
ON_REGISTERED_MESSAGE(AFX_WM_CREATETOOLBAR, &CMainFrame::OnToolbarCreateNew)
END_MESSAGE_MAP()static UINT indicators[] =
{
ID_SEPARATOR, // 状态行指示器
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};// CMainFrame 构造/析构CMainFrame::CMainFrame()
{
// TODO: 在此添加成员初始化代码
}CMainFrame::~CMainFrame()
{
}int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWndEx::OnCreate(lpCreateStruct) == -1)
return -1; /*BOOL bNameValid;*/ // 设置用于绘制所有用户界面元素的视觉管理器
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005)); if (!m_wndMenuBar.Create(this))
{
TRACE0("未能创建菜单栏\n");
return -1; // 未能创建
} m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY); // 防止菜单栏在激活时获得焦点
CMFCPopupMenu::SetForceMenuFocus(FALSE); //if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
// !m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME))
//{
// TRACE0("未能创建工具栏\n");
// return -1; // 未能创建
//} /*CString strToolBarName;
bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD);
ASSERT(bNameValid);
m_wndToolBar.SetWindowText(strToolBarName);*/ /*CString strCustomize;
bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE);
ASSERT(bNameValid);
m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize);*/ //创建对话框工具条
if(!this->m_wndDialogBar.Create(this,IDD_DIALOGBAR,CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC,IDD_DIALOGBAR))
{
TRACE0("Failed to create dialogbar\n");
return -1; // fail to create
} if (!m_wndStatusBar.Create(this))
{
TRACE0("未能创建状态栏\n");
return -1; // 未能创建
}
m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)); // TODO: 如果您不希望工具栏和菜单栏可停靠,请删除这五行
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
/*m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);*/
EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndMenuBar);
/*DockPane(&m_wndToolBar);*/
// 启用 Visual Studio 2005 样式停靠窗口行为
CDockingManager::SetDockingMode(DT_SMART);
// 启用 Visual Studio 2005 样式停靠窗口自动隐藏行为
EnableAutoHidePanes(CBRS_ALIGN_ANY); // 启用工具栏和停靠窗口菜单替换
/*EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR);*/ // 启用快速(按住 Alt 拖动)工具栏自定义
CMFCToolBar::EnableQuickCustomization(); return 0;
}BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWndEx::PreCreateWindow(cs))
return FALSE;
// TODO: 在此处通过修改
// CREATESTRUCT cs 来修改窗口类或样式 return TRUE;
}// CMainFrame 诊断#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWndEx::AssertValid();
}void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWndEx::Dump(dc);
}
#endif //_DEBUG
// CMainFrame 消息处理程序void CMainFrame::OnViewCustomize()
{
CMFCToolBarsCustomizeDialog* pDlgCust = new CMFCToolBarsCustomizeDialog(this, TRUE /* 扫描菜单*/);
pDlgCust->Create();
}LRESULT CMainFrame::OnToolbarCreateNew(WPARAM wp,LPARAM lp)
{
LRESULT lres = CFrameWndEx::OnToolbarCreateNew(wp,lp);
if (lres == 0)
{
return 0;
} CMFCToolBar* pUserToolbar = (CMFCToolBar*)lres;
ASSERT_VALID(pUserToolbar); BOOL bNameValid;
CString strCustomize;
bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE);
ASSERT(bNameValid); pUserToolbar->EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize);
return lres;
}BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: 在此添加专用代码和/或调用基类 // create a splitter with 1 row, 2 columns
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
} // add the first splitter pane - the default view in column 0
if (!m_wndSplitter.CreateView(0, 0,
RUNTIME_CLASS(cClassTreeView), CSize(130, 50), pContext))
{
TRACE0("Failed to create first pane\n");
return FALSE;
} // add the second splitter pane - an input view in column 1
if (!m_wndSplitter.CreateView(0, 1,
RUNTIME_CLASS(CMy3DModoelManagerView), CSize(0, 0), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
} // activate the input view
SetActiveView((CView*)m_wndSplitter.GetPane(0,1));
return TRUE;
}
//#pragma onceclass CMainFrame : public CFrameWndEx
{
protected: // 仅从序列化创建
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)// 属性
public:// 操作
public:// 重写
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
CSplitterWnd m_wndSplitter;
// 实现
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endifprotected: // 控件条嵌入成员
CMFCMenuBar m_wndMenuBar;
CMFCStatusBar m_wndStatusBar;
CDialogBar m_wndDialogBar;// 生成的消息映射函数
protected:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnViewCustomize();
afx_msg LRESULT OnToolbarCreateNew(WPARAM wp, LPARAM lp);
DECLARE_MESSAGE_MAP() virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
};
~
#define AFX_IDW_TOOLBAR 0xE800 // main Toolbar for window
#define AFX_IDW_STATUS_BAR 0xE801 // Status bar window
#define AFX_IDW_PREVIEW_BAR 0xE802 // PrintPreview Dialog Bar
#define AFX_IDW_RESIZE_BAR 0xE803 // OLE in-place resize bar
#define AFX_IDW_REBAR 0xE804 // COMCTL32 "rebar" Bar
#define AFX_IDW_DIALOGBAR 0xE805 // CDialogBar