Print Page | Close Window

[SOLVED] Cannot hide buttons in EditListBox

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=24015
Printed Date: 23 November 2024 at 7:24pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [SOLVED] Cannot hide buttons in EditListBox
Posted By: docontrol
Subject: [SOLVED] Cannot hide buttons in EditListBox
Date 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);




Replies:
Posted By: agontarenko
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net