Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Controls
  New Posts New Posts RSS Feed - [SOLVED] Cannot hide buttons in EditListBox
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[SOLVED] Cannot hide buttons in EditListBox

 Post Reply Post Reply
Author
Message
docontrol View Drop Down
Groupie
Groupie


Joined: 07 December 2009
Location: Denmark
Status: Offline
Points: 35
Post Options Post Options   Thanks (0) Thanks(0)   Quote docontrol Quote  Post ReplyReply Direct Link To This Post Topic: [SOLVED] Cannot hide buttons in EditListBox
    Posted: 06 July 2020 at 6:00am
There seem to be a bug in the source code for the CXTPEditListBox control in 19.2. If I call SetListEditStyle with LBS_XTP_ONLY_UP_DOWN to hide new and delete buttons the application will still try to apply markup to the hidden buttons. I can workaround the bug by manually hiding those buttons after creation, but it seems to me that there is a bug here. What makes me in doubt is the fact the LBS_XTP_ONLY_UP_DOWN is not mentioned in the CodeJock help file regarding the CXTPEditListBox::SetListEditStyle method. Is that also a bug?

The bug mentioned is in XTPEditListBox.cpp on lines 866-869:

GetNewButton().SetWindowText(xamlAdd); <--- Should not be called if !m_bShowNewDeleteButtons
GetDeleteButton().SetWindowText(xamlDel); <--- Should not be called if !m_bShowNewDeleteButtons
GetUpButton().SetWindowText(xamlUp);
GetDownButton().SetWindowText(xamlDown);

Instead of applying the markup for all buttons after the for loop on lines 824-854, I would simply move the code inside the loop and apply it using a switch statement, e.g.:

CString xamlBtn;
UINT nIDResource;
switch (i)
{
case 0:
nIDResource = IDR_XAML_ICON_LIST_SYMBOL_ADD;
break;
case 1:
nIDResource = IDR_XAML_ICON_LIST_SYMBOL_DELETE;
break;
case 2:
nIDResource = IDR_XAML_ICON_LIST_SYMBOL_ARROW_UP;
break;
case 3:
nIDResource = IDR_XAML_ICON_LIST_SYMBOL_ARROW_DOWN;
break;
}
VERIFY(XTPResourceManager()->LoadXAML(xamlBtn, nIDResource));
m_arButton[ i ].SetWindowText(xamlBtn);

Back to Top
agontarenko View Drop Down
Admin Group
Admin Group


Joined: 25 March 2016
Status: Offline
Points: 291
Post Options Post Options   Thanks (0) Thanks(0)   Quote agontarenko Quote  Post ReplyReply Direct Link To This Post Posted: 08 July 2020 at 2:59am
Hello,

It known bug, and it already fixed.
As hotfix you need to replace
void CXTPEditListBoxToolBar::Initialize(bool bAutoFont /*= true*/) function in next file
C:\Program Files (x86)\Codejock Software\MFC\Xtreme ToolkitPro v19.2.0\Source\Controls\ListBox\XTPEditListBox.cpp

with

void CXTPEditListBoxToolBar::Initialize(bool bAutoFont /*= true*/)
{
    // Create the ToolTip control.
    m_tooltip.Create(this);
    m_tooltip.Activate(TRUE);

    for (int i = 0; i < _countof(m_arButton); ++i)
    {
        if ((!m_bShowNewDeleteButtons) && ((i == 0) || (i == 1)))
            continue;

        if ((!m_bShowUpDownButtons) && ((i == 2) || (i == 3)))
            continue;

        if (!m_arButton.Create(NULL, WS_CHILD | WS_VISIBLE | BS_ICON | BS_CENTER | BS_VCENTER,
                                  CRect(0, 0, 0, 0), this, _arButtonID))
        {
            TRACE0("Unable to create edit button.\n");
            continue;
        }

        CString strToolTip;
        CXTPResourceManager::AssertValid(
            XTPResourceManager()->LoadString(&strToolTip, _arButtonID));
        // Add tooltips to group buttons.
        m_tooltip.AddTool(&m_arButton, strToolTip);

        // make sure the button is Windows XP theme compatible using
        // the toolbar button theme.
        if (m_arButton.SetTheme(xtpControlThemeFlat))
        {
            CXTPButtonTheme* pTheme = m_arButton.GetTheme();
            if (pTheme)
            {
                pTheme->EnableToolbarStyle(TRUE);
            }
            m_arButton.SetUseVisualStyle(TRUE);
        }

        m_arButton.EnableMarkup();
    }

    if (m_bShowNewDeleteButtons)
    {
        CString xamlAdd, xamlDel;
        VERIFY(XTPResourceManager()->LoadXAML(xamlAdd, IDR_XAML_ICON_LIST_SYMBOL_ADD));
        VERIFY(XTPResourceManager()->LoadXAML(xamlDel, IDR_XAML_ICON_LIST_SYMBOL_DELETE));
        GetNewButton().SetWindowText(xamlAdd);
        GetDeleteButton().SetWindowText(xamlDel);
    }
    if (m_bShowUpDownButtons)
    {
        CString xamlUp, xamlDown;
        VERIFY(XTPResourceManager()->LoadXAML(xamlUp, IDR_XAML_ICON_LIST_SYMBOL_ARROW_UP));
        VERIFY(XTPResourceManager()->LoadXAML(xamlDown, IDR_XAML_ICON_LIST_SYMBOL_ARROW_DOWN));
        GetUpButton().SetWindowText(xamlUp);
        GetDownButton().SetWindowText(xamlDown);
    }

    // Move the buttons to their correct location.
    MoveButtons();

    // Set the font for this window.
    if (bAutoFont)
    {
        SetFont(&XTPAuxData().xtpFont);
    }
}

Regards,
Artem Gontarenko
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.203 seconds.