zoukankan      html  css  js  c++  java
  • 如何在工具栏中,加上图标和文字?

    a).如何在工具栏中,加上图标和文字?(How To Add Icon And Text)

    /********************************************************************/
    /* */
    /* Function name : CreateHotToolBar */
    /* Description : Create the main toolbar. */
    /* */
    /********************************************************************/
    BOOL CMainFrame::CreateHotToolBar()
    {
    if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
    | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC/*| CBRS_GRIPPER*/) ||
    !m_wndToolBar.LoadToolBar(IDR_TOOLBAR1))
    {
    TRACE0("Failed to create toolbar\n");
    return FALSE; // fail to create
    }

    // Set the text for each button
    CToolBarCtrl& bar = m_wndToolBar.GetToolBarCtrl();

    int nIndex = 0;
    TBBUTTON tb;

    for (nIndex = m_wndToolBar.GetToolBarCtrl().GetButtonCount() - 1; nIndex >= 0; nIndex--)
    {
    ZeroMemory(&tb, sizeof(TBBUTTON));
    m_wndToolBar.GetToolBarCtrl().GetButton(nIndex, &tb);

    // Do we have a separator?
    if ((tb.fsStyle & TBSTYLE_SEP) == TBSTYLE_SEP)
    continue;

    // Have we got a valid command id?
    if (tb.idCommand == 0)
    continue;

    // Get the resource string if there is one.
    CString strText;
    LPCTSTR lpszButtonText = NULL;
    CString strButtonText(_T(""));
    _TCHAR seps[] = _T("\n");

    strText.LoadString(tb.idCommand);

    if (!strText.IsEmpty())
    {
    lpszButtonText = _tcstok((LPTSTR)(LPCTSTR)strText, seps);

    while(lpszButtonText)
    {
    strButtonText = lpszButtonText;
    lpszButtonText = _tcstok(NULL, seps);
    }
    }

    if (!strButtonText.IsEmpty())
    m_wndToolBar.SetButtonText(nIndex, strButtonText);
    }


  • 相关阅读:
    线程安全
    转 接口和抽象类 虚方法 有什么区别
    转 面向对象的三个基本特征
    转载 泛型
    遍历list,字典
    转 拉姆达表达式,委托、匿名方法、Lambda表达式的演进
    int byte转换
    委托,匿名方法
    带参数线程,不带参数线程
    const readonly
  • 原文地址:https://www.cnblogs.com/confach/p/112082.html
Copyright © 2011-2022 走看看