新创建了一个单文档工程,在int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)中添加如下代码:
      m_wndToolBar.GetToolBarCtrl().SetButtonWidth(50, 150); 
      m_wndToolBar.SetButtonText(0, "Test");
然后执行,窗体中没有任何反应。请指点。

解决方案 »

  1.   

    在OnCreate中调用应该没问题,你试试刷新一下toolbar
      

  2.   

    void CMainFrame::SetToolBarButtonText(CToolBar *pBar, UINT nIDString, LPCTSTR lpTextName)
    {
    ASSERT_VALID(pBar); TCHAR chSep = _T('\n');
    CString strButtons;
        strcpy(strButtons.GetBuffer(0), lpTextName); 
    VERIFY(strButtons.LoadString (nIDString));
    int nIndex = 0;
    LPCTSTR pszStart = strButtons;
    LPCTSTR pszEnd = NULL; do
    {
    pszEnd = _tcschr(pszStart, chSep);
    int nLen = (pszEnd == NULL)?_tcslen(pszStart):(int)(pszEnd - pszStart); ASSERT(nLen >= 0); CString strSubString;
    memcpy(strSubString.GetBufferSetLength(nLen), pszStart, nLen* sizeof(TCHAR)); pBar->SetButtonText(nIndex++, strSubString);

    pszStart += nLen + 1; }
    while (pszEnd != NULL);

    }来看看啊!