调整列表列大小时出现 HDN_ENDTRACK 问题

发布于 2024-08-04 14:29:54 字数 579 浏览 2 评论 0原文

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

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

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

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

ListView_GetColumnWidth 只是为了帮助目前的调试。

我要更改的特定列的默认值是 150,当我在 UI 中调整列大小时,会调用此方法,但宽度保持在 150 不变,进度条不会调整大小。仅当再次调整列大小时,宽度值现在才会反映第一次调整大小后的列值,ResizeProgressBar 方法然后正确更改 progbar 大小以填充其所在的列。这是连续的,宽度值似乎总是比实际值落后一步。

我将不胜感激任何帮助。干杯。

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();
}

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

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.

I would apreciate any help. Cheers.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嗳卜坏 2024-08-11 14:29:54

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

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代码>.

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();
    }
}

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文