调整列表列大小时出现HDN_ENDTRACK问题 [英] Problem with HDN_ENDTRACK when resizing a list column

查看:241
本文介绍了调整列表列大小时出现HDN_ENDTRACK问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在处理从CListCtrl派生的自定义类的HDN_ENDTRACKW消息时,我遇到了一些问题.

I am having a bit of a problem when handling a HDN_ENDTRACKW message for a custom class which derives from CListCtrl .

基本上,似乎发送此消息时,直到执行我的处理代码后,存储列宽度的实际值才更新.

Essentially, it seem that when this message is sent, the actual value which stores the width of the column is not updated until after my handling code has been executed.

句柄中的代码只是指示进度条调整大小,以填充调整后的列的宽度. 代码:

The code inside the handle simply instructs a progress bar to resize, to fill the width of the resized column. The code:

void ProgListCtrl::OnEndTrack(NMHDR* pNMHDR, LRESULT* pResult)
{
 int width = ListView_GetColumnWidth(GetSafeHwnd(), m_nProgressColumn);
 ResizeProgressbar();
}

ListView_GetColumnWidth只是为了帮助当前调试.

The ListView_GetColumnWidth is there just to help with debugging at the moment.

我要更改的特定列的默认值为150,当我在UI中调整该列的大小时,将调用此方法,但宽度保持不变,为150,进度条不会重新调整大小.只有当再次调整列的大小时,宽度值才可以在第一次调整大小后立即反映出该列的值,然后ResizeProgressBar方法然后正确更改程序栏大小以填充其所在的列.这是连续的,宽度值似乎总是比实际值落后一步.

The default value for the particular column I am changing is 150, when i resize the column in the UI, this method is called but the width stays at the same 150, the progress bar does not resize. Only when a column is resized again does the width value now reflect the value of the column after the first resize, the ResizeProgressBar method then correctly changes the progbar size to fill the column it is in. This is continuous, the width value always seems to be one step behind the actual value.

我将不胜感激.干杯.

推荐答案

使用HDN_ENDTRACK本身提供给您的信息,即:

Use the information that HDN_ENDTRACK itself provides to you, ie:

void ProgListCtrl::OnEndTrack(NMHDR* pNMHDR, LRESULT* pResult)
{
    NMHEADER *pHdr = (NMHEADER*) pNMHDR;
    if ((pHdr->iItem == m_nProgressColumn) &&
        (pHdr->pitem) &&
        (pHdr->pitem->mask & HDI_WIDTH))
    {
        int width = pHdr->pitem->cxy;
        ResizeProgressbar();
    }
}

或者,查看HDN_ITEMCHANGINGHDN_ITEMCHANGED通知而不是HDN_ENDTRACK.

Alternatively, look at the HDN_ITEMCHANGING and HDN_ITEMCHANGED notifications instead of HDN_ENDTRACK.

这篇关于调整列表列大小时出现HDN_ENDTRACK问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆