给工具栏添加一个组合框
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;

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(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1;      // fail to create
}

if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1;      // fail to create
}

// TODO: Delete these three lines if you don't want the toolbar to
//  be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);

int nItemIdx;
RECT rect;
nItemIdx = m_wndToolBar.CommandToIndex(ID_NEWBAR);
m_wndToolBar.SetButtonInfo(nItemIdx, ID_NEWBAR, TBBS_SEPARATOR, 200);
m_wndToolBar.GetItemRect(nItemIdx, &rect);
rect.top += 2;
rect.bottom += 100;
if (!m_wndToolBar.m_wndEngine.Create(WS_CHILD |WS_VISIBLE| CBS_AUTOHSCROLL| CBS_DROPDOWNLIST | CBS_HASSTRINGS , rect, 
&m_wndToolBar, ID_NEWBAR))
{  
TRACE0("Failed to create combo box\n");
return -1;
}
m_wndToolBar.m_wndEngine.ShowWindow(SW_SHOW);
m_wndToolBar.m_wndEngine.AddString("Google");
m_wndToolBar.m_wndEngine.AddString("Baidu");
m_wndToolBar.m_wndEngine.AddString("Yahoo");
m_wndToolBar.m_wndEngine.AddString("eBay");
m_wndToolBar.m_wndEngine.SetCurSel(1);

return 0;
}
CComboToolBar m_wndToolBar;
CComboBox     m_wndEngine;
错误提示:
Compiling...
MainFrm.cpp
E:\vc++程序\ToolBatTest\MainFrm.cpp(55) : error C2065: 'IDR_MAINFRAME' : undeclared identifier
E:\vc++程序\ToolBatTest\MainFrm.cpp(77) : error C2065: 'ID_NEWBAR' : undeclared identifier
Error executing cl.exe.ToolBatTest.exe - 2 error(s), 0 warning(s)
在程序中都定义了啊 很不解
求助大家  谢谢

解决方案 »

  1.   

    各个资源定义等都在resource.h,文件中,不需要的时候是包含的其他文件中已经包含了这个h文件
      

  2.   

    谢谢你们啊
    我还有个问题  没有分了~~
    Linking...
    MainFrm.obj : error LNK2001: unresolved external symbol "public: __thiscall CComboToolBar::CComboToolBar(void)" (??0CComboToolBar@@QAE@XZ)
    MainFrm.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall CComboToolBar::~CComboToolBar(void)" (??1CComboToolBar@@UAE@XZ)
    Debug/CToolBar.exe : fatal error LNK1120: 2 unresolved externals
    Error executing link.exe.CToolBar.exe - 3 error(s), 0 warning(s)
    这个错误怎么改啊 
    是上面的程序 
      

  3.   

    CComboToolBar是你自己的函数?类中定义了构造和析构函数但没有实现。